@omfalos/mokosh 0.5.0 → 0.5.2
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/dist/cli.js +104 -56
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +104 -56
- package/dist/cli.mjs.map +1 -1
- package/dist/duplication-worker.d.mts +1 -1
- package/dist/duplication-worker.d.ts +1 -1
- package/dist/duplication-worker.js +6 -4
- package/dist/duplication-worker.js.map +1 -1
- package/dist/duplication-worker.mjs +6 -4
- package/dist/duplication-worker.mjs.map +1 -1
- package/dist/index.d.mts +1164 -48
- package/dist/index.d.ts +1164 -48
- package/dist/index.js +48 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -37
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +52 -39
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +52 -39
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.d.mts +1 -1
- package/dist/parse-worker.d.ts +1 -1
- package/dist/parse-worker.js +6 -6
- package/dist/parse-worker.js.map +1 -1
- package/dist/parse-worker.mjs +6 -6
- package/dist/parse-worker.mjs.map +1 -1
- package/dist/{tokenizer-DIbb0GLe.d.mts → tokenizer-D9P-y7lH.d.mts} +1 -1
- package/dist/{tokenizer-DIbb0GLe.d.ts → tokenizer-D9P-y7lH.d.ts} +1 -1
- package/dist/{types-y90pqeDR.d.ts → types-B4jVIqMD.d.ts} +7 -0
- package/dist/{types-C153Tz5u.d.mts → types-qfwcXiZS.d.mts} +7 -0
- package/package.json +1 -1
- package/templates/skill/SKILL.md +1 -1
- package/templates/skill/mokosh.md +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,63 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}}});var
|
|
4
|
-
`)){if(o.startsWith("\0")){let[,c,
|
|
5
|
-
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(
|
|
6
|
-
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(
|
|
7
|
-
`&&
|
|
8
|
-
`)){let o=
|
|
9
|
-
`),s=[],i=new Set;for(let
|
|
10
|
-
`),s=[],i=new Set;for(let p of o){let f=p.match(Wp);if(f?.[1]){s.push(Ee(t,f[1]));continue}let u=p.match(zp);if(u?.[2]){i.add(u[2]);continue}let y=p.match(Bp);if(y?.[1]){i.add(y[1]);continue}let x=p.match(Hp);x?.[1]&&i.add(x[1])}let a=j(e,!1);a&&s.push(X(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:B(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:we(e).annotations})}}var Wp,en,zp,Bp,Hp,Rs=g(()=>{"use strict";l();Te();Wp=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,en="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",zp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),Bp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Hp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import Up from"livescript";function se(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Jp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=se(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>se(r.key)??se(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=se(t);return e?[{name:e}]:[]}function Kp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=se(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return Jp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>se(n.val)??se(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function qp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=Q(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:R(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=Q(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:R(s),type:"require"}}}}return null}function tn(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=qp(t,e);o&&n.push(o),r.push(...Kp(t));for(let s in t){if(Vp.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...tn(a,e,r));else n.push(...tn(i,e,r))}return n}function As(t,e){let r=be(e),n=Se(t,r),o=[],s=[];try{o=tn(Up.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Vp,Ms=g(()=>{"use strict";l();q();kt();Vp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Qp from"luaparse";function Yp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=Q(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=Q(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:R(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Xp(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Zp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function ef(t){let e=t.body,r=Xp(e),n=Zp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Ls(t,e){let r=be(e),n=Se(t,r),o=[],s=[];try{let i=Qp.parse(e);o=Yp(i,t),s=ef(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Os=g(()=>{"use strict";l();q();kt()});async function of(){return _s??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),_s}function sf(t){let e=t.trim();return e.length===0||e.startsWith("#")||tf.some(r=>e.startsWith(r))}function af(t,e){let r=t.match(nf);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function Gs(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!sf(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...af(t.value,e)),Array.isArray(t.children))for(let n of t.children)Gs(n,e,r)}async function js(t,e){let n=(await of()).parse(e),o=[];Gs(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var tf,rf,nf,_s,$s=g(()=>{"use strict";l();tf=["http://","https://","mailto:","//"],rf="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",nf=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${rf})\\b`,"g")});function cf(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=ne(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=ne(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function lf(t,e){let r=0,n=ne(t),o=0,s=0;for(;s<n.length;){let i=n[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;r+=a?1:1+e;let c=a?e:e+1,p=n[s+1],f=n[s+2];p&&(r+=H(p,c)),f&&(r+=H(f,c)),o++,s+=3}else if(i?.type.name==="else"){r+=1;let a=n[s+1];a&&(r+=H(a,e+1)),s+=2}else s++}return r}function pf(t,e){let r=0,n=ne(t),o=0;for(;o<n.length;){let s=n[o];if(s?.type.name==="except"){for(r+=1+e,o++;o<n.length&&n[o]?.type.name!=="Body";)r+=H(n[o],e),o++;o<n.length&&(r+=H(n[o],e),o++)}else s?.type.name==="Body"&&(r+=H(s,e)),o++}return r}function Ws(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=H(n,e+1),n=n.nextSibling;return r}function ff(t,e){let r=0,n=t.firstChild;for(;n;)r+=H(n,e),n=n.nextSibling;return r}function H(t,e){let r=t.type.name;switch(r){case"IfStatement":return lf(t,e);case"TryStatement":return pf(t,e);case"ForStatement":case"WhileStatement":return Ws(t,e);default:{let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+Ws(t,e):n+ff(t,e)}}}function mf(t){return H(t,0)}function rn(t){return{complexity:cf(t),cognitiveComplexity:mf(t)}}function zs(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=rn(i);r.push({name:a,line:oe(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let u=f.getChild("VariableName"),y=u?e.slice(u.from,u.to):void 0;y&&n(f,c?`${c}.${y}`:y),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var Bs=g(()=>{"use strict";l();vt()});import uf from"path";import{parser as gf}from"@lezer/python";function Hs(t,e){let r=[],n=[],o=new Set,s=uf.basename(t).toLowerCase(),i=gf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of hf(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let w=a.node.getChild("VariableName");w&&n.push({name:e.slice(w.from,w.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=kf(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=rn(i.topNode),u=zs(i,e),y=c==="test"?[]:Cf(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:f,...u.length>0?{functions:u}:{}}}function hf(t,e,r){let n=t.firstChild;return n?n.name==="from"?yf(t,e,r):xf(t,e,r):[]}function yf(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=bf(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[He(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[He(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[He(r,p.slice(0,-1),["*"],!1)]:i.map(f=>He(r,p+f,[f],!1))}function xf(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(He(r,s,["*"],!0))}o=o.nextSibling}return n}function bf(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function Sf(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),u=i.nextSibling;for(;u;){if(u.type.name==="VariableName"){let y=e.slice(u.from,u.to),x=y;if(u.nextSibling?.type.name==="as"){let w=u.nextSibling.nextSibling;w?.type.name==="VariableName"&&(x=e.slice(w.from,w.to),u=w)}let b=c===0?a:p?f+p.replace(/\./g,"/"):f+y;r.set(x,b)}u=u.nextSibling}}while(n.next());return r}function Cf(t,e){let r=Sf(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,u=e.slice(f.from,f.to),y=r.get(u);y&&n.push({from:c,to:u,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,f=a.getChild("Body");if(f){let u=f.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let y=u.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(u,p?`${p}.${x}`:x)}else i(u);u=u.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function He(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function kf(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>df.has(n.rawSpecifier))?"test":"logic"}var df,Us=g(()=>{"use strict";l();Bs();df=new Set(["pytest","unittest","nose","hypothesis"])});function Ef(t,e){let r=e.split("=>")[0]?.trim();return r?r==="_"||r==="*"||r==="given"?`${t}.*`:`${t}.${r}`:null}function Tf(t){let e=t.indexOf("{");if(e!==-1){let n=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,n===-1?void 0:n);return o?s.split(",").map(i=>Ef(o,i.trim())).filter(i=>i!=null):[]}let r=[];for(let n of t.split(",")){let o=n.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&r.push(`${s}.*`)}else r.push(o)}return r}function Js(t,e){let r=ve(e),o=Y(e).split(`
|
|
11
|
-
`),s=[],i=new Set;for(let p of o){let f=p.match(vf);if(f?.[1]){for(let y of Tf(f[1]))s.push(Ee(t,y));continue}let u=p.match(wf);u?.[2]&&i.add(u[2])}let a=j(e,!0);a&&s.push(X(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:B(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:we(e).annotations})}}var vf,wf,Ks=g(()=>{"use strict";l();Te();vf=/^\s*import\s+(.+?)\s*$/,wf=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/});import C from"typescript";function Ff(t){let e=1;function r(n){switch(n.kind){case C.SyntaxKind.IfStatement:case C.SyntaxKind.ConditionalExpression:case C.SyntaxKind.ForStatement:case C.SyntaxKind.ForInStatement:case C.SyntaxKind.ForOfStatement:case C.SyntaxKind.WhileStatement:case C.SyntaxKind.DoStatement:case C.SyntaxKind.CatchClause:case C.SyntaxKind.CaseClause:e++;break;case C.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===C.SyntaxKind.AmpersandAmpersandToken||o===C.SyntaxKind.BarBarToken||o===C.SyntaxKind.QuestionQuestionToken)&&e++;break}}C.forEachChild(n,r)}return r(t),e}function qs(t,e,r){let n=r?1:1+e,o=r?e:e+1;return n+=ie(t.expression,o,!1),n+=ie(t.thenStatement,o,!1),t.elseStatement&&(C.isIfStatement(t.elseStatement)?n+=qs(t.elseStatement,e,!0):n+=1+ie(t.elseStatement,e+1,!1)),n}function Vs(t,e){let r=1+e;return C.forEachChild(t,n=>{r+=ie(n,e+1,!1)}),r}function Nf(t,e){let r=1+e;return C.forEachChild(t,n=>{r+=ie(n,e,!1)}),r}function Pf(t,e){let r=0;return C.forEachChild(t,n=>{r+=ie(n,e,!1)}),r}function Df(t){let e=t.operatorToken.kind;return e===C.SyntaxKind.AmpersandAmpersandToken||e===C.SyntaxKind.BarBarToken||e===C.SyntaxKind.QuestionQuestionToken}function ie(t,e,r){if(C.isIfStatement(t))return qs(t,e,r);if(C.isForStatement(t)||C.isForInStatement(t)||C.isForOfStatement(t)||C.isWhileStatement(t)||C.isDoStatement(t)||C.isSwitchStatement(t))return Vs(t,e);if(C.isCatchClause(t))return Nf(t,e);let n=0;return C.isConditionalExpression(t)&&(n+=1),C.isBinaryExpression(t)&&Df(t)&&(n+=1),e>0&&(C.isFunctionDeclaration(t)||C.isFunctionExpression(t)||C.isArrowFunction(t))?n+Vs(t,e):n+Pf(t,e)}function If(t){return ie(t,0,!1)}function nn(t){return{complexity:Ff(t),cognitiveComplexity:If(t)}}var Qs=g(()=>{"use strict";l()});import E from"typescript";function Ys(t,e){Rf(t,e),Mf(t,e),Lf(t,e),Of(t,e)}function Rf(t,e){if((E.isFunctionDeclaration(t)||E.isVariableDeclaration(t))&&t.name&&E.isIdentifier(t.name)&&Af(t)){let r;if(E.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(E.isArrowFunction(n)||E.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Af(t){if(E.isFunctionDeclaration(t))return E.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&E.isSourceFile(e.parent)}function Mf(t,e){if(!E.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function Lf(t,e){if(!E.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function Of(t,e){if(E.isCallExpression(t)&&_f(t.expression))for(let r of t.arguments)E.isObjectLiteralExpression(r)&&Gf(r,e)}function _f(t){return E.isIdentifier(t)?on.has(t.text):!!(E.isPropertyAccessExpression(t)&&(on.has(t.name.text)||E.isIdentifier(t.expression)&&on.has(t.expression.text)))}function Gf(t,e){for(let r of t.properties){if(!E.isPropertyAssignment(r)||!E.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=E.isArrayLiteralExpression(n)?n.elements.filter(E.isStringLiteral):r.name.text==="tag"&&E.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var on,Xs=g(()=>{"use strict";l();on=new Set(["test","describe","it"])});import Zs from"path";import h from"typescript";function sn(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=w=>{zf(w,a),h.forEachChild(w,c)};c(i);let p=Zf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&em(a,i);let f=i.statements[0],u=f?ti(f):void 0,{complexity:y,cognitiveComplexity:x}=nn(i),b=jf(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...b.length>0?{functions:b}:{},...u!==void 0?{description:u}:{}}}function jf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=nn(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function ei(t,e,r,n){let o={name:t},s=ti(r);s!==void 0&&(o.doc=s);let i=$f(e);i!==void 0&&(o.flags=i);let a=Wf(e,n);return a!==void 0&&(o.signature=a),o}function ti(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function $f(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Wf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function zf(t,e){Bf(t,e),Hf(t,e),Jf(t,e),Kf(t,e),Xf(t,e),Ys(t,e)}function Bf(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||an(n)).length}function Hf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!Uf(t)&&(e.hasTypesOnly=!1)}function Uf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Jf(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:R(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function Kf(t,e){h.isExportDeclaration(t)?Vf(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):an(t)&&Yf(t,e)}function Vf(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))qf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function qf(t,e,r){let n=Qf(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:R(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function Qf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Yf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,ei(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,ei(o,n,t,e.sourceFile))}}}function Xf(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:R(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:R(r.text),type:"require"}))}function Zf(t,e){let r=Zs.basename(t).toLowerCase(),n=Zs.extname(t).toLowerCase();return _e().some(s=>r.includes(s))?"test":Mo(r)?"config":e.imports.some(s=>xr().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Cr()?"barrel":"logic"}function an(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function em(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=rm(o);if(s){let i=nm(o);i&&Et(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&tm(o,o.name.text,n,r)}}function tm(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?Et(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&Et(o.body,`${e}.constructor`,r,n)}function rm(t){if(an(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function nm(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function Et(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>Et(o,e,r,n))}var ri=g(()=>{"use strict";l();de();Qs();q();Xs()});function Tt(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var ni=g(()=>{"use strict";l()});import si from"postcss";import*as om from"postcss-less";function oi(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function im(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function am(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=ii.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...oi(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...oi(o)?{isExternal:!0}:{}}:null}function cm(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";im(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function ai(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=am(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...cm(n.value,e))}),r}function lm(t){return t.replace(/(?<!:)\/\/.*/g,"")}function pm(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=ii.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function Ft(t,e){let r=si.parse(lm(t));return{imports:ai(r,e),root:r}}function fm(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function Nt(t,e){try{let r=sm.parse(t),{exports:n,tags:o}=fm(r);return{imports:ai(r,e),root:r,exports:n,tags:o}}catch{return{imports:pm(t,e),root:si.parse(""),exports:[],tags:[]}}}var sm,ii,cn=g(()=>{"use strict";l();sm=om,ii=new Set(["reference","inline"])});import{parse as mm}from"postcss-scss";function ci(t){return t.startsWith("_")||t.startsWith("-")}function um(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function gm(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function dm(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||ci(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||ci(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Pt(t,e){let r=mm(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=gm(c);if(!p)return;let u={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...um(p)?{isExternal:!0}:{}};f&&(u.symbols=[f]),n.push(u)});let{exports:o,tags:s}=dm(r);return{imports:n,root:r,exports:o,tags:s}}var ln=g(()=>{"use strict";l()});function li(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function pi(t,e){if(e.length===0)return"ui";try{let r=gr("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var fi=g(()=>{"use strict";l()});function Ue(t,e){let r=z(t);if(r==="stylus"){let s=li(e,t);return{imports:s,exports:[],tags:[],category:pi(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Pt(e,t);return{imports:s,exports:a,tags:c,category:Tt(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=Nt(e,t);return{imports:s,exports:a,tags:c,category:Tt(i,s)}}let{imports:n,root:o}=Ft(e,t);return{imports:n,exports:[],tags:[],category:Tt(o,n)}}var mi=g(()=>{"use strict";l();q();ni();cn();ln();fi()});async function ui(t,e){let r=z(t),n=gs(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var gi=g(()=>{"use strict";l();q();ms();ds();ks();ws();Ds();Rs();Ms();Os();$s();Us();Ks();ri();Be();mi();de();q();Be();for(let[t,e]of[["javascript",(r,n)=>sn(r,n,"javascript")],["typescript",(r,n)=>sn(r,n,"typescript")],["css",Ue],["scss",Ue],["less",Ue],["stylus",Ue],["coffeescript",fs],["livescript",As],["lua",Ls],["python",Hs],["go",Cs],["java",Ps],["kotlin",Is],["scala",Js],["groovy",vs],["gherkin",qr],["markdown",js]])Ce(t,e)});import di from"path";function hm(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function yi(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function ym(t,e,r){if(e.isExternal||!e.toPath)return;let n=r.get(e.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(t.path)||n.testedBy.push(t.path)))}function xm(t,e){if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let n=e.get(r.toPath);!n||n===t||(n.documentedBy??=[],n.documentedBy.includes(t.path)||n.documentedBy.push(t.path),n.category==="logic"&&(n.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(n.path)||t.staleFor.push(n.path)))}}function hi(t){return Math.round(t*1e4)/1e4}function bm(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let o=e.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=hi(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=hi(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function pn(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Sm(t,e){let r=e.toPath,n=di.basename(r,di.extname(r)).replace(/\.(test|spec)$/,"");pn(t.tags,n,"import")}function Cm(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)pn(t.tags,r,"import")}function km(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&pn(t.tags,o.name,"comment-marker")}function vm(t,e,r){!e.toPath||e.isExternal||(Sm(t,e),Cm(t,e),km(t,e,r))}function xi(t,e){for(let r of t.values())delete r.testedBy,delete r.documentedBy,delete r.staleFor,r.category==="test"&&(r.tags=r.tags.filter(n=>n.kind!=="import"));for(let r of t.values()){if(bm(r,t),e.size>0&&hm(r,e),r.category==="test")for(let n of r.imports)ym(r,n,t),vm(r,n,t);xm(r,t)}}var bi=g(()=>{"use strict";l()});function fn(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:Ci.has(r),importSymbolsTracked:ki.has(r),callEdgesTracked:Dt.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var Si,Ci,ki,Dt,It=g(()=>{"use strict";l();Si=new Set(["java","kotlin","scala","groovy"]),Ci=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),ki=new Set(["typescript","javascript","python"]),Dt=new Set(["typescript","javascript","go","python","java"])});import Ei from"fs";import Ne from"path";function wm(t,e){let r=t.split(`
|
|
12
|
-
`),
|
|
2
|
+
var ur=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Fu=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Du from"path";import{fileURLToPath as Nu}from"url";var Pu,Ru,m,p=d(()=>{"use strict";Pu=()=>Nu(import.meta.url),Ru=()=>Du.dirname(Pu()),m=Ru()});function $t(t){fr.push(t)}function ii(t){return[...Au,...fr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Wt(t){mr.push(t)}function ut(){return[...Lu,...mr]}function zt(t){dr.push(t)}function gr(){return[...Iu,...dr]}function yr(t){hr=t}function xr(){return hr}function Bt(){fr.length=0,mr.length=0,dr.length=0,hr=ai}var Au,fr,Lu,mr,Iu,dr,ai,hr,_e=d(()=>{"use strict";p();Au=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],fr=[];Lu=[".test.",".spec.","-test.","-spec."],mr=[];Iu=["jest","vitest","playwright","cypress","@testing-library/"],dr=[];ai=.8,hr=ai});function Sr(t){let e=new Set(Ht);for(let n of t?.blocklist??[])e.add(n.toLowerCase());for(let n of t?.allowlist??[])e.delete(n.toLowerCase());br=e}function kr(){br=new Set(Ht)}function Kt(t){if(!li.test(t))return!1;let e=t.toLowerCase();return!ci.has(e)&&!br.has(e)}function ye(t){return Ut.includes(t.kind)&&Kt(t.name)}function Cr(t){let e=new Set,n=[];for(let r of t)!ye(r)||e.has(r.name)||(e.add(r.name),n.push(r.name));return n}var Ut,ci,li,Ht,br,xe=d(()=>{"use strict";p();Ut=["comment-marker","import"],ci=new Set(["test","barrel"]),li=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Ht=new Set(["index","main","common","shared","types","type","constants","const","config","util","utils","helper","helpers","mock","mocks","fixture","fixtures","setup","spec","test","tests","args","props","options","opts","context","ctx","handler","handlers","callback","cb","fn","impl","run","get","set","use","name","value","data","item","result","node","org","linux","darwin","windows","freebsd","openbsd","netbsd","dragonfly","solaris","android","ios","js","wasm","wasip1","plan9","aix","illumos","amd64","arm","arm64","ppc64","ppc64le","mips","mips64","riscv64","s390x","loong64","cgo","gc","gccgo","unix"]),br=new Set(Ht)});import vr from"fs";import pi from"path";function Oe(t,{allowJs:e=!0,isExplicitPath:n=!1}={}){if(n){let r=pi.resolve(t);return vr.existsSync(r)?r.endsWith(".json")?ui(r):e?fi(r):{}:{}}for(let r of Mu){let o=pi.resolve(t,r);if(vr.existsSync(o)){if(r.endsWith(".json"))return ui(o);if(e)return fi(o)}}return{}}function ui(t){return JSON.parse(vr.readFileSync(t,"utf-8"))}function fi(t){let e=ur(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function wr(t){Bt(),kr(),Sr(t.tags);for(let e of t.configMatchers??[])$t(e);for(let e of t.testPatterns??[])Wt(e);for(let e of t.testLibraries??[])zt(e);t.barrelThreshold!==void 0&&yr(t.barrelThreshold)}function F(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var Mu,Er=d(()=>{"use strict";p();_e();xe();Mu=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var ue,be,Tr,Ge,ft,$,Fr,Y=d(()=>{"use strict";p();ue="mokosh-cache",be="duplication-tokens.json",Tr="duplication-result.json",Ge="graph.json",ft="branch-graphs",$=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],Fr=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".java",".kt",".kts",".scala",".sc",".groovy",".gradle",".feature",".md",".mdx"]});import Zx from"fs";import eb from"path";var mi=d(()=>{"use strict";p()});var Jt,di=d(()=>{"use strict";p();Jt={serialize(t){let e=["graph TD"],n=new Set;for(let r of t.nodes.values()){let o=`"${r.path}"`;for(let s of r.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${r.path} -> ${s.toPath}`;if(!n.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),n.add(a)}}}return e.join(`
|
|
3
|
+
`)}}});var gi=d(()=>{"use strict";p();di()});function Ou(t,e){return t.length!==e.length?t.length<e.length:t.join("\0")<e.join("\0")}var je,Vt=d(()=>{"use strict";p();je=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let n=new Set(this.nodes.keys());return e.filter(r=>!n.has(r))}findHighExportUsage(e){let n=[];for(let r of this.nodes.values()){if(r.maxExportUsage===void 0||r.maxExportUsage<e)continue;let o=r.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);n.push({path:r.path,maxExportUsage:r.maxExportUsage,tightestDep:o?.toPath??""})}return n.sort((r,o)=>o.maxExportUsage-r.maxExportUsage)}traversableTargets(e,n){let r=this.nodes.get(e);if(!r)return[];let o=new Set;for(let s of r.imports)!s.toPath||s.isExternal||s.isSamePackage&&!n.has("samePackage")||s.isDocReference&&!n.has("docReference")||o.add(s.toPath);return[...o]}findCycles(e={}){let n=new Set(e.includeKinds??[]),r=[],o=new Set,s=new Set,i=[],a=c=>{o.add(c),s.add(c),i.push(c);for(let l of this.traversableTargets(c,n))if(s.has(l)){let u=i.indexOf(l);r.push([...i.slice(u),l])}else o.has(l)||a(l);s.delete(c),i.pop()};for(let c of this.nodes.keys())o.has(c)||a(c);return e.expandComponents?r:this.collapseByComponent(r,n)}collapseByComponent(e,n){if(e.length<=1)return e;let r=this.componentIds(n),o=new Map,s=new Map;for(let[i,a]of e.entries()){let c=r.get(a[0]);if(c===void 0)continue;s.has(c)||s.set(c,i);let l=o.get(c);(l===void 0||Ou(a,l))&&o.set(c,a)}return[...o.entries()].sort(([i],[a])=>s.get(i)-s.get(a)).map(([,i])=>i)}componentIds(e){let n=new Map,r=new Map,o=new Set,s=[],i=new Map,a=0,c=0;for(let l of this.nodes.keys()){if(n.has(l))continue;let u=[{node:l,targets:this.traversableTargets(l,e),next:0}];for(n.set(l,a),r.set(l,a),a++,s.push(l),o.add(l);u.length>0;){let f=u[u.length-1];if(f.next<f.targets.length){let h=f.targets[f.next++];n.has(h)?o.has(h)&&r.set(f.node,Math.min(r.get(f.node),n.get(h))):(n.set(h,a),r.set(h,a),a++,s.push(h),o.add(h),u.push({node:h,targets:this.traversableTargets(h,e),next:0}))}else{if(r.get(f.node)===n.get(f.node)){let y=[],b;do b=s.pop(),o.delete(b),y.push(b);while(b!==f.node);if(y.length>1){for(let v of y)i.set(v,c);c++}}u.pop();let h=u[u.length-1];h&&r.set(h.node,Math.min(r.get(h.node),r.get(f.node)))}}}return i}}});import hi from"fs";import Gu from"path";function Qt(t,e){let n=t.replace(/^\.\//,"");if(e.nodes.has(n))return n;let r=n.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(r)?r:null}function yi(t,e){if(typeof t=="string")return Qt(t,e);if(t&&typeof t=="object"){let n=t;for(let r of["import","require","default"]){let o=yi(n[r],e);if(o)return o}}return null}function ju(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function $u(t,e){let n=new Set,r=new Set,o=[...e];for(;o.length;){let s=o.shift();if(r.has(s))continue;r.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)n.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let l=t.nodes.get(a.toPath);if(l)for(let u of l.exports)n.add(u.name);o.push(a.toPath)}else for(let l of a.symbols)n.add(l)}}}return n}function Dr(t,e){let n=[],r=Gu.join(e,"package.json");if(hi.existsSync(r))try{let o=JSON.parse(hi.readFileSync(r,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let i of Object.values(o.exports)){let a=yi(i,t);a&&!n.includes(a)&&n.push(a)}else if(typeof o.exports=="string"){let i=Qt(o.exports,t);i&&n.push(i)}let s=typeof o.bin=="string"?[o.bin]:o.bin&&typeof o.bin=="object"&&!Array.isArray(o.bin)?Object.values(o.bin).filter(i=>typeof i=="string"):[];for(let i of s){let a=Qt(i,t);a&&!n.includes(a)&&n.push(a)}if(n.length===0)for(let i of[o.main,o.module].filter(Boolean)){let a=Qt(i,t);a&&!n.includes(a)&&n.push(a)}}catch{}if(n.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){n.push(o);break}}return n.length===0?Bu(t):n}function zu(t){return t.endsWith("_test.go")||/(^|\/)(test|tests|__tests__|testdata)\//.test(t)||/[._-](test|spec)\.[^/]+$/.test(t)}function Bu(t){let e=[...t.nodes.values()],n=i=>e.filter(a=>i(a.type)&&a.category!=="test"&&!zu(a.path)),r=n(i=>i==="python");if(r.length>0){let i=r.filter(a=>a.path.replace(/^.*\//,"")==="__init__.py");if(i.length>0){let a=Math.min(...i.map(c=>c.path.split("/").length));return i.filter(c=>c.path.split("/").length===a).map(c=>c.path).sort()}return r.map(a=>a.path).sort()}let o=n(i=>i==="go");if(o.length>0)return o.map(i=>i.path).sort();let s=n(i=>Wu.has(i));return s.length>0?s.map(i=>i.path).sort():[]}function Uu(t,e){let n=new Set(e);for(let r of e)t.traverse(r,o=>(n.add(o.path),!0),{direction:"outgoing"});return n}function Hu(t,e,n){let r=new Map;for(let o of e){if(n.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=r.get(a.name),l=!!(a.signature||a.doc);(!c||l&&!i)&&r.set(a.name,{file:o,symbol:a})}}return r}function Ku(t,e,n,r){let o=[];for(let s of t){let i=e.get(s),a=r.flatMap(f=>n.nodes.get(f)?.exports??[]).find(f=>f.name===s),c=i?.symbol??a,l=i?.file??r.find(f=>n.nodes.get(f)?.exports.some(h=>h.name===s))??r[0],u={name:s,definedIn:l,kind:ju(c?.signature)};c?.doc&&(u.doc=c.doc),c?.signature&&(u.signature=c.signature),o.push(u)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function Ju(t,e,n){let r=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!n.includes(c)&&!r(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!r(c)),a=s.filter(c=>r(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function Nr(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let l of e)if(!t.nodes.has(l))throw new Error(`Entry point not found in graph: ${l}`);let n=Uu(t,e),r=Hu(t,n,e),o=$u(t,e),s=Ku(o,r,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Ju(t,n,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var Wu,Pr=d(()=>{"use strict";p();Wu=new Set(["java","kotlin","scala","groovy"])});function Rr(t,e){let n=null,r=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(n=s.path);for(let i of s.callEdges??[])i.to===e&&r.push({file:s.path,callerFunction:i.from})}let o=[];if(n){let s=t.nodes.get(n);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:n,callers:r,callees:o}}var Ar=d(()=>{"use strict";p()});import yb from"fs";import bb from"path";function xi(t){let e=[...t.nodes.entries()].sort(([r],[o])=>r.localeCompare(o)).map(([r,o])=>`${r}:${o.mtime}:${o.size}`).join("|"),n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function Lr(t){let e=new Map;for(let n of t.nodes.keys()){let r=[];t.traverse(n,o=>(o.path!==n&&r.push(o.path),!0),{direction:"incoming"}),e.set(n,r)}return{impact:e,graphHash:xi(t)}}function Ir(t,e){return t.impact.get(e)??[]}var Mr=d(()=>{"use strict";p()});var _,$e=d(()=>{"use strict";p();Vt();_=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let n=new Map;for(let r of e.nodes)n.set(r.path,r);return new t(n)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let n of this.nodes.values())for(let r of n.imports)if(r.toPath){let o=e.get(r.toPath)||[];o.push(n.path),e.set(r.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,n,r,o){let s=new Set,i=r.maxDepth??1/0,a=[{path:e,depth:0,parent:null}];for(;a.length>0;){let c=a.pop(),{path:l,depth:u,parent:f}=c;if(u>i||s.has(l))continue;let h=this.nodes.get(l);if(!h||(s.add(l),n(h,u,f)===!1))continue;let y=o(l);for(let b=y.length-1;b>=0;b--)a.push({path:y[b],depth:u+1,parent:l})}}traverse(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,n,r,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let n of this.nodes.values())for(let r of n.callEdges??[]){let o=e.get(r.toFile)??[];o.push(n.path),e.set(r.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,n,r,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let n=[];return this.traverseCalls(e,r=>(r.path!==e&&n.push(r.path),!0),{direction:"incoming",maxDepth:1}),n}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let n=this.nodes.get(e);return n?n.imports.map(r=>this.nodes.get(r.toPath)).filter(r=>r!==void 0):[]}findUnusedFiles(e){return new je(this.nodes).findUnusedFiles(e)}findCycles(e){return new je(this.nodes).findCycles(e)}}});import mt from"fs";import bi from"path";function Yt(t){return bi.join(t,ue,ft)}function Si(t,e){return bi.join(Yt(t),`${e}.json`)}function ki(t,e){let n=Si(t,e);if(!mt.existsSync(n))return null;try{let r=mt.readFileSync(n,"utf-8");return _.deserialize(JSON.parse(r))}catch{return null}}function Ci(t,e,n){let r=Yt(t);mt.existsSync(r)||mt.mkdirSync(r,{recursive:!0}),mt.writeFileSync(Si(t,e),JSON.stringify(n.serialize()))}var vi=d(()=>{"use strict";p();Y();$e()});import{execFileSync as _r}from"child_process";function Ti(t,e){let n="",r=0;for(let o of t.split(`
|
|
4
|
+
`)){if(o.startsWith("\0")){let[,c,l]=o.slice(1).split(" ");n=c??"",r=l?Number(l)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,n,r)}}function Fi(t){let e=new Map;try{let n=_r("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${wi}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Ei});Ti(n,(r,o,s)=>{let i=e.get(r);if(i){i.commitCount90d+=1;return}e.set(r,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let n=_r("git",["-C",t,"log","--name-status","-M",`--format=${wi}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Ei});Ti(n,(r,o,s)=>{e.has(r)||e.set(r,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var Xt,wi,Ei,Or=d(()=>{"use strict";p();Xt=class{getChangedFiles(e,n){try{let o=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...n?[["diff","--name-only","--end-of-options",`${n}...HEAD`]]:[]].flatMap(s=>{try{return _r("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
+
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(r){return console.error("Error getting git diff:",r),[]}}},wi="%x00%H%x09%ae%x09%at",Ei=256*1024*1024});var dt,Gr=d(()=>{"use strict";p();dt=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});import Zt from"fs";import Vu from"path";import{load as Di}from"js-yaml";function Ni(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Qu(t){return t.replace(/:$/,"").split(",").map(e=>{let n=e.trim();return n.startsWith('"')&&(n=n.slice(1)),n.endsWith('"')&&(n=n.slice(0,-1)),Ni(n)}).filter(Boolean)}function Yu(t,e){let n=t.startsWith("/")?t.slice(1):t,r=n.lastIndexOf("@");return r>0?{name:n.substring(0,r),version:e||n.substring(r+1)}:{name:n,version:e}}function Xu(t){try{let e=Di(t),n={dependencies:{}};for(let[r,o]of Object.entries(e))if(!(r==="__metadata"||!o?.version))for(let s of r.split(", ")){let i=Ni(s);i&&(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return n}catch{return null}}function Zu(t){let e={dependencies:{}};for(let n of t.split(/\n\n+/)){let r=n.split(`
|
|
6
|
+
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(r.length<2)continue;let o=r[0];if(!o||o.startsWith(" "))continue;let s=Qu(o);if(s.length===0)continue;let a=r.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Pi(t){let e=Zt.readFileSync(t,"utf-8"),n=JSON.parse(e),r={dependencies:{}};if(n.packages)for(let[o,s]of Object.entries(n.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies))r.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return r}function Ri(t){let e=Zt.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let n=Xu(e);if(n!==null)return n}return Zu(e)}function Ai(t){let e=Zt.readFileSync(t,"utf-8"),n={dependencies:{}};try{let r=Di(e);if(r.packages)for(let[o,s]of Object.entries(r.packages)){let{name:i,version:a}=Yu(o,s.version);i&&(n.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies)){if(n.dependencies[o])continue;let i=typeof s=="string"?s:s.version;n.dependencies[o]={version:i||""}}}catch{}return n}function jr(t){for(let e of dt){let n=Vu.join(t,e);if(Zt.existsSync(n))return qu[e](n)}return null}var qu,$r=d(()=>{"use strict";p();Gr();qu={"package-lock.json":Pi,"yarn.lock":Ri,"pnpm-lock.yaml":Ai}});function Li(t){let e=t.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1):e}function ef(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=Li(e).split(":");return a.length>=3&&a[0]&&a[2]?{group:a[0],version:a[2]}:null}if(!e.startsWith("{"))return null;let n=e.match(/module\s*=\s*["']([^"']+)["']/),r=e.match(/group\s*=\s*["']([^"']+)["']/),o=n?n[1].split(":")[0]:r?.[1];if(!o)return null;let s=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:o,...i?.[1]!==void 0&&{version:i[1]},...s?.[1]!==void 0&&{versionRef:s[1]}}}function Wr(t){let e=t.split(/\r?\n/).map(s=>s.replace(/#.*$/,"").trim()),n={},r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="versions"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=s.slice(0,a).trim(),l=Li(s.slice(a+1));c&&l&&(n[c]=l)}let o={};r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="libraries"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=ef(s.slice(a+1));if(!c)continue;let l=c.versionRef?n[c.versionRef]:c.version;l&&(o[c.group]=l)}return o}function zr(t){let e={};for(let n of t.split(/\r?\n/)){let r=n.trim();if(!r||r.startsWith("#")||r.startsWith("empty="))continue;let s=r.split("=")[0].split(":");s.length>=3&&s[0]&&s[2]&&(e[s[0]]=s[2])}return e}function Br(t){let e={},n=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let o=n.exec(t);o;o=n.exec(t)){let[,s,,i]=o;s&&i&&/\d/.test(i)&&(e[s]=i)}let r=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let o=r.exec(t);o;o=r.exec(t))o[1]&&o[2]&&/\d/.test(o[2])&&(e[o[1]]=o[2]);return e}var Ur=d(()=>{"use strict";p()});function qt(t){let e={},n=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let r=n.exec(t);r;r=n.exec(t)){let[,o,,s]=r;o&&s&&(e[o]=s)}return e}var Hr=d(()=>{"use strict";p()});import tn from"fs";import en from"path";function gt(t){try{return tn.existsSync(t)?tn.readFileSync(t,"utf-8"):null}catch{return null}}function Kr(t){let e={},n=u=>{for(let[f,h]of Object.entries(u))!e[f]&&h&&(e[f]=h)},r=gt(en.join(t,"gradle","libs.versions.toml"));r&&n(Wr(r));let o=[],s=[],i=[],a=(u,f)=>{let h;try{h=tn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let y of h){let b=en.join(u,y.name);if(y.isDirectory()){f<nf&&!y.name.startsWith(".")&&!tf.has(y.name)&&a(b,f+1);continue}y.isFile()&&(y.name==="gradle.lockfile"?o.push(b):y.name==="build.gradle"||y.name==="build.gradle.kts"?s.push(b):y.name==="build.sbt"&&i.push(b))}};a(t,0);for(let u of o){let f=gt(u);f&&n(zr(f))}for(let u of s){let f=gt(u);f&&n(Br(f))}for(let u of i){let f=gt(u);f&&n(qt(f))}try{let u=en.join(t,"project");for(let f of tn.readdirSync(u,{withFileTypes:!0}))if(f.isFile()&&f.name.endsWith(".scala")){let h=gt(en.join(u,f.name));h&&n(qt(h))}}catch{}let c=Object.keys(e);if(c.length===0)return null;let l={};for(let u of c)l[u]={version:e[u]};return l}var tf,nf,Jr=d(()=>{"use strict";p();Ur();Hr();tf=new Set(["node_modules","build",".gradle","target",".git","dist"]),nf=2});function Ii(t){let e=jr(t),n=Kr(t);return n?{...e??{dependencies:{}},jvmDependencies:n}:e}var Vr=d(()=>{"use strict";p();$r();Jr();Ur();$r();Jr();Hr();Gr()});import Mi from"path";function K(t){switch(Mi.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":case".sc":return"scala";case".groovy":case".gradle":return"groovy";case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function W(t){let e=Mi.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var ne=d(()=>{"use strict";p()});function fe(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function We(t){let e=new Set,n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=n.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=n.exec(t);return e}function ze(t,e){let n=t.toLowerCase();return n.includes(".test.")||n.includes(".spec.")||e.has("test")?"test":"logic"}var nn=d(()=>{"use strict";p()});import rf from"coffeescript";function Oi(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return fe(t.value)}}function Se(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function of(t,e){let n=Oi(e.source);return n?{fromPath:t,toPath:"",rawSpecifier:n,isStyle:W(n),type:"static"}:null}function sf(t,e){let n=e.variable?.base?.value==="require",r=Oi(e.args?.[0]?.base);return!n||!r?null:{fromPath:t,toPath:"",rawSpecifier:r,isStyle:W(r),type:"require"}}function _i(t,e){if(e)return[{name:e}];let n=t.value;if(n?.constructor?.name==="Class"){let o=Se(n.variable);return o?[{name:o}]:[]}if(n?.base?.constructor?.name==="Obj"&&Array.isArray(n.base.properties))return n.base.properties.map(o=>Se(o.variable)??Se(o)).filter(o=>!!o).map(o=>({name:o}));let r=Se(n);return r?[{name:r}]:[]}function af(t){if(Array.isArray(t.specifiers))return t.specifiers.map(n=>n.identifier??n.original?.value).filter(n=>!!n).map(n=>({name:n}));let e=Se(t.variable)??Se(t.variable?.base);return e?[{name:e}]:[]}function cf(t,e,n,r){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=of(t,e);s&&n.push(s)}else if(o==="Call"){let s=sf(t,e);s&&n.push(s)}else if(o==="Assign"){let s=Se(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?r.push(..._i(e,void 0)):s==="exports"&&typeof i=="string"&&r.push(..._i(e,i))}else o==="ExportNamedDeclaration"&&e.clause?r.push(...af(e.clause)):o==="ExportDefaultDeclaration"&&r.push({name:"default"})}function Qr(t,e,n,r){if(!(!e||typeof e!="object")){cf(t,e,n,r);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)Qr(t,i,n,r);else Qr(t,s,n,r)}}}function Gi(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{Qr(t,rf.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var ji=d(()=>{"use strict";p();ne();nn()});function Be(t,e){$i.set(t,e)}function Wi(t){return $i.get(t)}var $i,ht=d(()=>{"use strict";p();$i=new Map});import{AstBuilder as lf,GherkinClassicTokenMatcher as pf,Parser as uf}from"@cucumber/gherkin";import{IdGenerator as ff}from"@cucumber/messages";function Yr(t,e){let n=new Set,r=o=>{for(let s of o)n.add(s.name.startsWith("@")?s.name.slice(1):s.name)};try{let o=new lf(mf),s=new pf,a=new uf(o,s).parse(e);if(a.feature){r(a.feature.tags);for(let c of a.feature.children){if(c.scenario){r(c.scenario.tags);for(let l of c.scenario.examples)r(l.tags)}if(c.rule)for(let l of c.rule.children)l.scenario&&r(l.scenario.tags)}}}catch(o){console.warn(`[GherkinParser] Failed to parse ${t}:`,o)}return{imports:[],exports:[],tags:Array.from(n).map(o=>({name:o,kind:"comment-marker"})),category:"test"}}var mf,zi=d(()=>{"use strict";p();ht();mf=ff.uuid();Be("gherkin",Yr)});function ke(t){let e=[],n=t.firstChild;for(;n;)e.push(n),n=n.nextSibling;return e}function Ce(t,e){let n=1;for(let r=0;r<e&&r<t.length;r++)t[r]===`
|
|
7
|
+
`&&n++;return n}var rn=d(()=>{"use strict";p()});function df(t,e){let n=1;function r(o){switch(o.type.name){case"IfStatement":case"ForStatement":n++;break;case"Case":{o.firstChild?.type.name==="case"&&n++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&n++;break}}let s=o.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),n}function Ui(t,e,n,r){let o=n?1:1+e,s=ke(t),i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Ue(a,i,!1,r));let c=s.find(u=>u.type.name==="Block");c&&(o+=Ue(c,i,!1,r));let l=s.findIndex(u=>u.type.name==="else");if(l>=0){let u=s[l+1];u?.type.name==="IfStatement"?o+=Ui(u,e,!0,r):u&&(o+=1+Ue(u,e+1,!1,r))}return o}function Bi(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Ue(o,e+1,!1,n),o=o.nextSibling;return r}function gf(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Ue(o,e,!1,n),o=o.nextSibling;return r}function hf(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Ue(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return Ui(t,e,n,r);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return Bi(t,e,r);let s=o==="LogicOp"&&hf(t,r)?1:0;return e>0&&o==="FunctionLiteral"?s+Bi(t,e,r):s+gf(t,e,r)}function yf(t,e){return Ue(t,0,!1,e)}function on(t,e){return{complexity:df(t,e),cognitiveComplexity:yf(t,e)}}function Xr(t,e){let r=t.getChild("Parameters")?.getChild("Parameter"),o=r?.getChild("TypeName")??r?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function Hi(t,e){let n=[],r=t.cursor();do if(r.name==="FunctionDecl"){let o=r.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=on(r.node,e);n.push({name:s,line:Ce(e,r.from),complexity:i,cognitiveComplexity:a})}}else if(r.name==="MethodDecl"){let o=r.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Xr(r.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:l}=on(r.node,e);n.push({name:a,line:Ce(e,r.from),complexity:c,cognitiveComplexity:l})}}while(r.next());return n}var Ki=d(()=>{"use strict";p();rn()});import xf from"path";import{parser as bf}from"@lezer/go";function Vi(t,e){let n=[],r=new Map,o=new Set,s=new Set,i=new Map,a=bf.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let k=e.slice(c.from,c.to),E=k.match(Sf);E?.[1]&&o.add(E[1]);let A=k.match(kf);A&&Ji(A[1],s);let G=k.match(Cf);G&&Ji(G[1],s);break}case"ImportSpec":{let k=c.node.getChild("String");if(k){let A=e.slice(k.from,k.to).slice(1,-1);n.push({fromPath:t,toPath:"",rawSpecifier:A,isExternal:!0,isStyle:!1,type:"static"});let G=c.node.getChild("DefName"),N=G?e.slice(G.from,G.to):A.split("/").pop();N&&N!=="_"&&N!=="."&&i.set(N,A)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let k=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(k){let E=e.slice(k.from,k.to);E!=="_"&&/^[A-Z]/.test(E)&&!r.has(E)&&r.set(E,{name:E})}break}}while(c.next());let l=n.some(k=>k.rawSpecifier==="testing"),u=xf.basename(t).endsWith("_test.go")||o.has("test")||l?"test":"logic",f=new Set([...o,...s]),{complexity:h,cognitiveComplexity:y}=on(a.topNode,e),b=Hi(a,e),v=u==="test"?[]:vf(a,e,i);return{imports:n,exports:Array.from(r.values()),tags:Array.from(f).map(k=>({name:k,kind:"comment-marker"})),category:u,rawCallEdges:v,complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{}}}function vf(t,e,n){let r=[];function o(i,a){if(i.type.name==="CallExpr"){let l=i.firstChild;if(l?.type.name==="SelectorExpr"){let u=l.firstChild,f=l.getChild("FieldName");if(u?.type.name==="VariableName"&&f){let h=e.slice(u.from,u.to),y=n.get(h);if(y){let b=e.slice(f.from,f.to);r.push({from:a,to:b,toSpecifier:y})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),l=Xr(s.node,e);o(a,l?`${l}.${c}`:c)}}while(s.next());return r}function Ji(t,e){for(let n of t.split(/[\s,&|!()]+/)){let r=n.trim();r&&r!=="ignore"&&e.add(r)}}var Sf,kf,Cf,Qi=d(()=>{"use strict";p();Ki();Sf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,kf=/^\/\/go:build\s+(.+)$/,Cf=/^\/\/\s*\+build\s+(.+)$/});function qr(t){let e=t.replace(/\.\w+$/,"");return Ff.test(e)}function He(t){let e=new Set;for(let n of t.matchAll(wf))n[1]&&e.add(n[1]);return e}function me(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,n=>n.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,n=>" ".repeat(n.length)),e}function Ke(t){let e=me(t),n=new Set;for(let o of e.matchAll(/@([A-Z]\w*)/g))o[1]&&n.add(o[1]);let r=new Set;for(let o of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))o[1]&&r.add(o[1]);return{annotations:[...n],typeNames:[...r]}}function sn(t){let e=t.split(".").pop();return e&&e!=="*"?e:void 0}function Je(t,e,n=e){let r=sn(n);return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static",symbols:r?[r]:void 0}}function de(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect",isSamePackage:!0}}function X(t,e){let n=[];for(let r of me(t).split(`
|
|
8
|
+
`)){let o=r.trim();if(!o||o.startsWith("@")||o.startsWith("*"))continue;let s=o.match(/^package\s+(?:object\s+)?([\w.]+)/);if(s?.[1]){if(n.push(s[1]),!e)break;continue}if(!(e&&/^import\s/.test(o)))break}return n.length>0?n.join("."):null}function re(t,e,n={}){let r=t.replace(/\\/g,"/"),o=r.split("/").pop()??"";if(o.endsWith(".gradle")||o==="build.gradle.kts"||o==="settings.gradle.kts")return"config";if(Tf.test(r)||e.some(i=>Ef.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let s=n.annotations??[];return s.some(i=>Df.has(i))?"config":s.some(i=>Nf.has(i))||(n.typeNames??[]).some(i=>Rf.some(a=>i.endsWith(a)))?"ui":s.some(i=>Pf.has(i))?"logic":qr(o)?"test":"logic"}var wf,Ef,Zr,Tf,Ff,Df,Nf,Pf,Rf,Ve=d(()=>{"use strict";p();wf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,Ef=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework","org.testng","org.assertj","com.google.truth","org.hamcrest","io.mockk","com.nhaarman.mockitokotlin2"],Zr=["test","androidTest","integrationTest","it"],Tf=new RegExp(`/src/(${Zr.join("|")})/`),Ff=/(?:Test|Tests|Spec|IT|ITCase)$/;Df=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Nf=new Set(["Composable","Preview"]),Pf=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Rf=["Activity","Fragment","ViewModel","Screen","Composable"]});function If(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function Yi(t,e){let n=He(e),o=me(e).split(`
|
|
9
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Af);if(u?.[2]){let h=If(!!u[1],u[2]);h&&s.push(Je(t,h,u[2]));continue}let f=l.match(Lf);f?.[2]&&i.add(f[2])}let a=X(e,!1);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Af,Lf,Xi=d(()=>{"use strict";p();Ve();Af=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Lf=/^(?:@\w+\s+)*(?:public\s+|private\s+|protected\s+|final\s+|abstract\s+|static\s+)*(class|interface|trait|enum|def)\s+([A-Za-z_][A-Za-z0-9_]*)/});function _f(t,e){let n=1;function r(o){let s=o.type.name;if(s==="IfStatement"||s==="CatchClause"||s==="TernaryExpression")n++;else if(Zi.has(s))n++;else if(s==="SwitchLabel")o.firstChild?.type.name==="case"&&n++;else if(s==="LogicOp"){let a=e.slice(o.from,o.to);(a==="&&"||a==="||")&&n++}let i=o.firstChild;for(;i;)r(i),i=i.nextSibling}return r(t),n}function qi(t,e,n,r){let o=n?1:1+e,s=[];for(let u=t.firstChild;u;u=u.nextSibling)s.push(u);let i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Qe(a,i,!1,r));let c=s.find(u=>u.type.name==="Block");c&&(o+=Qe(c,i,!1,r));let l=s.findIndex(u=>u.type.name==="else");if(l>=0){let u=s[l+1];u?.type.name==="IfStatement"?o+=qi(u,e,!0,r):u&&(o+=1+Qe(u,e+1,!1,r))}return o}function eo(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Qe(o,e+1,!1,n),o=o.nextSibling;return r}function Of(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Qe(o,e,!1,n),o=o.nextSibling;return r}function Gf(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Qe(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return qi(t,e,n,r);if(Zi.has(o)||o==="SwitchStatement"||o==="CatchClause"||o==="TernaryExpression")return eo(t,e,r);let s=o==="LogicOp"&&Gf(t,r)?1:0;return e>0&&o==="LambdaExpression"?s+eo(t,e,r):s+Of(t,e,r)}function jf(t,e){return Qe(t,0,!1,e)}function to(t,e){return{complexity:_f(t,e),cognitiveComplexity:jf(t,e)}}function no(t,e){for(let n=t.parent;n;n=n.parent)if(Mf.has(n.type.name)){let r=n.getChild("Definition");if(r)return e.slice(r.from,r.to)}}function ea(t,e){let n=[],r=t.cursor();do if(r.name==="MethodDeclaration"||r.name==="ConstructorDeclaration"){let o=r.node.getChild("Definition");if(o){let s=e.slice(o.from,o.to),i=no(r.node,e),a=i&&r.name==="MethodDeclaration"?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:l}=to(r.node,e);n.push({name:a,line:Ce(e,r.from),complexity:c,cognitiveComplexity:l})}}while(r.next());return n}var Zi,Mf,ta=d(()=>{"use strict";p();rn();Zi=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Mf=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"])});import{parser as $f}from"@lezer/java";function zf(t,e){let n=t.getChild("ScopedIdentifier");if(!n)return null;let r=t.getChild("static")!=null,o=t.getChild("Asterisk")!=null,s=e.slice(n.from,n.to);if(r){if(o)return s?{specifier:s,wildcard:!1}:null;let i=s.split(".").slice(0,-1).join(".");return i?{specifier:i,wildcard:!1,symbol:sn(s)}:null}return o?{specifier:`${s}.*`,wildcard:!0}:{specifier:s,wildcard:!1,symbol:sn(s)}}function Bf(t){let e=new Map;for(let n of t){if(n.type==="side-effect")continue;let r=n.rawSpecifier;if(r.endsWith(".*"))continue;let o=r.split(".").pop();o&&e.set(o,r)}return e}function Uf(t,e){let n=t;if(n.name==="GenericType"&&(n=n.firstChild),!n)return null;if(n.name==="TypeName")return e.slice(n.from,n.to);if(n.name==="ScopedTypeName"){let r=null;for(let o=n.firstChild;o;o=o.nextSibling)o.name==="TypeName"&&(r=o);return r?e.slice(r.from,r.to):null}return null}function Hf(t,e,n){let r=[];function o(i,a){let c=i.type.name;if(c==="MethodInvocation"){let u=i.firstChild;if(u?.type.name==="Identifier"){let f=n.get(e.slice(u.from,u.to)),h=i.getChild("MethodName");f&&h&&r.push({from:a,to:e.slice(h.from,h.to),toSpecifier:f})}}else if(c==="ObjectCreationExpression"){let u=i.getChild("TypeName")??i.getChild("GenericType")??i.getChild("ScopedTypeName"),f=u&&Uf(u,e);if(f){let h=n.get(f);h&&r.push({from:a,to:"new",toSpecifier:h})}}let l=i.firstChild;for(;l;)o(l,a),l=l.nextSibling}let s=t.cursor();do if(s.name==="MethodDeclaration"||s.name==="ConstructorDeclaration"){let i=s.node.getChild("Definition"),a=s.node.getChild("Block")??s.node.getChild("ConstructorBody");if(i&&a){let c=e.slice(i.from,i.to),l=no(s.node,e),u=l&&s.name==="MethodDeclaration"?`${l}.${c}`:c;o(a,u)}}while(s.next());return r}function na(t,e){let n=[],r=new Map,o=new Set,s=new Set,i;try{i=$f.parse(e)}catch{return{imports:[],exports:[],tags:[],category:re(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let b=e.slice(a.from,a.to).match(Wf);b?.[1]&&o.add(b[1]);break}case"MarkerAnnotation":case"Annotation":{let b=a.node.getChild("Identifier");b&&s.add(e.slice(b.from,b.to));break}case"ImportDeclaration":{let b=zf(a.node,e);b&&n.push({fromPath:t,toPath:"",rawSpecifier:b.specifier,isExternal:!0,isStyle:!1,type:"static",symbols:b.symbol?[b.symbol]:void 0});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let b=a.node.getChild("Definition");if(b){let v=e.slice(b.from,b.to);r.has(v)||r.set(v,{name:v})}}break}}while(a.next());let c=X(e,!1);c&&n.push(de(t,c));let l=re(t,n.map(b=>b.rawSpecifier),{typeNames:[...r.keys()],annotations:[...s]}),{complexity:u,cognitiveComplexity:f}=to(i.topNode,e),h=ea(i,e),y=l==="test"?[]:Hf(i,e,Bf(n));return{imports:n,exports:Array.from(r.values()),tags:Array.from(o).map(b=>({name:b,kind:"comment-marker"})),category:l,rawCallEdges:y,complexity:u,cognitiveComplexity:f,...h.length>0?{functions:h}:{}}}var Wf,ra=d(()=>{"use strict";p();ta();Ve();Wf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/});function oa(t,e){let n=He(e),o=me(e).split(`
|
|
10
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Kf);if(u?.[1]){s.push(Je(t,u[1]));continue}let f=l.match(Jf);if(f?.[2]){i.add(f[2]);continue}let h=l.match(Vf);if(h?.[1]){i.add(h[1]);continue}let y=l.match(Qf);y?.[1]&&i.add(y[1])}let a=X(e,!1);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Kf,ro,Jf,Vf,Qf,sa=d(()=>{"use strict";p();Ve();Kf=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,ro="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",Jf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),Vf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Qf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${ro}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import Yf from"livescript";function ve(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Xf(t){if(!t)return[];if(t.constructor?.name==="Class"){let n=ve(t.title);return n?[{name:n}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(n=>ve(n.key)??ve(n.val)).filter(n=>!!n).map(n=>({name:n}));let e=ve(t);return e?[{name:e}]:[]}function Zf(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let n=t.left,r=ve(n.head),s=n.tails?.[0]?.key?.name;if(r==="module"&&s==="exports")return Xf(t.right);if(r==="exports"&&typeof s=="string")return[{name:s}];if(n.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let n=t.right;if(n?.constructor?.name==="Obj"&&Array.isArray(n.items))return n.items.map(r=>ve(r.val)??ve(r.key)).filter(r=>!!r).map(r=>({name:r}))}return[]}function em(t,e){let n=t.constructor?.name||t.type;if(n==="Import"){let r=t.right?.value;if(typeof r=="string"){let o=fe(r);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:W(o),type:"static"}}}if(n==="Chain"&&t.head?.value==="require"){let r=t.tails?.[0];if(r?.constructor?.name==="Call"||r?.type==="Call"){let o=r.args?.[0]?.value;if(typeof o=="string"){let s=fe(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:W(s),type:"require"}}}}return null}function oo(t,e,n){if(!t||typeof t!="object")return[];let r=[],o=em(t,e);o&&r.push(o),n.push(...Zf(t));for(let s in t){if(qf.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)r.push(...oo(a,e,n));else r.push(...oo(i,e,n))}return r}function ia(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{o=oo(Yf.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var qf,aa=d(()=>{"use strict";p();ne();nn();qf=new Set(["first_line","first_column","last_line","last_column","line","column"])});import tm from"luaparse";function nm(t,e){let n=[];function r(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=fe(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=fe(i.raw))}s&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:W(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)r(a);else r(i)}}}return r(t),n}function rm(t){let e=new Set;for(let n of t)n.type==="LocalStatement"&&n.variables.forEach((r,o)=>{n.init[o]?.type==="TableConstructorExpression"&&e.add(r.name)});return e}function om(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let n=e.arguments[0];if(n?.type!=="TableConstructorExpression")return[];let r=[];for(let o of n.fields)o.type==="TableKeyString"&&r.push({name:o.key.name});return r}function sm(t){let e=t.body,n=rm(e),r=om(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&n.has(s.identifier.base.name)&&r.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&r.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&n.has(i.base.name)&&r.push({name:i.identifier.name});let o=new Set;return r.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function ca(t,e){let n=We(e),r=ze(t,n),o=[],s=[];try{let i=tm.parse(e);o=nm(i,t),s=sm(i)}catch{}return{imports:o,exports:s,tags:Array.from(n).map(i=>({name:i,kind:"comment-marker"})),category:r}}var la=d(()=>{"use strict";p();ne();nn()});async function lm(){return pa??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),pa}function pm(t){let e=t.trim();return e.length===0||e.startsWith("#")||im.some(n=>e.startsWith(n))}function um(t,e){let n=t.match(cm);return n?n.map(r=>({fromPath:e,toPath:"",rawSpecifier:r,isStyle:!1,type:"static",isDocReference:!0})):[]}function ua(t,e,n){if(t.type==="link"&&typeof t.url=="string"&&!pm(t.url)&&n.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static",isDocReference:!0}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&n.push(...um(t.value,e)),Array.isArray(t.children))for(let r of t.children)ua(r,e,n)}async function fa(t,e){let r=(await lm()).parse(e),o=[];ua(r,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var im,am,cm,pa,ma=d(()=>{"use strict";p();im=["http://","https://","mailto:","//"],am="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",cm=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${am})\\b`,"g")});function fm(t){let e=1;function n(r){switch(r.type.name){case"IfStatement":{e+=ke(r).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=ke(r).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=r.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),e}function mm(t,e){let n=0,r=ke(t),o=0,s=0;for(;s<r.length;){let i=r[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;n+=a?1:1+e;let c=a?e:e+1,l=r[s+1],u=r[s+2];l&&(n+=oe(l,c)),u&&(n+=oe(u,c)),o++,s+=3}else if(i?.type.name==="else"){n+=1;let a=r[s+1];a&&(n+=oe(a,e+1)),s+=2}else s++}return n}function dm(t,e){let n=0,r=ke(t),o=0;for(;o<r.length;){let s=r[o];if(s?.type.name==="except"){for(n+=1+e,o++;o<r.length&&r[o]?.type.name!=="Body";)n+=oe(r[o],e),o++;o<r.length&&(n+=oe(r[o],e),o++)}else s?.type.name==="Body"&&(n+=oe(s,e)),o++}return n}function da(t,e){let n=1+e,r=t.firstChild;for(;r;)n+=oe(r,e+1),r=r.nextSibling;return n}function gm(t,e){let n=0,r=t.firstChild;for(;r;)n+=oe(r,e),r=r.nextSibling;return n}function oe(t,e){let n=t.type.name;switch(n){case"IfStatement":return mm(t,e);case"TryStatement":return dm(t,e);case"ForStatement":case"WhileStatement":return da(t,e);default:{let r=n==="ConditionalExpression"||n==="and"||n==="or"?1:0;return e>0&&(n==="FunctionDefinition"||n==="LambdaExpression")?r+da(t,e):r+gm(t,e)}}}function hm(t){return oe(t,0)}function so(t){return{complexity:fm(t),cognitiveComplexity:hm(t)}}function ga(t,e){let n=[];function r(i,a){let{complexity:c,cognitiveComplexity:l}=so(i);n.push({name:a,line:Ce(e,i.from),complexity:c,cognitiveComplexity:l})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,l=i.getChild("Body");if(l){let u=l.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let f=u.getChild("VariableName"),h=f?e.slice(f.from,f.to):void 0;h&&r(u,c?`${c}.${h}`:h),o(u)}else s(u);u=u.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&r(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),n}var ha=d(()=>{"use strict";p();rn()});import ym from"path";import{parser as xm}from"@lezer/python";function ya(t,e){let n=[],r=[],o=new Set,s=ym.basename(t).toLowerCase(),i=xm.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let y=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);y?.[1]&&o.add(y[1]);break}case"ImportStatement":{for(let y of Sm(a.node,e,t))n.push(y);break}case"FunctionDefinition":case"ClassDefinition":{let y=a.node.parent;if(y?.name==="Script"||y?.name==="DecoratedStatement"&&y.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&r.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let y=a.node.firstChild;y?.name==="VariableName"&&r.push({name:e.slice(y.from,y.to)})}break}}while(a.next());let c=Tm(s,n,o);c==="test"&&o.add("test");let{complexity:l,cognitiveComplexity:u}=so(i.topNode),f=ga(i,e),h=c==="test"?[]:Em(i,e);return{imports:n,exports:r,tags:Array.from(o).map(y=>({name:y,kind:"comment-marker"})),category:c,rawCallEdges:h,complexity:l,cognitiveComplexity:u,...f.length>0?{functions:f}:{}}}function Sm(t,e,n){let r=t.firstChild;return r?r.name==="from"?km(t,e,n):Cm(t,e,n):[]}function km(t,e,n){let r=t.firstChild;if(!r)return[];let o=r.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(r.to,o.from).trim(),i=vm(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[yt(n,s,i,!0)];let l=a===1?"./":"../".repeat(a-1);return c?[yt(n,l+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[yt(n,l.slice(0,-1),["*"],!1)]:i.map(u=>yt(n,l+u,[u],!1))}function Cm(t,e,n){let r=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),r.push(yt(n,s,["*"],!0))}o=o.nextSibling}return r}function vm(t,e){let n=[],r=t;for(;r;)r.name==="*"?n.push("*"):r.name==="VariableName"&&(n.push(e.slice(r.from,r.to)),r.nextSibling?.name==="as"&&(r=r.nextSibling.nextSibling??r.nextSibling)),r=r.nextSibling;return n}function wm(t,e){let n=new Map,r=t.cursor();do{if(r.name!=="ImportStatement")continue;let s=r.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let l=a.slice(c),u=c<=1?"./":"../".repeat(c-1),f=i.nextSibling;for(;f;){if(f.type.name==="VariableName"){let h=e.slice(f.from,f.to),y=h;if(f.nextSibling?.type.name==="as"){let v=f.nextSibling.nextSibling;v?.type.name==="VariableName"&&(y=e.slice(v.from,v.to),f=v)}let b=c===0?a:l?u+l.replace(/\./g,"/"):u+h;n.set(y,b)}f=f.nextSibling}}while(r.next());return n}function Em(t,e){let n=wm(t,e),r=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let u=a.firstChild,f=e.slice(u.from,u.to),h=n.get(f);h&&r.push({from:c,to:f,toSpecifier:h})}let l=a.firstChild;for(;l;)o(l,c),l=l.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),l=c?e.slice(c.from,c.to):void 0,u=a.getChild("Body");if(u){let f=u.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let h=f.getChild("VariableName"),y=h?e.slice(h.from,h.to):void 0;y&&o(f,l?`${l}.${y}`:y)}else i(f);f=f.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),r}function yt(t,e,n,r){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:r,type:"static",symbols:n.length>0?n:void 0}}function Tm(t,e,n){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":n.has("test")||e.some(r=>bm.has(r.rawSpecifier))?"test":"logic"}var bm,xa=d(()=>{"use strict";p();ha();bm=new Set(["pytest","unittest","nose","hypothesis"])});function Nm(t,e){let n=e.split("=>")[0]?.trim();return n?n==="_"||n==="*"||n==="given"?`${t}.*`:`${t}.${n}`:null}function Pm(t){let e=t.indexOf("{");if(e!==-1){let r=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,r===-1?void 0:r);return o?s.split(",").map(i=>Nm(o,i.trim())).filter(i=>i!=null):[]}let n=[];for(let r of t.split(",")){let o=r.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&n.push(`${s}.*`)}else n.push(o)}return n}function ba(t,e){let n=He(e),o=me(e).split(`
|
|
11
|
+
`),s=[],i=new Set;for(let l of o){let u=l.match(Fm);if(u?.[1]){for(let h of Pm(u[1]))s.push(Je(t,h));continue}let f=l.match(Dm);f?.[2]&&i.add(f[2])}let a=X(e,!0);a&&s.push(de(t,a));let c=Array.from(i,l=>({name:l}));return{imports:s,exports:c,tags:Array.from(n).map(l=>({name:l,kind:"comment-marker"})),category:re(t,s.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ke(e).annotations})}}var Fm,Dm,Sa=d(()=>{"use strict";p();Ve();Fm=/^\s*import\s+(.+?)\s*$/,Dm=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/});import C from"typescript";function Rm(t){let e=1;function n(r){switch(r.kind){case C.SyntaxKind.IfStatement:case C.SyntaxKind.ConditionalExpression:case C.SyntaxKind.ForStatement:case C.SyntaxKind.ForInStatement:case C.SyntaxKind.ForOfStatement:case C.SyntaxKind.WhileStatement:case C.SyntaxKind.DoStatement:case C.SyntaxKind.CatchClause:case C.SyntaxKind.CaseClause:e++;break;case C.SyntaxKind.BinaryExpression:{let o=r.operatorToken.kind;(o===C.SyntaxKind.AmpersandAmpersandToken||o===C.SyntaxKind.BarBarToken||o===C.SyntaxKind.QuestionQuestionToken)&&e++;break}}C.forEachChild(r,n)}return n(t),e}function Ca(t,e,n){let r=n?1:1+e,o=n?e:e+1;return r+=we(t.expression,o,!1),r+=we(t.thenStatement,o,!1),t.elseStatement&&(C.isIfStatement(t.elseStatement)?r+=Ca(t.elseStatement,e,!0):r+=1+we(t.elseStatement,e+1,!1)),r}function ka(t,e){let n=1+e;return C.forEachChild(t,r=>{n+=we(r,e+1,!1)}),n}function Am(t,e){let n=1+e;return C.forEachChild(t,r=>{n+=we(r,e,!1)}),n}function Lm(t,e){let n=0;return C.forEachChild(t,r=>{n+=we(r,e,!1)}),n}function Im(t){let e=t.operatorToken.kind;return e===C.SyntaxKind.AmpersandAmpersandToken||e===C.SyntaxKind.BarBarToken||e===C.SyntaxKind.QuestionQuestionToken}function we(t,e,n){if(C.isIfStatement(t))return Ca(t,e,n);if(C.isForStatement(t)||C.isForInStatement(t)||C.isForOfStatement(t)||C.isWhileStatement(t)||C.isDoStatement(t)||C.isSwitchStatement(t))return ka(t,e);if(C.isCatchClause(t))return Am(t,e);let r=0;return C.isConditionalExpression(t)&&(r+=1),C.isBinaryExpression(t)&&Im(t)&&(r+=1),e>0&&(C.isFunctionDeclaration(t)||C.isFunctionExpression(t)||C.isArrowFunction(t))?r+ka(t,e):r+Lm(t,e)}function Mm(t){return we(t,0,!1)}function io(t){return{complexity:Rm(t),cognitiveComplexity:Mm(t)}}var va=d(()=>{"use strict";p()});import T from"typescript";function wa(t,e){_m(t,e),Gm(t,e),jm(t,e)}function _m(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Om(t)){let n;if(T.isFunctionDeclaration(t))n="function";else{let r=t.initializer;n=r&&(T.isArrowFunction(r)||T.isFunctionExpression(r))?"function":"variable"}e.tags.add({name:t.name.text,kind:n})}}function Om(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function Gm(t,e){if(!T.isSourceFile(t))return;let n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=t.getFullText(),o=n.exec(r);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=n.exec(r)}function jm(t,e){if(!T.isCallExpression(t)||!$m(t.expression))return;let[n]=t.arguments;if(n&&T.isStringLiteral(n))for(let r of n.text.match(/@[\w-]+/g)??[])e.tags.add({name:r.substring(1),kind:"comment-marker"});for(let r of t.arguments)T.isObjectLiteralExpression(r)&&Wm(r,e)}function $m(t){return T.isIdentifier(t)?ao.has(t.text):!!(T.isPropertyAccessExpression(t)&&(ao.has(t.name.text)||T.isIdentifier(t.expression)&&ao.has(t.expression.text)))}function Wm(t,e){for(let n of t.properties){if(!T.isPropertyAssignment(n)||!T.isIdentifier(n.name)||n.name.text!=="tags"&&n.name.text!=="tag")continue;let{initializer:r}=n,o=T.isArrayLiteralExpression(r)?r.elements.filter(T.isStringLiteral):n.name.text==="tag"&&T.isStringLiteral(r)?[r]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var ao,Ea=d(()=>{"use strict";p();ao=new Set(["test","describe","it"])});import Ta from"path";import x from"typescript";function co(t,e,n){let r=[],o=new Map,s=new Set,i=x.createSourceFile(t,e,x.ScriptTarget.Latest,!0,n==="typescript"?x.ScriptKind.TSX:x.ScriptKind.JSX),a={filePath:t,imports:r,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{Hm(v,a),x.forEachChild(v,c)};c(i);let l=nd(t,a);(l==="test"||l==="barrel")&&s.add({name:l,kind:"comment-marker"}),l!=="test"&&rd(a,i);let u=i.statements[0],f=u?Da(u):void 0,{complexity:h,cognitiveComplexity:y}=io(i),b=zm(i);return{imports:r,exports:Array.from(o.values()),tags:Array.from(s),category:l,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{},...f!==void 0?{description:f}:{}}}function zm(t){let e=[],n=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=io(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},r=(o,s)=>{if(x.isFunctionDeclaration(o)&&o.name&&o.body?n(o.name.text,o):x.isVariableDeclaration(o)&&x.isIdentifier(o.name)&&o.initializer&&(x.isArrowFunction(o.initializer)||x.isFunctionExpression(o.initializer))?n(o.name.text,o.initializer):s&&x.isMethodDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.${o.name.text}`,o):s&&x.isConstructorDeclaration(o)&&o.body?n(`${s}.constructor`,o):s&&x.isGetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.get ${o.name.text}`,o):s&&x.isSetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body&&n(`${s}.set ${o.name.text}`,o),x.isClassDeclaration(o)&&o.name){let i=o.name.text;x.forEachChild(o,a=>r(a,i));return}x.forEachChild(o,i=>r(i,s))};return r(t,void 0),e}function Fa(t,e,n,r){let o={name:t},s=Da(n);s!==void 0&&(o.doc=s);let i=Bm(e);i!==void 0&&(o.flags=i);let a=Um(e,r);return a!==void 0&&(o.signature=a),o}function Da(t){let e=x.getJSDocCommentsAndTags(t);for(let n of e)if(x.isJSDoc(n)&&n.comment)return x.getTextOfJSDocComment(n.comment)||void 0}function Bm(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),n=x.getJSDocTags(t).map(r=>r.tagName.text).filter(r=>e.has(r));return n.length>0?n:void 0}function Um(t,e){let n=x.createPrinter({removeComments:!0}),r=o=>n.printNode(x.EmitHint.Unspecified,o,e);if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)){let o=t.parameters.map(r).join(", "),s=t.type?r(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(x.isVariableDeclaration(t)){if(t.type)return r(t.type);if(t.initializer&&(x.isArrowFunction(t.initializer)||x.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(r).join(", "),i=o.type?r(o.type):"unknown";return`(${s}) => ${i}`}return}if(x.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(x.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(x.isTypeAliasDeclaration(t))return r(t.type);if(x.isEnumDeclaration(t))return`enum ${t.name.text}`}function Hm(t,e){Km(t,e),Jm(t,e),Qm(t,e),Ym(t,e),td(t,e),wa(t,e)}function Km(t,e){if(!x.isSourceFile(t))return;let n=t.statements.filter(r=>!x.isEmptyStatement(r));e.totalStatements=n.length,e.exportStatements=n.filter(r=>x.isExportDeclaration(r)||x.isExportAssignment(r)||lo(r)).length}function Jm(t,e){if(x.isJsxElement(t)||x.isJsxSelfClosingElement(t)||x.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)||x.isArrowFunction(t)||x.isClassDeclaration(t)||x.isVariableStatement(t)||x.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}x.isExportDeclaration(t)&&!Vm(t)&&(e.hasTypesOnly=!1)}function Vm(t){return t.isTypeOnly?!0:!t.exportClause||!x.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Qm(t,e){if(!x.isImportDeclaration(t)||!t.moduleSpecifier||!x.isStringLiteral(t.moduleSpecifier))return;let n=[];if(t.importClause&&(t.importClause.name&&n.push("default"),t.importClause.namedBindings))if(x.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)n.push(o.name.text);else x.isNamespaceImport(t.importClause.namedBindings)&&n.push("*");let r=n.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:W(t.moduleSpecifier.text),type:r,symbols:n.length>0?n:void 0})}function Ym(t,e){x.isExportDeclaration(t)?Xm(t,e):x.isExportAssignment(t)?e.exports.set("default",{name:"default"}):lo(t)&&ed(t,e)}function Xm(t,e){if(t.moduleSpecifier&&x.isStringLiteral(t.moduleSpecifier))Zm(t,t.moduleSpecifier.text,e);else if(t.exportClause&&x.isNamedExports(t.exportClause))for(let n of t.exportClause.elements){let r=n.name.text;e.exports.set(r,{name:r})}}function Zm(t,e,n){let r=qm(t),o={fromPath:n.filePath,toPath:"",rawSpecifier:e,isStyle:W(e),type:"re-export"};r.length>0&&(o.symbols=r),n.imports.push(o)}function qm(t){return t.exportClause?x.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ed(t,e){if((x.isFunctionDeclaration(t)||x.isClassDeclaration(t)||x.isInterfaceDeclaration(t)||x.isTypeAliasDeclaration(t)||x.isEnumDeclaration(t))&&t.name){let r=t.name.text;e.exports.set(r,Fa(r,t,t,e.sourceFile));return}if(x.isVariableStatement(t)){for(let r of t.declarationList.declarations)if(x.isIdentifier(r.name)){let o=r.name.text;e.exports.set(o,Fa(o,r,t,e.sourceFile))}}}function td(t,e){if(!x.isCallExpression(t))return;let n=t.arguments[0];!n||!x.isStringLiteral(n)||(t.expression.kind===x.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:W(n.text),type:"dynamic"}):x.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:W(n.text),type:"require"}))}function nd(t,e){let n=Ta.basename(t).toLowerCase(),r=Ta.extname(t).toLowerCase();return ut().some(s=>n.includes(s))?"test":ii(n)?"config":e.imports.some(s=>gr().some(i=>s.rawSpecifier.includes(i)))?"test":r===".tsx"||r===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>xr()?"barrel":"logic"}function lo(t){return x.canHaveModifiers(t)&&x.getModifiers(t)?.some(e=>e.kind===x.SyntaxKind.ExportKeyword)===!0}function rd(t,e){let n=t.rawCallEdges??[];t.rawCallEdges=n;let r=new Map;for(let o of e.statements){if(!x.isImportDeclaration(o)||!x.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&r.set(i.name.text,s),i.namedBindings&&x.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)r.set(a.name.text,s)}if(r.size!==0)for(let o of e.statements){let s=sd(o);if(s){let i=id(o);i&&an(i,s,r,n);continue}x.isClassDeclaration(o)&&o.name&&od(o,o.name.text,r,n)}}function od(t,e,n,r){for(let o of t.members)x.isMethodDeclaration(o)&&o.body&&x.isIdentifier(o.name)?an(o.body,`${e}.${o.name.text}`,n,r):x.isConstructorDeclaration(o)&&o.body&&an(o.body,`${e}.constructor`,n,r)}function sd(t){if(lo(t)){if(x.isFunctionDeclaration(t)&&t.name)return t.name.text;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(x.isIdentifier(e.name)&&e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.name.text}}}function id(t){if(x.isFunctionDeclaration(t))return t.body;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.initializer}}function an(t,e,n,r){if(x.isCallExpression(t)&&x.isIdentifier(t.expression)){let o=t.expression.text,s=n.get(o);s&&!r.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&r.push({from:e,to:o,toSpecifier:s})}x.forEachChild(t,o=>an(o,e,n,r))}var Na=d(()=>{"use strict";p();_e();va();ne();Ea()});function cn(t,e){if(e.length===0)return"ui";let n=!1;return t.walk(r=>{if(r.type==="rule")return n=!0,!1}),n?"ui":"barrel"}var Pa=d(()=>{"use strict";p()});import Aa from"postcss";import*as ad from"postcss-less";function Ra(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ld(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function pd(t,e){let n=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(n){let s=n[1]?.trim()??"",i=n[2]??"";if(!i)return null;let a=La.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Ra(i)?{isExternal:!0}:{}}}let r=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=r?r[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...Ra(o)?{isExternal:!0}:{}}:null}function ud(t,e){let n=[],r=/url\(['"]?([^'")]+)['"]?\)/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";ld(s)&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=r.exec(t)}return n}function Ia(t,e){let n=[];return t.walk(r=>{if(r.type==="atrule"&&r.name==="import"){let o=pd(r.params,e);o&&n.push(o)}r.type==="decl"&&n.push(...ud(r.value,e))}),n}function fd(t){return t.replace(/(?<!:)\/\/.*/g,"")}function md(t,e){let n=[],r=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=La.has(s)?"side-effect":"static";n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=r.exec(t)}return n}function ln(t,e){let n=Aa.parse(fd(t));return{imports:Ia(n,e),root:n}}function dd(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type!=="atrule")continue;let{value:o}=r;if(o===void 0)continue;let s=r.name;s&&(e.push({name:s}),n.push({name:s,kind:"variable"}))}return{exports:e,tags:n}}function pn(t,e){try{let n=cd.parse(t),{exports:r,tags:o}=dd(n);return{imports:Ia(n,e),root:n,exports:r,tags:o}}catch{return{imports:md(t,e),root:Aa.parse(""),exports:[],tags:[]}}}var cd,La,po=d(()=>{"use strict";p();cd=ad,La=new Set(["reference","inline"])});import{parse as gd}from"postcss-scss";function Ma(t){return t.startsWith("_")||t.startsWith("-")}function hd(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function yd(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let n=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:n,alias:o}:{specifier:n}}function xd(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type==="decl"&&r.prop.startsWith("$")){let o=r.prop.slice(1);if(!o||Ma(o))continue;e.push({name:o}),n.push({name:o,kind:"variable"});continue}if(r.type==="atrule"&&(r.name==="mixin"||r.name==="function")){let s=r.params.match(/^([\w-]+)/)?.[1];if(!s||Ma(s))continue;let i=r.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),n.push({name:s,kind:"function"})}}return{exports:e,tags:n}}function un(t,e){let n=gd(t),r=[];n.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:l,alias:u}=yd(c);if(!l)return;let f={fromPath:e,toPath:"",rawSpecifier:l,isStyle:!0,type:a==="forward"?"re-export":"static",...hd(l)?{isExternal:!0}:{}};u&&(f.symbols=[u]),r.push(f)});let{exports:o,tags:s}=xd(n);return{imports:r,root:n,exports:o,tags:s}}var uo=d(()=>{"use strict";p()});function _a(t,e){let n=[],r=/@require\s+['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=r.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return n}function Oa(t,e){if(e.length===0)return"ui";try{let n=ur("stylus");return new n.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Ga=d(()=>{"use strict";p()});function xt(t,e){let n=K(t);if(n==="stylus"){let s=_a(e,t);return{imports:s,exports:[],tags:[],category:Oa(e,s)}}if(n==="scss"){let{imports:s,root:i,exports:a,tags:c}=un(e,t);return{imports:s,exports:a,tags:c,category:cn(i,s)}}if(n==="less"){let{imports:s,root:i,exports:a,tags:c}=pn(e,t);return{imports:s,exports:a,tags:c,category:cn(i,s)}}let{imports:r,root:o}=ln(e,t);return{imports:r,exports:[],tags:[],category:cn(o,r)}}var ja=d(()=>{"use strict";p();ne();Pa();po();uo();Ga()});async function $a(t,e){let n=K(t),r=Wi(n);return r?r(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Wa=d(()=>{"use strict";p();ne();ji();zi();Qi();Xi();ra();sa();aa();la();ma();xa();Sa();Na();ht();ja();_e();ne();ht();for(let[t,e]of[["javascript",(n,r)=>co(n,r,"javascript")],["typescript",(n,r)=>co(n,r,"typescript")],["css",xt],["scss",xt],["less",xt],["stylus",xt],["coffeescript",Gi],["livescript",ia],["lua",ca],["python",ya],["go",Vi],["java",na],["kotlin",oa],["scala",ba],["groovy",Yi],["gherkin",Yr],["markdown",fa]])Be(t,e)});import za from"path";function bd(t,e){let n=e.get(t.path);n!==void 0&&(t.coveragePct=n)}function Ua(t,e){for(let n of t)if(n.isExternal){let r=n.rawSpecifier.startsWith("@")?n.rawSpecifier.split("/").slice(0,2).join("/"):n.rawSpecifier.split("/")[0];r&&!e.some(o=>o.name===r)&&e.push({name:r,kind:"library"})}}function Sd(t,e,n){if(e.isExternal||!e.toPath)return;let r=n.get(e.toPath);r&&(r.category!=="logic"&&r.category!=="barrel"||(r.testedBy??=[],r.testedBy.includes(t.path)||r.testedBy.push(t.path)))}function kd(t,e){if(t.type==="markdown")for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let r=e.get(n.toPath);!r||r===t||(r.documentedBy??=[],r.documentedBy.includes(t.path)||r.documentedBy.push(t.path),r.category==="logic"&&(r.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(r.path)||t.staleFor.push(r.path)))}}function Ba(t){return Math.round(t*1e4)/1e4}function Cd(t,e){let n=[];for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let o=e.get(r.toPath);if(!o||o.exports.length===0)continue;let s;if(r.symbols===void 0){if(r.type==="side-effect")continue;s=1}else r.symbols.includes("*")?s=1:s=r.symbols.length/o.exports.length;r.exportUsageRatio=Ba(Math.min(1,s)),n.push(r.exportUsageRatio)}n.length>0&&(t.avgExportUsage=Ba(n.reduce((r,o)=>r+o,0)/n.length),t.maxExportUsage=Math.max(...n))}function Ha(t,e,n){e&&(t.some(r=>r.name===e&&r.kind===n)||t.push({name:e,kind:n}))}function vd(t,e){let n=e.toPath,r=za.basename(n,za.extname(n)).replace(/\.(test|spec)$/,"");Ha(t.tags,r,"import")}function wd(t,e,n){let r=n.get(e.toPath);if(!(!r||r.category==="test"))for(let o of r.tags)o.kind==="comment-marker"&&Ha(t.tags,o.name,"comment-marker")}function Ed(t,e,n){!e.toPath||e.isExternal||(vd(t,e),wd(t,e,n))}function Ka(t,e){for(let n of t.values())delete n.testedBy,delete n.documentedBy,delete n.staleFor,n.category==="test"&&(n.tags=n.tags.filter(r=>r.kind!=="import"));for(let n of t.values()){if(Cd(n,t),e.size>0&&bd(n,e),n.category==="test")for(let r of n.imports)Sd(n,r,t),Ed(n,r,t);kd(n,t)}}var Ja=d(()=>{"use strict";p()});function P(t,e,n,r,o,s,i,a){return{importResolution:t,exportSymbols:e,importSymbols:n,callEdges:r,complexity:o,category:s,duplication:i,testTags:a}}function fo(t){let e=new Map;for(let n of t.nodes.values())e.set(n.type,(e.get(n.type)??0)+1);return[...e.entries()].map(([n,r])=>({type:n,fileCount:r,exportsTracked:Qa.has(n),importSymbolsTracked:Ya.has(n),callEdgesTracked:fn.has(n),fidelity:Xa[n]})).sort((n,r)=>r.fileCount-n.fileCount)}var Va,Qa,Ya,fn,Xa,mn=d(()=>{"use strict";p();Va=new Set(["java","kotlin","scala","groovy"]),Qa=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),Ya=new Set(["typescript","javascript","python","java","kotlin","scala","groovy"]),fn=new Set(["typescript","javascript","go","python","java"]);Xa={typescript:P("full","full","full","full","full","full","partial","full"),javascript:P("full","full","full","full","full","full","partial","full"),python:P("full","partial","partial","full","full","partial","partial","full"),go:P("full","partial","none","full","full","partial","partial","full"),java:P("partial","partial","partial","partial","full","partial","partial","full"),kotlin:P("partial","partial","partial","none","none","partial","partial","full"),scala:P("partial","partial","partial","none","none","partial","partial","full"),groovy:P("partial","partial","partial","none","none","partial","partial","full"),coffeescript:P("partial","partial","none","none","none","partial","partial","none"),livescript:P("partial","none","none","none","none","partial","partial","none"),lua:P("partial","partial","none","none","none","partial","partial","none"),css:P("full","none","none","none","none","full","full","none"),scss:P("full","partial","none","none","none","full","full","none"),less:P("full","partial","none","none","none","full","full","none"),stylus:P("full","none","none","none","none","full","partial","none"),gherkin:P("none","none","none","none","none","full","partial","full"),markdown:P("partial","none","none","none","none","full","partial","none"),unknown:P("none","none","none","none","none","none","none","none")}});import ec from"fs";import Ye from"path";function Td(t,e){let n=t.split(`
|
|
12
|
+
`),r=null,o=new Map,s=!1;for(let i of n){let a=i.trim();if(a.startsWith("module ")){r=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Za(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Za(a.replace(/^replace\s+/,""),e,o)}return{mod:r,replaces:o}}function Za(t,e,n){let[r,o]=t.split("=>").map(a=>a.trim());if(!r||!o)return;let s=r.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=Ye.isAbsolute(o)?o:Ye.resolve(e,o);n.set(s,i)}function qa(t){let e;try{e=ec.readdirSync(t,{withFileTypes:!0})}catch{return null}let n=e.filter(r=>r.isFile()&&r.name.endsWith(".go")&&!r.name.endsWith("_test.go")).map(r=>({path:Ye.join(t,r.name),isExternal:!1})).sort((r,o)=>r.path.localeCompare(o.path));return n.length>0?n:null}var bt,mo=d(()=>{"use strict";p();bt=class{extensions=[".go"];goModCache=new Map;resolve(e,n,r,o){let{mod:s,replaces:i}=this.readGoMod(r);if(!s)return null;let a=this.applyReplace(n,i,r);if(a!==void 0)return qa(a);if(n!==s&&!n.startsWith(`${s}/`))return null;let c=n.slice(s.length).replace(/^\//,"");return c?qa(Ye.join(r,c)):null}readGoMod(e){let n=this.goModCache.get(e);if(n!==void 0)return n;let r={mod:null,replaces:new Map};try{let o=ec.readFileSync(Ye.join(e,"go.mod"),"utf-8"),s=Td(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,r),r}}applyReplace(e,n,r){for(let[o,s]of n){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return Ye.join(s,i)}}}}});import dn from"fs";import gn from"path";function rc(t){let e=t.replace(/\\/g,"/"),n=e.match(/^(.*)\/src\/([^/]+)(?:\/|$)/);if(!n?.[1]||!n[2]){let s=e.lastIndexOf("/");return{module:s===-1?e:e.slice(0,s),rootSegment:"",sourceRoot:"unknown"}}let r=n[2],o=r==="main"?"main":Nd.has(r)?r:"unknown";return{module:n[1],rootSegment:r,sourceRoot:o}}function Pd(t,e=[]){let n=new Map,r=(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set([...$,...r,...e]),s=(a,c)=>{let{module:l,rootSegment:u,sourceRoot:f}=rc(c),h=n.get(a);if(!h){n.set(a,[{module:l,rootSegment:u,sourceRoot:f,files:[c]}]);return}let y=h.find(b=>b.module===l&&b.rootSegment===u);y?y.files.push(c):h.push({module:l,rootSegment:u,sourceRoot:f,files:[c]})},i=(a,c)=>{if(c>Dd)return;let l;try{l=dn.readdirSync(a,{withFileTypes:!0})}catch{return}for(let u of l){let f=gn.join(a,u.name);if(u.isDirectory()){!u.name.startsWith(".")&&!o.has(u.name)&&i(f,c+1);continue}if(!u.isFile())continue;let h=gn.extname(u.name);if(!Fd.has(h))continue;let y=Ad(f,h===".scala"||h===".sc");y&&s(y,f)}};i(t,0);for(let a of n.values())for(let c of a)c.files.sort();return n}function Rd(t,e){let n=t.get(e);if(!(!n||n.length===0))return n.length===1?n[0]?.files:n.flatMap(r=>r.files).sort()}function Ad(t,e){let n;try{let r=dn.openSync(t,"r");try{let o=Buffer.alloc(tc),s=dn.readSync(r,o,0,tc,0);n=o.toString("utf8",0,s)}finally{dn.closeSync(r)}}catch{return null}return X(n,e)}function go(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function nc(t){return gn.basename(t,gn.extname(t))}var Fd,Dd,tc,Nd,Ee,ho=d(()=>{"use strict";p();Y();Ve();Fd=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Dd=12,tc=4096,Nd=new Set(Zr);Ee=class{constructor(e=[]){this.extraIgnoreDirs=e}extraIgnoreDirs;extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,n,r,o){let s=this.getIndex(r);if(s.size===0)return null;let i=n.endsWith(".*"),a=(i?n.slice(0,-2):n).split(".").filter(Boolean);if(a.length===0)return null;if(i){let c=s.get(a.join("."));if(!c)return null;let l=rc(e),u=c.filter(y=>y.module===l.module&&y.rootSegment===l.rootSegment),f=l.sourceRoot!=="main"&&l.sourceRoot!=="unknown",h=u.flatMap(y=>f?y.files:y.files.filter(b=>!qr(nc(b))));return go(h)}for(let c=a.length-1;c>=1;c--){let l=Rd(s,a.slice(0,c).join("."));if(!l)continue;let u=a[c],f=l.filter(h=>nc(h)===u);if(f.length>0)return go(f);if(c===a.length-1)return go(l)}return null}getIndex(e){let n=this.indexCache.get(e);if(n)return n;let r=Pd(e,this.extraIgnoreDirs);return this.indexCache.set(e,r),r}}});import Ld from"fs";import yo from"path";var St,xo=d(()=>{"use strict";p();St=class{extensions=[".lua"];resolve(e,n,r,o){let s=n.replace(/\./g,yo.sep),i=[r,yo.join(r,"lib")];for(let a of i){if(!Ld.existsSync(a))continue;let c=o(yo.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Id from"path";var Md,kt,bo=d(()=>{"use strict";p();Y();Md=new Set($),kt=class{extensions=[".md",".mdx"];resolve(e,n,r,o){let s=n.replace(/^\.\//,"").split("/")[0];if(s&&Md.has(s))return null;let i=o(Id.join(r,"_dummy"),`./${n}`);return i?[i]:null}}});import _d from"fs";import So from"path";function oc(t){try{return _d.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ct,ko=d(()=>{"use strict";p();Ct=class{extensions=[".py"];resolve(e,n,r,o){let s=n.replace(/\./g,So.sep),i=So.join(r,`${s}.py`);if(oc(i))return[{path:i,isExternal:!1}];let a=So.join(r,s,"__init__.py");return oc(a)?[{path:a,isExternal:!1}]:null}}});import sc from"path";var Od,vt,Co=d(()=>{"use strict";p();Od=["~","http://","https://","//","data:","sass:"],vt=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,n,r,o){if(Od.some(u=>n.startsWith(u)))return null;let s=o(e,n);if(s)return[s];let i=sc.dirname(n),a=sc.basename(n),c=i==="."?`_${a}`:`${i}/_${a}`,l=o(e,c);return l?[l]:null}}});function hn(t={}){return[new Ct,new St,new bt,t.jvm??new Ee,new vt,new kt]}var vo=d(()=>{"use strict";p();mo();ho();xo();bo();ko();Co();mo();ho();xo();bo();ko();Co()});import yn from"fs";import se from"path";function Gd(t,e){let n=t.constructor?.name??"LangResolver";if(ic.has(n))return;ic.add(n);let r=e instanceof Error?e.message:String(e);process.stderr.write(`
|
|
13
|
+
Warning: ${n}.resolve() threw (${r}); affected imports are left unresolved.
|
|
14
|
+
`)}var ic,ie,xn=d(()=>{"use strict";p();vo();ic=new Set;ie=class{constructor(e,n={}){this.rootDir=e;this.workspaceMap=n.workspaceMap??new Map,this.tsconfigSearchPaths=n.tsconfigSearchPaths??[e],this.pathAliases=n.pathAliases,this.langResolvers=n.langResolvers??hn()}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let n=0;n<this.langResolvers.length;n++)if(this.langResolvers[n]?.extensions.some(r=>e.endsWith(r)))return String(n);return"none"}cacheKey(e,n){return`${se.dirname(e)}\0${this.langBucketFor(e)}\0${n}`}resolveAll(e,n){let r=this.cacheKey(e,n),o=this.resolutionCache.get(r);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,n);return this.resolutionCache.set(r,s.length>0?s:null),s}resolveAllUncached(e,n){let r=this.resolvePathAlias(n);if(r)return[r];if(n.startsWith(".")||n.startsWith("/")){let i=this.resolveLocalPath(e,n);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=null;try{a=i.resolve(e,n,this.rootDir,o)}catch(c){Gd(i,c)}if(a)return a}let s=this.resolveWorkspaceImport(n);return s?[s]:[{path:n,isExternal:!0}]}resolve(e,n){return this.resolveAll(e,n)[0]??null}resolveLocalPath(e,n){let r=se.dirname(e),o=n.startsWith("/")?n:se.resolve(r,n),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let l of[".ts",".tsx"]){let u=this.tryExtensions(c,l,s);if(u)return u}}for(let c of i){let l=this.tryExtensions(o,c,s);if(l)return l}return s?{path:o,isExternal:!0}:null}tryExtensions(e,n,r){let o=e+n;if(this.isFile(o))return{path:o,isExternal:r};let s=se.join(e,`index${n}`);if(this.isFile(s))return{path:s,isExternal:r};if(n===".py"){let i=se.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:r}}return null}isFile(e){try{return yn.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let n in this.pathAliases){let r=this.matchAliasPattern(n,e),o=this.pathAliases[n];if(r&&o){let s=this.tryAliasSubstitutions(o,r[1]||"");if(s)return s}}for(let n of this.tsconfigSearchPaths){let r=se.join(n,"tsconfig.json");if(yn.existsSync(r))try{let s=JSON.parse(yn.readFileSync(r,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",n);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,n){let r=this.aliasRegexCache.get(e);if(!r){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");r=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,r)}return n.match(r)}tryAliasSubstitutions(e,n,r=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",n),a=se.resolve(r,i);for(let c of o){let l=this.tryExtensions(a,c,!1);if(l)return l}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[n,r]of this.workspaceMap){if(e!==n&&!e.startsWith(`${n}/`))continue;let o=e.slice(n.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:n};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=se.join(r,a);try{if(yn.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:r}}let i=this.resolveLocalPath(se.join(r,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import wt from"fs";import O from"path";import jd from"piscina";function Bd(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function Ud(t,e){if(t.length===0)return e;let n=t.map(i=>O.dirname(i).split(O.sep)),r=n[0]??[];for(let i of n.slice(1)){let a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;r=r.slice(0,a)}let o=r.join(O.sep)||O.sep,s=O.relative(e,o);return s.startsWith("..")||O.isAbsolute(s)?e:o}var $d,Wd,zd,Te,wo=d(()=>{"use strict";p();Or();_e();Vr();Wa();Ja();mn();$e();xn();$d=["tests","test","__tests__","specs","spec"],Wd=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],zd=600;Te=class{constructor(e,n=null,r,o,s=!1,i=new Map,a=!0,c=[],l=null){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.docFiles=l;this.previousGraph=n,this.walkIgnoreDirs=new Set([...Wd,...c,...Bd()]),this.resolver=r||new ie(e),this.lockFile=Ii(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;docFiles;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;walkIgnoreDirs;async build(e){let n=e.map(r=>O.isAbsolute(r)?r:O.resolve(this.rootDir,r));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=Fi(this.rootDir));try{for(let r of n)this.enqueue(r);return await this.drain(),await this.processTestFiles(Ud(n,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
13
15
|
Done. Total processed: ${this.visited.size} nodes.
|
|
14
|
-
`),
|
|
16
|
+
`),Ka(this.graph.nodes,this.coverageMap),new _(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},n=e.minFiles??zd;if(!(n>0&&!this.hasAtLeastFiles(this.rootDir,n))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
|
|
15
17
|
Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
|
|
16
|
-
`);try{let
|
|
17
|
-
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${
|
|
18
|
-
`),this.pool=null}}}hasAtLeastFiles(e,
|
|
19
|
-
Warning: failed to parse ${
|
|
20
|
-
`),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ui(e,r)}makeStubNode(e,r,n){return{path:r,type:z(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:P.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:u,cognitiveComplexity:y,functions:x}=o;return{path:r,type:z(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...u!==void 0?{complexity:u}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:P.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),n.push(c)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=this.lockFile.jvmDependencies;if(r&&Si.has(z(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(r))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=r[i]?.version);return}let n=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=n?this.lockFile.dependencies[n]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function Oi(t){return Wm.has(t)?"style":"code"}var Wm,_i=g(()=>{"use strict";l();Wm=new Set(["css","scss","less","stylus"])});function zm(t){return t.trim().replace(/\s+/g," ")}function Bm(t){try{return t.fileType==="scss"?Pt(t.source,t.file).root:t.fileType==="less"?Nt(t.source,t.file).root:t.fileType==="css"?Ft(t.source,t.file).root:void 0}catch{return}}function Hm(t){let e=Bm(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${zm(f.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function Gi(t,e,r=2){let n=new Map;for(let s of t)for(let i of Hm(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let f={file:c.file,startLine:c.startLine,endLine:c.endLine},u={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,u],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var ji=g(()=>{"use strict";l();cn();ln()});function $i(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>n[n.length-1].lcpLength&&n.push({lcpLength:t[o],low:s})}for(;n.length>1;){let o=n.pop();r.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return r}var Wi=g(()=>{"use strict";l()});function zi(t,e,r){let n=0;for(let o=e;o<e+r;o++)Um.has(t[o].text)&&n++;return n/r}var Um,Bi=g(()=>{"use strict";l();Um=new Set(["{","}",":",",","[","]"])});function Hi(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(s,i)=>i),n=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?n[a+s]:-1;r.sort((a,c)=>{let p=n[a]-n[c];return p!==0?p:i(a)-i(c)}),o[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],p=r[a],f=n[c]===n[p],u=i(c)===i(p);o[p]=o[c]+(f&&u?0:1)}if([n,o]=[o,n],n[r[e-1]]===e-1)break}return r}function Ui(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let o=new Array(r);for(let i=0;i<r;i++)o[e[i]]=i;let s=0;for(let i=0;i<r;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<r&&c+s<r&&t[i+s]===t[c+s];)s++;n[a]=s,s>0&&s--}else s=0}return n}var Ji=g(()=>{"use strict";l()});function Ki(t,e,r,n=.5){let o=[],s=[],i=new Map;for(let{file:u,tokens:y}of t)if(y.length!==0){i.set(u,y);for(let x=0;x<y.length;x++)o.push(y[x].text),s.push({file:u,localIndex:x});o.push(` ${u}`),s.push({file:u,localIndex:-1})}if(o.length===0)return[];let a=Hi(o),c=Ui(o,a),p=$i(c),f=[];for(let u of p){let y=Jm(u,a,s,i,e,r,n);y&&f.push(y)}return f.sort((u,y)=>y.lines-u.lines)}function Jm(t,e,r,n,o,s,i){if(t.lcpLength<o)return;let a=[];for(let x=t.low;x<=t.high;x++){let b=r[e[x]];b.localIndex!==-1&&a.push(b)}if(a.length<2||!Km(a,n))return;let c=Vm(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=n.get(p.file);if(zi(f,p.localIndex,t.lcpLength)>i)return;let u=c.map(({file:x,localIndex:b})=>{let w=n.get(x);return{file:x,startLine:w[b].line,endLine:w[b+t.lcpLength-1].line}}),y=Math.min(...u.map(x=>x.endLine-x.startLine+1));if(!(y<s))return{occurrences:u,lines:y,tokens:t.lcpLength}}function Km(t,e){let r=null;for(let{file:n,localIndex:o}of t){if(o===0)return!0;let i=e.get(n)[o-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function Vm(t,e){let r=new Map;for(let{file:o,localIndex:s}of t){let i=r.get(o);i?i.push(s):r.set(o,[s])}let n=[];for(let[o,s]of r){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(n.push({file:o,localIndex:a}),i=a+e)}return n}var Vi=g(()=>{"use strict";l();Wi();Bi();Ji()});function qi(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function Qm(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=qi(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
|
|
21
|
-
`,s),a=i===-1?
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
`);try{let r=O.join(m,"parse-worker.js");this.pool=new jd({filename:r,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(r){process.stderr.write(`
|
|
19
|
+
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${r}
|
|
20
|
+
`),this.pool=null}}}hasAtLeastFiles(e,n){let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=wt.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||o.push(O.join(s,a.name));else if(a.isFile()&&(r++,r>=n))return!0}return r>=n}async processTestFiles(e){let n=ut(),r=s=>n.some(i=>s.name.includes(i));this.walkProject(e,r);let o=e;for(;o!==this.rootDir;){let s=O.dirname(o);if(s===o)break;for(let i of $d){let a=O.join(s,i);try{wt.statSync(a).isDirectory()&&this.walkProject(a,r)}catch{}}o=s}await this.drain()}async processDocFiles(){if(this.docFiles!==null){for(let e of this.docFiles)this.enqueue(e);await this.drain();return}this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,n){let r;try{r=wt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of r){let s=O.join(e,o.name);o.isDirectory()?this.walkIgnoreDirs.has(o.name)||this.walkProject(s,n):o.isFile()&&n(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(n=>this.finishFile(n)))}}async finishFile(e){let n=wt.statSync(e,{throwIfNoEntry:!1});if(!n?.isFile())return;let r=O.relative(this.rootDir,e),o=await this.getNode(e,r,n);o.imports=await this.resolveImports(e,o.imports),Ua(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,n,r){let o=this.previousGraph?.nodes.get(n);if(o&&o.mtime===r.mtimeMs&&o.size===r.size)return{...o};let s=await this.tryParse(e,n);if(!s)return this.makeStubNode(e,n,r);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,n,r,s,i);return this.attachGitStats(a,n),a}async tryParse(e,n){let r=wt.readFileSync(e,"utf-8");try{return await this.parseContent(e,r)}catch(o){return process.stderr.write(`
|
|
21
|
+
Warning: failed to parse ${n}: ${o}
|
|
22
|
+
`),null}}parseContent(e,n){return this.pool?this.pool.run({filePath:e,content:n}):$a(e,n)}makeStubNode(e,n,r){return{path:n,type:K(e),category:"other",imports:[],exports:[],tags:[],mtime:r.mtimeMs,size:r.size}}resolveCallEdges(e,n){let r=[];for(let o of n??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&r.push({from:o.from,to:o.to,toFile:O.relative(this.rootDir,s.path)})}catch{}return r}buildNode(e,n,r,o,s){let{imports:i,exports:a,tags:c,category:l,description:u,complexity:f,cognitiveComplexity:h,functions:y}=o;return{path:n,type:K(e),category:l,imports:i,exports:a,tags:c,mtime:r.mtimeMs,size:r.size,...u!==void 0?{description:u}:{},...s.length>0?{callEdges:s}:{},...f!==void 0?{complexity:f}:{},...h!==void 0?{cognitiveComplexity:h}:{},...y!==void 0?{functions:y}:{}}}attachGitStats(e,n){let r=this.gitStatsMap?.get(n);r&&(e.commitCount90d=r.commitCount90d,r.lastAuthor!==void 0&&(e.lastAuthor=r.lastAuthor),r.lastCommitAt!==void 0&&(e.lastCommitAt=r.lastCommitAt))}async resolveImports(e,n){let r=[];for(let o of n){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:O.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),r.push(c)}}return r}attachLockfileVersion(e){if(!this.lockFile)return;let n=this.lockFile.jvmDependencies;if(n&&Va.has(K(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(n))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=n[i]?.version);return}let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=r?this.lockFile.dependencies[r]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function Eo(t,e){return t.startsWith("!")?e!==t.slice(1):e===t}function ac(t){return t.score??t.lines}function bn(t,e){let n=t.occurrences.map(o=>o.file);if(e.path!==void 0){let o=e.path,s=i=>i.includes(o.startsWith("!")?o.slice(1):o);if(o.startsWith("!")?n.some(s):!n.some(s))return!1}if(e.allPaths!==void 0){let o=e.allPaths,s=o.startsWith("!")?o.slice(1):o,i=n.length>0&&n.every(a=>a.includes(s));if(o.startsWith("!")?i:!i)return!1}if(e.family!==void 0&&!Eo(e.family,t.family))return!1;if(e.type!==void 0){let o=e.type.startsWith("!")?e.type.slice(1):e.type,s=n.length>0&&n.every(i=>K(i)===o);if(e.type.startsWith("!")?s:!s)return!1}if(e.kind!==void 0&&!Eo(e.kind,t.kind??"block")||e.defKind!==void 0&&!Eo(e.defKind,t.defKind)||e.minLines!==void 0&&t.lines<e.minLines||e.maxLines!==void 0&&t.lines>e.maxLines)return!1;let r=ac(t);if(e.minScore!==void 0&&r<e.minScore||e.maxScore!==void 0&&r>e.maxScore||e.minOccurrences!==void 0&&t.occurrences.length<e.minOccurrences||e.crossFile!==void 0&&new Set(n).size>=2!==e.crossFile)return!1;if(e.signals!==void 0&&e.signals.length>0){let o=new Set(t.signals??[]),s=e.signals.filter(a=>!a.startsWith("!"));if(e.signals.filter(a=>a.startsWith("!")).map(a=>a.slice(1)).some(a=>o.has(a))||s.length>0&&!s.some(a=>o.has(a)))return!1}return!0}function Sn(t,e){let n=t;if(e.sort){let r=e.sortDir==="asc"?-1:1,o=e.sort==="score"?ac:e.sort==="occurrences"?s=>s.occurrences.length:s=>s.lines;n=[...n].sort((s,i)=>(o(i)-o(s))*r)}return e.limit!==void 0&&(n=n.slice(0,Math.max(0,e.limit))),n}var To=d(()=>{"use strict";p();ne()});function Hd(t,e,n,r,o){let s=t;if(n==="string"){s[e]=o;return}if(n==="bool"){s[e]=o.toLowerCase()==="true";return}let i=Number(o);if(!Number.isFinite(i))throw new Error(`find_duplicates filter: "${r}" expects a number, got "${o}"`);s[e]=i}function Kd(t,e){let n=e.indexOf(":");if(n===-1)throw new Error(`find_duplicates filter: clause "${e}" is not "key:value"`);let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(!lc.has(r))throw new Error(`find_duplicates filter: unknown key "${r}". Known keys: ${[...lc].sort().join(", ")}`);if(r==="signal"||r==="signals"){t.signals=[...t.signals??[],o];return}if(r==="sort"){if(!cc.has(o))throw new Error(`find_duplicates filter: sort must be one of ${[...cc].join(", ")}, got "${o}"`);t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=pc[r];s&&Hd(t,s.field,s.kind,r,o)}function Xe(t){let e={};for(let n of t.split(",")){let r=n.trim();r&&Kd(e,r)}return e}var pc,cc,lc,Fo=d(()=>{"use strict";p();pc={path:{field:"path",kind:"string"},allpaths:{field:"allPaths",kind:"string"},family:{field:"family",kind:"string"},type:{field:"type",kind:"string"},kind:{field:"kind",kind:"string"},defkind:{field:"defKind",kind:"string"},minlines:{field:"minLines",kind:"int"},maxlines:{field:"maxLines",kind:"int"},minscore:{field:"minScore",kind:"int"},maxscore:{field:"maxScore",kind:"int"},minoccurrences:{field:"minOccurrences",kind:"int"},crossfile:{field:"crossFile",kind:"bool"},limit:{field:"limit",kind:"int"}},cc=new Set(["lines","score","occurrences"]),lc=new Set([...Object.keys(pc),"signal","signals","sort","sortdir"])});function Jd(t){let e=[...t].sort((r,o)=>r.start-o.start),n=[];for(let r of e){let o=n.at(-1);o&&r.start<=o.end+1?o.end=Math.max(o.end,r.end):n.push({...r})}return n}function Vd(t,e,n){let r=e.flatMap(a=>a.occurrences).filter(a=>a.file===t).map(a=>({start:a.startLine,end:a.endLine})),o=Jd(r).reduce((a,c)=>a+(c.end-c.start+1),0),s=n?.get(t),i=s!==void 0&&s>0?Math.round(o/s*1e3)/10:void 0;return{file:t,coveredLines:o,totalLines:s,coveragePct:i}}function uc(t,e){let n=new Map;for(let o of t){let s=[...new Set(o.occurrences.map(c=>c.file))].sort(),i=s.join("\0"),a=n.get(i);a?a.groups.push(o):n.set(i,{files:s,groups:[o]})}let r=[];for(let{files:o,groups:s}of n.values()){let i=Math.max(...s.map(a=>a.lines));r.push({files:o,groups:[...s].sort((a,c)=>c.lines-a.lines),matchCount:s.length,longestMatch:i,coverage:o.map(a=>Vd(a,s,e))})}return r.sort((o,s)=>s.longestMatch-o.longestMatch||s.matchCount-o.matchCount)}var fc=d(()=>{"use strict";p()});function mc(t){return Qd[t]??"other"}var Qd,dc=d(()=>{"use strict";p();Qd={css:"style",scss:"style",less:"style",stylus:"style",javascript:"js",typescript:"js",coffeescript:"js",livescript:"js",java:"jvm",kotlin:"jvm",scala:"jvm",groovy:"jvm",python:"python",go:"go",lua:"lua",markdown:"markdown",gherkin:"gherkin"}});import gc from"path";function eg(t,e){let n=t.split(/[\\/]/),r=/^\*\*\/(.+?)\/\*\*$/.exec(e);return r?n.includes(r[1]):e.startsWith("*.")?gc.basename(t).endsWith(e.slice(1)):n.includes(e)}function kn(t,e=[]){if(t.split(/[\\/]/).some(o=>Yd.has(o)))return!0;let r=gc.basename(t);return Xd.some(o=>r.endsWith(o))?!0:e.some(o=>eg(t,o))}function Et(t){let e=t.slice(0,qd).toLowerCase();return Zd.some(n=>e.includes(n))}var Yd,Xd,Zd,qd,Do=d(()=>{"use strict";p();Yd=new Set(["generated","__generated__","__generated","gen","__snapshots__"]),Xd=[".pb.go",".pb.ts",".pb.js","_pb2.py","_pb2.pyi","_pb.dart",".g.dart",".generated.ts",".generated.tsx",".generated.js",".generated.jsx","_generated.go",".gen.go",".gen.ts",".snap"],Zd=["@generated","do not edit","code generated by","autogenerated","auto-generated","this file was automatically generated","this is a generated file","jest snapshot v1"],qd=500});import D from"typescript";function hc(t,e,n){let r=t.tagName.getText(e),o=[];for(let s of t.attributes.properties){if(D.isJsxSpreadAttribute(s))return;let i=s.name.getText(e);if(!s.initializer)o.push(i);else if(D.isStringLiteral(s.initializer))o.push(`${i}=${s.initializer.text}`);else if(D.isJsxExpression(s.initializer))if(!s.initializer.expression)o.push(`${i}={}`);else{let a=n.printNode(D.EmitHint.Unspecified,s.initializer.expression,e);o.push(`${i}=${a}`)}else return}return o.sort(),o.length>0?`${r} ${o.join(" ")}`:r}function tg(t,e,n){if(D.isJsxText(t)){let r=t.text.trim().replace(/\s+/g," ");return r.length===0?"":`T:${r}`}if(D.isJsxExpression(t))return t.expression?`E:${n.printNode(D.EmitHint.Unspecified,t.expression,e)}`:"";if(D.isJsxElement(t)||D.isJsxSelfClosingElement(t)||D.isJsxFragment(t))return yc(t,e,n)}function yc(t,e,n){if(D.isJsxSelfClosingElement(t)){let s=hc(t,e,n);return s===void 0?void 0:`<${s}/>`}let r=[];for(let s of t.children){let i=tg(s,e,n);if(i===void 0)return;r.push(i)}if(D.isJsxFragment(t))return`<>${r.join("")}</>`;let o=hc(t.openingElement,e,n);return o===void 0?void 0:`<${o}>${r.join("")}</>`}function ng(t,e){let n=D.createSourceFile(t.file,t.source,D.ScriptTarget.Latest,!0,D.ScriptKind.TSX),r=D.createPrinter({removeComments:!0}),o=[],s=a=>n.getLineAndCharacterOfPosition(a).line+1,i=a=>{if(D.isJsxElement(a)||D.isJsxSelfClosingElement(a)||D.isJsxFragment(a)){let c=yc(a,n,r);c!==void 0&&c.length>=e&&o.push({file:t.file,startLine:s(a.getStart(n)),endLine:s(a.getEnd()),canonicalShape:c})}D.forEachChild(a,i)};return i(n),o}function rg(t){let e=[...t].sort((o,s)=>s[0].canonicalShape.length-o[0].canonicalShape.length),n=new Map,r=[];for(let o of e){let s=o.filter(i=>!n.get(i.file)?.some(c=>c.start<=i.startLine&&i.endLine<=c.end));if(!(s.length<2)){for(let i of s){let a={start:i.startLine,end:i.endLine},c=n.get(i.file);c?c.push(a):n.set(i.file,[a])}r.push(s)}}return r}function xc(t,e=40){let n=new Map;for(let s of t)for(let i of ng(s,e)){let a=n.get(i.canonicalShape);a?a.push(i):n.set(i.canonicalShape,[i])}let r=[...n.values()].filter(s=>s.length>=2),o=[];for(let s of rg(r)){let i=s[0],a=s.map(c=>({file:c.file,startLine:c.startLine,endLine:c.endLine}));o.push({occurrences:a,lines:Math.max(...s.map(c=>c.endLine-c.startLine+1)),tokens:i.canonicalShape.length,kind:"definition",defKind:"jsxElement"})}return o}var bc=d(()=>{"use strict";p()});import L from"typescript";function og(t){let e=t;for(;L.isAsExpression(e)||L.isSatisfiesExpression(e)||L.isParenthesizedExpression(e);)e=e.expression;return e}function sg(t,e,n){if(L.isPropertyAssignment(n)){if(L.isComputedPropertyName(n.name))return;let r=n.name.getText(e),o=t.printNode(L.EmitHint.Unspecified,n.initializer,e);return`${r}:${o}`}if(L.isShorthandPropertyAssignment(n)){let r=n.name.getText(e);return`${r}:${r}`}}function ig(t){let e=t.filter(n=>n!==void 0);if(!(e.length<2||e.length!==t.length))return[...e].sort().join(";")}function ag(t){let e=L.createSourceFile(t.file,t.source,L.ScriptTarget.Latest,!0,L.ScriptKind.TSX),n=L.createPrinter({removeComments:!0}),r=[],o=i=>e.getLineAndCharacterOfPosition(i).line+1,s=i=>{if(L.isVariableDeclaration(i)&&L.isIdentifier(i.name)&&i.initializer&&L.isVariableDeclarationList(i.parent)&&(i.parent.flags&L.NodeFlags.Const)!==0){let a=og(i.initializer);if(L.isObjectLiteralExpression(a)){let c=ig(a.properties.map(l=>sg(n,e,l)));c!==void 0&&r.push({file:t.file,name:i.name.text,startLine:o(i.getStart(e)),endLine:o(i.getEnd()),memberCount:a.properties.length,canonicalShape:c})}}L.forEachChild(i,s)};return s(e),r}function Sc(t,e=3){let n=new Map;for(let o of t)for(let s of ag(o)){if(s.memberCount<e)continue;let i=n.get(s.canonicalShape);i?i.push(s):n.set(s.canonicalShape,[s])}let r=[];for(let o of n.values()){if(o.length<2)continue;let s=o[0],i=o.map(a=>({file:a.file,startLine:a.startLine,endLine:a.endLine,name:a.name}));r.push({occurrences:i,lines:Math.max(...o.map(a=>a.endLine-a.startLine+1)),tokens:s.memberCount,kind:"definition",defKind:"objectLiteral"})}return r}var kc=d(()=>{"use strict";p()});function Cn(t){return t.trim().replace(/\s+/g," ")}function No(t){try{return t.fileType==="scss"?un(t.source,t.file).root:t.fileType==="less"?pn(t.source,t.file).root:t.fileType==="css"?ln(t.source,t.file).root:void 0}catch{return}}function cg(t){let e=No(t);if(!e)return[];let n=[];return e.walkRules(r=>{let o=r.nodes?.filter(u=>u.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=r.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let l=o.map(u=>`${u.prop.trim().toLowerCase()}:${Cn(u.value)}`).join(";");n.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:l,declCount:o.length})}),n}function Cc(t,e,n=2){let r=new Map;for(let s of t)for(let i of cg(s)){if(i.declCount<n||i.lines<e)continue;let a=r.get(i.signature);a?a.push(i):r.set(i.signature,[i])}let o=[];for(let s of r.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],l=s[a];if(c.file===l.file&&c.startLine===l.startLine&&c.endLine===l.endLine)continue;let u={file:c.file,startLine:c.startLine,endLine:c.endLine},f={file:l.file,startLine:l.startLine,endLine:l.endLine};o.push({occurrences:[u,f],lines:Math.min(c.lines,l.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Po=d(()=>{"use strict";p();po();uo()});function lg(t){let e=No(t);if(!e)return[];let n=[];return e.walkDecls(r=>{let o=r.prop.startsWith("--"),s=t.fileType==="scss"&&r.prop.startsWith("$");if(!o&&!s)return;let i=r.source?.start?.line;i!==void 0&&n.push({file:t.file,line:i,name:r.prop,value:Cn(r.value)})}),t.fileType==="less"&&e.walkAtRules(r=>{let{value:o}=r;if(o===void 0)return;let s=r.source?.start?.line;s!==void 0&&n.push({file:t.file,line:s,name:`@${r.name}`,value:Cn(o)})}),n}function vc(t,e=2){let n=t.flatMap(lg),r=new Map,o=new Map;for(let a of n){let c=r.get(a.value);c?c.push(a):r.set(a.value,[a]);let l=o.get(a.name);l?l.push(a):o.set(a.name,[a])}let s=(a,c)=>({file:a.file,startLine:a.line,endLine:a.line,name:a.name,...c?{value:a.value}:{}}),i=[];for(let a of r.values())a.length<e||i.push({occurrences:a.map(c=>s(c,!1)),lines:1,tokens:1,kind:"definition",defKind:"cssVar"});for(let a of o.values())a.length<e||new Set(a.map(l=>l.value)).size<2||i.push({occurrences:a.map(l=>s(l,!0)),lines:1,tokens:1,kind:"definition",defKind:"cssVar",signals:["value-drift"]});return i}var wc=d(()=>{"use strict";p();Po()});function Ec(t){let e=t.length,n=[],r=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<r[r.length-1].lcpLength;){let i=r.pop();n.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>r[r.length-1].lcpLength&&r.push({lcpLength:t[o],low:s})}for(;r.length>1;){let o=r.pop();n.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return n}var Tc=d(()=>{"use strict";p()});function Fc(t,e,n){let r=t.slice(e,n).replace(/[^\n]/g," ");return t.slice(0,e)+r+t.slice(n)}function ug(t,e){if(!e)return t;let n=t;for(let[r,o]of e.block??[]){let s=0;for(;;){let i=n.indexOf(r,s);if(i===-1)break;let a=n.indexOf(o,i+r.length),c=a===-1?n.length:a+o.length;n=Fc(n,i,c),s=c}}for(let r of e.line??[]){let o=0;for(;;){let s=n.indexOf(r,o);if(s===-1)break;let i=n.indexOf(`
|
|
23
|
+
`,s),a=i===-1?n.length:i;n=Fc(n,s,a),o=a}}return n}function mg(t,e){let n=fg[e];if(!n)return t;let r=t.split(`
|
|
24
|
+
`),o=e==="go",s=!1,i=!1;for(let a=0;a<r.length;a++){let c=r[a],l=()=>{r[a]=c.replace(/[^\r]/g," ")};if(s){l(),c.includes(")")&&(s=!1);continue}if(i){l(),(/}\s*from\s/.test(c)||c.includes("}"))&&(i=!1);continue}n.some(u=>u.test(c))&&(l(),o&&/^\s*import\s+\(/.test(c)&&!c.includes(")")?s=!0:(e==="typescript"||e==="javascript")&&/^\s*import\b/.test(c)&&c.includes("{")&&!c.includes("}")&&(i=!0))}return r.join(`
|
|
25
|
+
`)}function Rc(t){return t==="ID"||t==="NUM"||t==="STR"?!1:Pc.has(t)?!0:t.length===1?hg.has(t):yg.has(t)}function Ac(t,e,n=!0){let r=mg(ug(t,pg[e]),e),o=[],s=1,i=0;Ro.lastIndex=0;let a=Ro.exec(r);for(;a!==null;){for(let u=i;u<a.index;u++)r[u]===`
|
|
26
|
+
`&&s++;i=a.index;let c=a[0],l=c;dg.test(c)&&!Pc.has(c)?l="ID":n&&(Dc.test(c)||gg.test(c))&&(l=Dc.test(c)?"NUM":"STR"),o.push({text:l,line:s});for(let u=i;u<a.index+c.length;u++)r[u]===`
|
|
27
|
+
`&&s++;i=a.index+c.length,a=Ro.exec(r)}return o}var pg,fg,Nc,Ro,dg,Dc,gg,Pc,hg,yg,Ao=d(()=>{"use strict";p();pg={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},java:{line:["//"],block:[["/*","*/"]]},kotlin:{line:["//"],block:[["/*","*/"]]},scala:{line:["//"],block:[["/*","*/"]]},groovy:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};fg={typescript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],javascript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],python:[/^\s*import\s+\S/,/^\s*from\s+\S+\s+import[\s(]/],go:[/^\s*import\s+["(]/],java:[/^\s*import\s+/],kotlin:[/^\s*import\s+/],scala:[/^\s*import\s+/],groovy:[/^\s*import\s+/]};Nc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Ro=new RegExp(`${Nc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),dg=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Dc=/^\d+(?:\.\d+)?$/,gg=/^(".*"|'.*'|`.*`)$/s,Pc=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"]),hg=new Set(["+","-","*","%","&","|","!","^","~","?"]),yg=new Set(Nc)});function Lc(t,e,n){let r=0;for(let o=e;o<e+n;o++)xg.has(t[o].text)&&r++;return r/n}function Ic(t,e,n){let r=0;for(let o=e;o<e+n;o++)Rc(t[o].text)&&r++;return r}var xg,Mc=d(()=>{"use strict";p();Ao();xg=new Set(["{","}",":",",","[","]"])});function _c(t){let e=t.length;if(e===0)return[];let n=Array.from({length:e},(s,i)=>i),r=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)r[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?r[a+s]:-1;n.sort((a,c)=>{let l=r[a]-r[c];return l!==0?l:i(a)-i(c)}),o[n[0]]=0;for(let a=1;a<e;a++){let c=n[a-1],l=n[a],u=r[c]===r[l],f=i(c)===i(l);o[l]=o[c]+(u&&f?0:1)}if([r,o]=[o,r],r[n[e-1]]===e-1)break}return n}function Oc(t,e){let n=t.length,r=new Array(n).fill(0);if(n===0)return r;let o=new Array(n);for(let i=0;i<n;i++)o[e[i]]=i;let s=0;for(let i=0;i<n;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<n&&c+s<n&&t[i+s]===t[c+s];)s++;r[a]=s,s>0&&s--}else s=0}return r}var Gc=d(()=>{"use strict";p()});function jc(t,e,n,r=.5){let o=[],s=[],i=new Map;for(let{file:h,tokens:y}of t)if(y.length!==0){i.set(h,y);for(let b=0;b<y.length;b++)o.push(y[b].text),s.push({file:h,localIndex:b});o.push(` ${h}`),s.push({file:h,localIndex:-1})}if(o.length===0)return[];let a=_c(o),c=Oc(o,a),l=Ec(c),u=[];for(let h of l){let y=bg(h,a,s,i,e,n,r);y&&u.push(y)}return Sg(u,i).sort((h,y)=>y.lines-h.lines)}function bg(t,e,n,r,o,s,i){if(t.lcpLength<o)return;let a=[];for(let h=t.low;h<=t.high;h++){let y=n[e[h]];y.localIndex!==-1&&a.push(y)}if(a.length<2||!kg(a,r))return;let c=Cg(a,t.lcpLength);if(c.length<2)return;let l=c[0],u=r.get(l.file);if(!(Lc(u,l.localIndex,t.lcpLength)>i||Math.min(...c.map(({file:h,localIndex:y})=>{let b=r.get(h),v=b[y].line;return b[y+t.lcpLength-1].line-v+1}))<s))return{occurrences:c,lcpLength:t.lcpLength}}function Sg(t,e){let n=[...t].sort((s,i)=>i.lcpLength-s.lcpLength),r=new Map,o=[];for(let s of n){let i=s.occurrences.filter(({file:f,localIndex:h})=>{let y=h+s.lcpLength;return!r.get(f)?.some(v=>v.start<=h&&y<=v.end)});if(i.length<2)continue;for(let{file:f,localIndex:h}of i){let y={start:h,end:h+s.lcpLength},b=r.get(f);b?b.push(y):r.set(f,[y])}let a=i.map(({file:f,localIndex:h})=>{let y=e.get(f);return{file:f,startLine:y[h].line,endLine:y[h+s.lcpLength-1].line}}),c=Math.min(...a.map(f=>f.endLine-f.startLine+1)),l=i[0],u=Ic(e.get(l.file),l.localIndex,s.lcpLength);o.push({occurrences:a,lines:c,tokens:s.lcpLength,score:u})}return o}function kg(t,e){let n=null;for(let{file:r,localIndex:o}of t){if(o===0)return!0;let i=e.get(r)[o-1].text;if(n===null)n=i;else if(n!==i)return!0}return!1}function Cg(t,e){let n=new Map;for(let{file:o,localIndex:s}of t){let i=n.get(o);i?i.push(s):n.set(o,[s])}let r=[];for(let[o,s]of n){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(r.push({file:o,localIndex:a}),i=a+e)}return r}var $c=d(()=>{"use strict";p();Tc();Mc();Gc()});function Wc(t,e,n,r=.6){let o=t.split(`
|
|
28
|
+
`).slice(Math.max(0,e-1),n),s=0,i=0,a=!1;for(let c of o){if(c.trim().length===0)continue;s++;let l=vg.test(c)||wg.test(c);l&&(a=!0),(l||Eg.test(c))&&i++}return a&&s>0&&i/s>=r}var vg,wg,Eg,zc=d(()=>{"use strict";p();vg=/<\/?\s*(?:svg|path|g|circle|ellipse|rect|line|polygon|polyline|defs|use|symbol|mask|clipPath|linearGradient|radialGradient|stop|pattern|filter|fe[A-Z][A-Za-z]*|marker|foreignObject|tspan|textPath)\b/,wg=/\b(?:viewBox|xmlns(?::xlink)?|xlink:href|fill-rule|clip-rule|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-miterlimit|gradientUnits|gradientTransform|patternUnits|patternTransform|preserveAspectRatio|pathLength|d|points|cx|cy|rx|ry)\s*=/,Eg=/^\s*(?:<\/?[A-Za-z>]|\/?>\s*$|[A-Za-z_$][\w:.$-]*\s*=\s*["'{])/});import Z from"typescript";function Tg(t,e,n){if(!Z.isPropertySignature(n)||!n.type)return;let r=n.name.getText(e),o=n.questionToken?"?":"",s=t.printNode(Z.EmitHint.Unspecified,n.type,e);return`${r}${o}:${s}`}function Fg(t){let e=t.filter(n=>n!==void 0);if(!(e.length<2||e.length!==t.length))return[...e].sort().join(";")}function Dg(t){let e=Z.createSourceFile(t.file,t.source,Z.ScriptTarget.Latest,!0,Z.ScriptKind.TSX),n=Z.createPrinter({removeComments:!0}),r=[],o=i=>e.getLineAndCharacterOfPosition(i).line+1,s=i=>{let a,c,l;if(Z.isInterfaceDeclaration(i)?(a=i.name.text,c="interface",l=i.members):Z.isTypeAliasDeclaration(i)&&Z.isTypeLiteralNode(i.type)&&(a=i.name.text,c="type",l=i.type.members),a&&c&&l){let u=Fg(l.map(f=>Tg(n,e,f)));u!==void 0&&r.push({file:t.file,name:a,defKind:c,startLine:o(i.getStart(e)),endLine:o(i.getEnd()),memberCount:l.length,canonicalShape:u})}Z.forEachChild(i,s)};return s(e),r}function Bc(t,e=2){let n=new Map;for(let o of t)for(let s of Dg(o)){if(s.memberCount<e)continue;let i=n.get(s.canonicalShape);i?i.push(s):n.set(s.canonicalShape,[s])}let r=[];for(let o of n.values()){if(o.length<2)continue;let s=o[0],i=o.map(a=>({file:a.file,startLine:a.startLine,endLine:a.endLine,name:a.name}));r.push({occurrences:i,lines:Math.max(...o.map(a=>a.endLine-a.startLine+1)),tokens:s.memberCount,kind:"definition",defKind:s.defKind})}return r}var Uc=d(()=>{"use strict";p()});import Ng from"crypto";import Tt from"fs";import Pg from"path";function vn(t){let e=[];for(let r of t)e.push(`${r.path}\0${r.mtime}\0${r.size}`);e.sort();let n=Ng.createHash("sha256");for(let r of e)n.update(`${r}
|
|
29
|
+
`);return n.digest("hex")}function wn(t){return JSON.stringify({minLines:t.minLines,ignoreLiterals:t.ignoreLiterals,maxPunctuationRatio:t.maxPunctuationRatio,limit:t.limit,scope:t.scope??null,includeGenerated:t.includeGenerated,includeSameFile:t.includeSameFile,includeSvgMarkup:t.includeSvgMarkup,includeDocs:t.includeDocs,ignoreDirs:[...t.ignoreDirs].sort(),ignoreGlobs:[...t.ignoreGlobs].sort()})}function Rg(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.digest=="string"&&typeof e.paramsKey=="string"&&Array.isArray(e.groups)&&Array.isArray(e.clusters)}function En(t,e,n){try{if(!Tt.existsSync(t))return null;let r=JSON.parse(Tt.readFileSync(t,"utf-8"));return!Rg(r)||r.digest!==e||r.paramsKey!==n?null:{groups:r.groups,clusters:r.clusters}}catch{return null}}function Tn(t,e,n,r,o){try{let s=Pg.dirname(t);Tt.existsSync(s)||Tt.mkdirSync(s,{recursive:!0});let i={digest:e,paramsKey:n,groups:[...r],clusters:[...o]};Tt.writeFileSync(t,JSON.stringify(i))}catch(s){process.stderr.write(`Warning: failed to persist duplication result cache: ${s}
|
|
30
|
+
`)}}var Hc=d(()=>{"use strict";p()});function Lo(t){let e=t.indexOf("/");return e===-1?".":t.slice(0,e)}function Kc(t){let e={};for(let n of t)e[n]=(e[n]??0)+1;return e}function Fn(t){let e={},n=[],r=0;for(let o of t){o.lines>r&&(r=o.lines);for(let s of o.signals??[])n.push(s);for(let s of new Set(o.occurrences.map(i=>Lo(i.file))))e[s]=(e[s]??0)+1}return{matched:t.length,byFamily:Kc(t.map(o=>o.family??"other")),byTopDir:e,bySignal:Kc(n),largestLines:r}}function Dn(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`)}function Nn(t){let e=t.package;return{lines:t.lines,...t.score!==void 0&&{score:t.score},...t.family!==void 0&&{family:t.family},...t.kind!==void 0&&{kind:t.kind},...t.defKind!==void 0&&{defKind:t.defKind},...t.signals!==void 0&&{signals:t.signals},...e!==void 0&&{package:e},occurrences:Dn(t)}}function Pn(t){let e=t.package,n=t.groups[0];return{files:t.files,matchCount:t.matchCount,longestMatch:t.longestMatch,...n!==void 0&&{longestMatchAt:Dn(n)},coverage:t.coverage,...e!==void 0&&{package:e}}}var Jc=d(()=>{"use strict";p()});import Ft from"fs";import Ag from"path";function Lg(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&typeof e.generated=="boolean"&&Array.isArray(e.tokens)}function Ze(t){try{if(!Ft.existsSync(t))return new Map;let e=Ft.readFileSync(t,"utf-8"),n=JSON.parse(e);if(!Array.isArray(n))return new Map;let r=n.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&Lg(o[1]));return new Map(r)}catch{return new Map}}function qe(t,e){let n=Ag.dirname(e);Ft.existsSync(n)||Ft.mkdirSync(n,{recursive:!0}),Ft.writeFileSync(e,JSON.stringify([...t.entries()]))}var Vc=d(()=>{"use strict";p()});import{readFile as Io}from"fs/promises";import tt from"path";import Mg from"piscina";function zg(t){return dt.includes(tt.basename(t))}function Bg(t,e){if(e.length===0)return!1;let n=new Set(e);return t.split(tt.sep).some(r=>n.has(r))}function et(t,e,n){let r=[...t.signals??[]];return new Set(t.occurrences.map(o=>o.file)).size===1&&r.push("same-file"),t.occurrences.some(o=>e.has(o.file))&&r.push("generated"),t.occurrences.some(o=>Gg.test(o.file))&&r.push("test"),t.family==="markdown"&&r.push("docs"),t.occurrences.length>0&&t.occurrences.every(o=>{let s=n.get(o.file);return s!==void 0&&Wc(s,o.startLine,o.endLine)})&&r.push("svg-markup"),r.length>0?{...t,signals:r}:t}function Ug(t){return Math.max(0,...t.groups.map(n=>n.tokens))>=Wg?!0:t.groups.length>=jg&&t.files.length<=$g}function Hg(t,e){if(e==="all")return!0;let n=t.groups.some(r=>r.signals?.includes("test"));return e==="tests"?n&&Ug(t):!n}async function nt(t,e,n={}){let{minLines:r=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=$,includeGenerated:l=!1,includeSameFile:u=!1,includeSvgMarkup:f=!1,includeDocs:h=!1,scope:y="src",minScore:b=0,ignoreGlobs:v=[],parallelTokenizing:k=!0,tokenCache:E,filter:A}=n,G=A?Xe(A):void 0,N=[...t.nodes.values()].filter(V=>V.type!=="unknown"&&!zg(V.path)&&!Bg(V.path,c)),U=new Set,ct=new Map,te=Kg(k,N.length);try{let V=[],ce=[],Ie=new Map;if(await Promise.all(N.map(async S=>{let M=kn(S.path,v);if(M&&!l)return;if(Og.has(S.type)){let Q;try{Q=await Io(tt.join(e,S.path),"utf8")}catch{return}let si=M||Et(Q);if(si&&!l)return;si&&U.add(S.path),ct.set(S.path,Q.split(`
|
|
31
|
+
`).length),V.push({file:S.path,source:Q,fileType:S.type});return}let le=E?.get(S.path),Tu=le&&le.mtime===S.mtime&&le.size===S.size&&le.ignoreLiterals===s,pt,Me,pe;if(Tu)pt=le.tokens,Me=le.generated;else{let Q;try{Q=await Io(tt.join(e,S.path),"utf8")}catch{return}if(Me=M||Et(Q),Me&&!l)return;pt=te?await te.run({source:Q,fileType:S.type,ignoreLiterals:s}):Ac(Q,S.type,s),E?.set(S.path,{mtime:S.mtime,size:S.size,ignoreLiterals:s,generated:Me,tokens:pt}),pe=Q}if(Me&&!l)return;if(Me&&U.add(S.path),ct.set(S.path,pe!==void 0?pe.split(`
|
|
32
|
+
`).length:pt.at(-1)?.line??0),S.type==="typescript"||S.type==="javascript"){if(pe===void 0)try{pe=await Io(tt.join(e,S.path),"utf8")}catch{pe=void 0}pe!==void 0&&ce.push({file:S.path,source:pe})}let ni=mc(S.type),ri={file:S.path,tokens:pt},oi=Ie.get(ni);oi?oi.push(ri):Ie.set(ni,[ri])})),E){let S=new Set(N.map(M=>M.path));for(let M of E.keys())S.has(M)||E.delete(M)}let j=new Map(ce.map(S=>[S.file,S.source])),H=Cc(V,r).map(S=>et(S,U,j));for(let[S,M]of Ie)for(let le of jc(M,o,r,i))H.push(et({...le,family:S},U,j));for(let S of vc(V))H.push(et({...S,family:"style"},U,j));for(let S of Bc(ce))H.push(et({...S,family:"js"},U,j));for(let S of Sc(ce))H.push(et({...S,family:"js"},U,j));for(let S of xc(ce))H.push(et({...S,family:"js"},U,j));let Gt=H.filter(S=>!(!u&&S.signals?.includes("same-file")||!f&&S.signals?.includes("svg-markup")||!h&&S.signals?.includes("docs")||b>0&&(S.kind??"block")==="block"&&(S.score??S.tokens)<b||G&&!bn(S,G))),lt=uc(Gt,ct).filter(S=>Hg(S,y)),jt=new Set(lt.flatMap(S=>S.groups)),he=S=>S.score??S.lines;return{groups:Gt.filter(S=>jt.has(S)).sort((S,M)=>he(M)-he(S)||M.lines-S.lines).slice(0,a),clusters:lt.sort((S,M)=>Math.max(...M.groups.map(he))-Math.max(...S.groups.map(he))||M.longestMatch-S.longestMatch).slice(0,a)}}finally{te&&await te.destroy()}}function Kg(t,e){if(t===!1)return null;let n=typeof t=="object"?t:{},r=n.minFiles??_g;if(e<r)return null;n.maxThreads!==void 0&&n.maxThreads<1&&process.stderr.write(`
|
|
33
|
+
Warning: parallelTokenizing.maxThreads (${n.maxThreads}) must be at least 1; using 1.
|
|
34
|
+
`);try{return new Mg({filename:tt.join(m,"duplication-worker.js"),...n.maxThreads!==void 0?{maxThreads:Math.max(1,n.maxThreads)}:{}})}catch(o){return process.stderr.write(`
|
|
26
35
|
Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
|
|
27
|
-
`),null}}var ou,su,Ot=g(()=>{"use strict";l();G();Kr();_i();ji();Vi();Xi();Zi();ou=20,su=new Set(["css","scss","less"])});var ce,_t=g(()=>{"use strict";l();ce=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function le(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function yn(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function tt(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function xn(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new ce(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let f=a.category==="test"||a.tags.some(u=>u.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function bn(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function Re(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function Sn(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function Cn(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function Z(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function ta(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ae(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ta(t),c=[...t.nodes.values()].filter(p=>p.coveragePct!==void 0&&p.coveragePct<=o&&(!a||(p.commitCount90d??0)>=s)).flatMap(p=>(p.functions??[]).filter(f=>f[r]>=n).map(f=>({file:p.path,name:f.name,line:f.line,complexity:f.complexity,cognitiveComplexity:f.cognitiveComplexity,coveragePct:p.coveragePct,...p.commitCount90d!==void 0&&{commitCount90d:p.commitCount90d}}))).sort((p,f)=>f[r]-p[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Gt=g(()=>{"use strict";l();_t()});import{execFileSync as vn}from"child_process";import kn from"fs";import lu from"os";import pu from"path";function wn(t,e){try{return vn("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error(`Could not resolve git ref "${e}" in ${t}`)}}async function ra(t,e,r){let n=kn.mkdtempSync(pu.join(lu.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));kn.rmdirSync(n);try{return vn("git",["worktree","add","--detach",n,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await r(n)}finally{try{vn("git",["worktree","remove","--force",n],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{kn.rmSync(n,{recursive:!0,force:!0})}}}var na=g(()=>{"use strict";l()});import fu from"path";async function la(t,e,r,n={}){let o=wn(t,e),s=Vo(t,o);if(s)return{sha:o,graph:s};let i=await ra(t,o,async a=>{let c=n.pathAliases?new J(a,{pathAliases:n.pathAliases}):void 0;return new ae(a,null,c,void 0,n.gitStats??!1,new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(r)});return qo(t,o,i),{sha:o,graph:i}}function mu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function uu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function gu(t,e=4){let r=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),n=t.occurrences.length-r.length,o=n>0?`, +${n} more`:"";return`${t.lines}L x${t.occurrences.length}: ${r.join(", ")}${o}`}function du(t,e){let{files:r,staleReferences:n,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],p=[r.added.length&&`${r.added.length} added`,r.changed.length&&`${r.changed.length} changed`,r.removed.length&&`${r.removed.length} removed`].filter(Boolean);c.push(p.length?`Files: ${p.join(", ")}`:"No file changes"),n.length>0&&c.push(`\u26A0 ${pe(n.length,"stale reference")} \u2014 removed export still imported`);let f=s.newHotspots[0];return f?c.push(`+${pe(s.newHotspots.length,"complexity hotspot")} (max ${e} ${f[e]} in ${f.file})`):s.resolvedHotspots.length>0&&c.push(`${pe(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${pe(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${pe(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${pe(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${pe(a.newHotspots.length,"risk hotspot")}`),c}function hu(t){let{staleReferences:e,duplication:r,complexity:n,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":n.newHotspots.length>0||r.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function En(t,e={}){let r=e.metric??"cognitiveComplexity",n=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:p,coverage:f}=t,u=oa(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),y=s.added.length+s.changed.length+s.removed.length,x={base:`${t.base.ref}@${sa(t.base.sha)}`,head:`${t.head.ref}@${sa(t.head.sha)}`,verdict:hu(t),headline:du(t,r),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...y<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(x.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(x.complexity={avgDelta:u,newHotspots:c.newHotspots.slice(0,n).map(b=>mu(b,r)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(x.duplication={newGroups:a.newGroups.slice(0,n).map(b=>gu(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(p.newlyStale.length>0||p.resolved.length>0)&&(x.docDrift={newlyStale:p.newlyStale.slice(0,n).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:p.newlyStale.length,resolvedCount:p.resolved.length}),f&&(f.newHotspots.length>0||f.resolvedHotspots.length>0)&&(x.coverage={avgDelta:oa(f.head.avgCoveragePct-f.base.avgCoveragePct),newHotspots:f.newHotspots.slice(0,n).map(b=>uu(b,r)),newHotspotCount:f.newHotspots.length,resolvedCount:f.resolvedHotspots.length}),x}function yu(t,e){let r=[],n=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){r.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(f=>f.name).sort(),imports:a.imports.map(f=>f.toPath).sort()}),p=JSON.stringify({category:i.category,exports:i.exports.map(f=>f.name).sort(),imports:i.imports.map(f=>f.toPath).sort()});c!==p&&n.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:r,removed:o,changed:n}}function xu(t,e){let r=[];for(let[n,o]of t.nodes){let s=e.nodes.get(n);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let p=[...e.nodes.values()].filter(f=>f.imports.some(u=>u.toPath===n&&u.symbols?.includes(c))).map(f=>f.path);p.length>0&&r.push({file:n,symbol:c,stillReferencedBy:p})}}return r}function jt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function bu(t,e,r,n,o){let s=fu.join(ht(t),`${n}-${te}`),i=Pe(s),[{groups:a},{groups:c}]=await Promise.all([Ie(e,t,{minLines:o,tokenCache:i}),Ie(r,t,{minLines:o})]);De(i,s);let p=new Set(a.map(jt)),f=new Set(c.map(jt));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(u=>!p.has(jt(u))),resolvedGroups:a.filter(u=>!f.has(jt(u)))}}function ia(t){let e=[...t.nodes.values()].map(r=>r.cognitiveComplexity).filter(r=>r!==void 0);return e.length===0?0:e.reduce((r,n)=>r+n,0)/e.length}function Su(t,e,r,n){let o=Re(t,{metric:r,threshold:n,limit:1/0}),s=Re(e,{metric:r,threshold:n,limit:1/0}),i=p=>`${p.file}:${p.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:ia(t)},head:{avgCognitiveComplexity:ia(e)},newHotspots:s.filter(p=>!a.has(i(p))),resolvedHotspots:o.filter(p=>!c.has(i(p)))}}function aa(t){let e=new Set;for(let r of t.nodes.values())if(!(r.type!=="markdown"||!r.staleFor))for(let n of r.staleFor)e.add(`${r.path}::${n}`);return e}function Cu(t,e){let r=aa(t),n=aa(e);return{base:{staleCount:r.size},head:{staleCount:n.size},newlyStale:[...n].filter(o=>!r.has(o)),resolved:[...r].filter(o=>!n.has(o))}}function ca(t){let e=[...t.nodes.values()].map(r=>r.coveragePct).filter(r=>r!==void 0);return e.length===0?0:e.reduce((r,n)=>r+n,0)/e.length}function ku(t,e,r){if(!Z(t)||!Z(e))return null;let n=Ae(t,{maxCoveragePct:r,limit:1/0}).hotspots,o=Ae(e,{maxCoveragePct:r,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(n.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:ca(t)},head:{avgCoveragePct:ca(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:n.filter(c=>!a.has(s(c)))}}async function Tn(t,e,r,n={}){let{sha:o,graph:s}=await la(t,e,n.entryPoints??[],n),i=wn(t,n.headRef??"HEAD"),[a,c]=await Promise.all([bu(t,s,r,o,n.minDuplicateLines),Promise.resolve(ku(s,r,n.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:n.headRef??"HEAD",sha:i},files:yu(s,r),staleReferences:xu(s,r),duplication:a,complexity:Su(s,r,n.complexityMetric,n.complexityThreshold),docDrift:Cu(s,r),coverage:c}}var oa,sa,pe,pa=g(()=>{"use strict";l();G();Qo();dn();Ot();Gt();Lt();na();oa=t=>Math.round(t*100)/100,sa=t=>t.length>8?t.slice(0,8):t;pe=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import $t from"path";function vu(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function wu(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=$t.extname(o),c=$t.basename(o,a),p=c==="index"?$t.basename($t.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function fe(t,e){let r=e?.minOutDegree??5;return wu(t,vu(t),r)}var Wt=g(()=>{"use strict";l()});function Tu(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function Fu(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Nu(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function Pu(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function rt(t,e){let r=e?.detectFn??fe,n=e?.hubComparator??Eu,o=r(t.nodes,e),s=Tu(t,o),i=Fu(t.nodes,o,s,n);return{features:Nu(o,i),unassigned:Pu(t.nodes,o,i)}}var Eu,zt=g(()=>{"use strict";l();Wt();Eu=(t,e)=>t.outDegree-e.outDegree});function fa(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,r=Ru(e);for(let n of Du)if(n.segments?.some(o=>Iu(e,o))||n.basenames?.includes(r))return n.role;return"other"}function Iu(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Ru(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var Du,ma=g(()=>{"use strict";l();Du=[{role:"component",segments:["component","components"]},{role:"controller",segments:["controller","controllers"]},{role:"middleware",segments:["middleware"]},{role:"router",segments:["router","routes","route"]},{role:"store",segments:["store","stores"]},{role:"service",segments:["service","services"]},{role:"handler",segments:["handler","handlers"]},{role:"adapter",segments:["adapter","adapters"]},{role:"plugin",segments:["plugin","plugins"]},{role:"api",segments:["api"]},{role:"cli",segments:["cli","commands"],basenames:["cli"]},{role:"util",segments:["util","utils","helper","helpers"]},{role:"model",segments:["model","models"],basenames:["model"]},{role:"parser",segments:["parser","parsers"],basenames:["parser"]},{role:"builder",basenames:["builder"]},{role:"resolver",basenames:["resolver"]}]});function Fn(t,e){let r=rt(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:fa(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Nn=g(()=>{"use strict";l();zt();ma()});function Pn(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(Dt.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=tt(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var ua=g(()=>{"use strict";l();It();Gt()});function Au(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Mu(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Dn(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!Mu(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:Au(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function In(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var Rn=g(()=>{"use strict";l()});import ga from"fs";import qC from"path";function Bt(t){try{return ga.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ht(t){try{return ga.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var nt=g(()=>{"use strict";l()});import Lu from"fs";import An from"path";function da(t,e=[]){let r;try{r=Lu.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let n of r){let o=An.join(t,n.name);n.isDirectory()?!_u.has(n.name)&&!n.name.startsWith(".")&&da(o,e):n.isFile()&&Ou.has(An.extname(n.name).toLowerCase())&&e.push(o)}return e}function Ut(t,e,r){if(!Bt(e))return null;let n=da(e);return n.length===0?null:{name:r,root:e,relativeRoot:An.relative(t,e),entryPoints:n}}var Ou,_u,Mn=g(()=>{"use strict";l();G();nt();Ou=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),_u=new Set(I)});import ha from"fs";import ya from"path";function Gu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function ju(t){let e=Gu(t),r=new Set;for(let n of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=n[1].replace(/^:/,"").replace(/:$/,"");o&&r.add(o)}return[...r]}var xa,ba=g(()=>{"use strict";l();Mn();xa={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>ya.join(t,s)).find(s=>ha.existsSync(s));if(!e)return null;let r;try{r=ha.readFileSync(e,"utf-8")}catch{return null}let n=ju(r);if(n.length===0)return null;let o=[];for(let s of n){let i=ya.join(t,...s.split(":")),a=Ut(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import ot from"fs";import A from"path";function Ln(t,e){let r=A.join(e,"package.json");if(!ot.existsSync(r))return null;let n={};try{n=JSON.parse(ot.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:A.relative(t,e),entryPoints:$u(e,n)}:null}function $u(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(A.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(A.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(A.join(t,i))}}}e.main&&r.push(A.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(A.join(t,o));let n=r.filter(Ht);return n.length>0?n.slice(0,1):r.slice(0,1)}function Me(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");Wu(t,s,n,r)}return r}function Wu(t,e,r,n){if(!e.includes("*")){zu(t,e,r,n);return}let o=e.split("/");o.includes("**")?Bu(t,o,r,n):Hu(t,o,r,n)}function zu(t,e,r,n){let o=A.join(t,e);if(r.has(o)||!Bt(o))return;r.add(o);let s=Ln(t,o);s&&n.push(s)}function Bu(t,e,r,n){let o=A.join(t,e[0]==="**"?"":e[0]??"");Sa(t,o,r,n)}function Hu(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=A.join(t,...e.slice(0,o)),i;try{i=ot.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=A.join(s,a.name);if(r.has(c))continue;r.add(c);let p=Ln(t,c);p&&n.push(p)}}function Sa(t,e,r,n){let o;try{o=ot.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=A.join(e,s.name);if(ot.existsSync(A.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=Ln(t,i);a&&n.push(a)}else Sa(t,i,r,n)}}var Jt=g(()=>{"use strict";l();nt();nt()});import On from"fs";import Ca from"path";var ka,va=g(()=>{"use strict";l();Jt();ka={type:"npm",detect(t){let e=Ca.join(t,"package.json");if(!On.existsSync(e))return null;let r;try{r=JSON.parse(On.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||On.existsSync(Ca.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:Me(t,n)}}});import Le from"fs";import N from"path";function Ea(t,e,r,n){if(n>4)return[];let o;try{o=Le.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=N.join(e,a);Le.existsSync(N.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...Ea(t,c,r,n+1))}return s}function Uu(t,e,r){let n={};try{n=JSON.parse(Le.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=N.join(e,"package.json");if(Le.existsSync(a))try{let c=JSON.parse(Le.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:N.relative(t,e),entryPoints:Ju(e,n,s,i)}:null}function Ju(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=N.resolve(t,"../..");o.push(N.resolve(a,s)),o.push(N.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(N.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(N.join(t,c))}}if(r&&o.push(N.join(t,r)),e.sourceRoot){let a=N.resolve(t,"../.."),c=N.resolve(a,e.sourceRoot);o.push(N.join(c,"index.ts"),N.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(N.join(t,a));let i=o.filter(Ht);return i.length>0?i.slice(0,1):o.slice(0,1)}var wa,Ta=g(()=>{"use strict";l();nt();wa={type:"nx",detect(t){return Le.existsSync(N.join(t,"nx.json"))?Ea(t,t,new Set,0).map(r=>Uu(t,r,N.join(r,"project.json"))).filter(r=>r!==null):null}}});import Fa from"fs";import Ku from"path";import{load as Vu}from"js-yaml";var Na,Pa=g(()=>{"use strict";l();Jt();Na={type:"pnpm",detect(t){let e=Ku.join(t,"pnpm-workspace.yaml");if(!Fa.existsSync(e))return null;let r=[];try{r=Vu(Fa.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return Me(t,r)}}});import st from"fs";import Kt from"path";function qu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function Qu(t){let e=qu(t),r=new Map;for(let n of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=n[1],i=n[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");r.has(c)||r.set(c,{name:o,dir:c})}return[...r.values()]}var Da,Ia=g(()=>{"use strict";l();Mn();Da={type:"sbt",detect(t){let e=Kt.join(t,"build.sbt"),r=Kt.join(t,"project");if(!st.existsSync(e)||!st.existsSync(r))return null;let n=[];try{n.push(st.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of st.readdirSync(r))a.endsWith(".scala")&&n.push(st.readFileSync(Kt.join(r,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of n)for(let c of Qu(a))o.has(c.dir)||(o.add(c.dir),s.push(c));if(s.length===0)return null;let i=[];for(let a of s){let c=Kt.join(t,...a.dir.split("/")),p=Ut(t,c,a.name);p&&i.push(p)}return i.length>0?i:null}}});import Yu from"fs";import Xu from"path";var Ra,Aa=g(()=>{"use strict";l();Ra={type:"turborepo",detect(t){return Yu.existsSync(Xu.join(t,"turbo.json"))?[]:null}}});import _n from"fs";import Ma from"path";var La,Oa=g(()=>{"use strict";l();Jt();La={type:"yarn",detect(t){if(!_n.existsSync(Ma.join(t,"yarn.lock")))return null;let e=Ma.join(t,"package.json");if(!_n.existsSync(e))return null;let r;try{r=JSON.parse(_n.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:Me(t,n)}}});function $(t){_a.push(t)}function Ga(){return _a}var _a,Vt=g(()=>{"use strict";l();_a=[]});import Zu from"path";function Gn(t,e=Ga()){let r=Zu.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var jn=g(()=>{"use strict";l();ba();va();Ta();Pa();Ia();Aa();Oa();Vt();Vt();$(Ra);$(wa);$(Na);$(La);$(ka);$(xa);$(Da)});var it,$n=g(()=>{"use strict";l();xe();it=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let r of e.nodes.values()){let n=this.getPackageForFile(r.path);if(n)for(let o of r.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==n.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function ja(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function eg(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function at(t,e,r){return Ng.every(n=>n(t,e,r))}var tg,rg,ng,og,sg,ig,ag,cg,lg,pg,fg,mg,ug,gg,dg,hg,yg,xg,bg,Sg,Cg,kg,vg,wg,Eg,Tg,Fg,Ng,Wn=g(()=>{"use strict";l();tg=(t,e)=>!e.category||ja(t.category,e.category),rg=(t,e)=>!e.type||ja(t.type,e.type),ng=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,og=(t,e)=>!e.path||eg(t.path,e.path),sg=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,ig=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},ag=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),cg=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),lg=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),pg=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,fg=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,mg=(t,e)=>e.minSize===void 0||t.size>=e.minSize,ug=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,gg=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,dg=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,hg=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,yg=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,xg=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,bg=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Sg=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Cg=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,kg=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,vg=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,wg=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Eg=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Tg=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Fg=(t,e,r)=>!e.any?.length||e.any.some(n=>at(t,n,r)),Ng=[tg,rg,ng,og,sg,ig,ag,cg,lg,pg,fg,mg,ug,gg,dg,hg,yg,xg,bg,Sg,Cg,kg,vg,wg,Eg,Tg,Fg]});function qt(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>at(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;switch(e.sort){case"size":p=c.size-a.size;break;case"imports":p=c.imports.length-a.imports.length;break;case"commitCount90d":p=(c.commitCount90d??0)-(a.commitCount90d??0);break;case"exportUsage":p=(c.avgExportUsage??0)-(a.avgExportUsage??0);break;case"complexity":p=(c.complexity??0)-(a.complexity??0);break;case"cognitiveComplexity":p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0);break}return p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var $a=g(()=>{"use strict";l();Wn();Wn()});function Dg(t,e,r,n){let o=t;switch(r){case"string":o[e]=n;break;case"int":o[e]=parseInt(n,10);break;case"float":o[e]=parseFloat(n);break;case"boolNotFalse":o[e]=n.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=n.toLowerCase()==="true";break}}function za(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!n||!o)return;if(n==="tag"||n==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(n==="sort"){t.sort=o;return}if(n==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=Pg[n];s&&Dg(t,s.field,s.kind,o)}function Ig(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};za(o,n),Object.keys(o).length>0&&e.push(o)}return e}function Qt(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith(Wa)&&o.endsWith(")")){let s=o.slice(Wa.length,-1),i=Ig(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}za(e,n)}return e}var Pg,Wa,Ba=g(()=>{"use strict";l();Pg={category:{field:"category",kind:"string"},type:{field:"type",kind:"string"},path:{field:"path",kind:"string"},importsfile:{field:"importsFile",kind:"string"},importedby:{field:"importedBy",kind:"string"},lastauthor:{field:"lastAuthor",kind:"string"},external:{field:"isExternal",kind:"boolIsTrue"},hasdocstring:{field:"hasDocstring",kind:"boolNotFalse"},isdocumented:{field:"isDocumented",kind:"boolNotFalse"},isstale:{field:"isStale",kind:"boolNotFalse"},minimports:{field:"minImports",kind:"int"},maximports:{field:"maxImports",kind:"int"},minsize:{field:"minSize",kind:"int"},maxsize:{field:"maxSize",kind:"int"},limit:{field:"limit",kind:"int"},mincoverage:{field:"minCoverage",kind:"int"},maxcoverage:{field:"maxCoverage",kind:"int"},minexportusage:{field:"minExportUsage",kind:"float"},maxexportusage:{field:"maxExportUsage",kind:"float"},mincomplexity:{field:"minComplexity",kind:"int"},maxcomplexity:{field:"maxComplexity",kind:"int"},mincognitivecomplexity:{field:"minCognitiveComplexity",kind:"int"},maxcognitivecomplexity:{field:"maxCognitiveComplexity",kind:"int"},mincommits:{field:"minCommits",kind:"int"},maxcommits:{field:"maxCommits",kind:"int"}};Wa="any("});var Ha=g(()=>{"use strict";l();$a();Ba()});import Rg from"path";import F from"typescript";function me(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function zn(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&Ua.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&Ua.has(o.expression.text)&&e.push(n)}return e}function Bn(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function Hn(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=me(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=me(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Un(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=me(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:me(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=me(s.properties,i);return i===s.properties.length-1?{start:me(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:me(s.properties,i+1).getStart(r),text:""}}return null}function Jn(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Kn(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Ag(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Yt(t,e,r,n){let o=F.createSourceFile(Rg.basename(t),e,F.ScriptTarget.Latest,!0),s=zn(o),[i]=s;if(!i)return e;let a=Bn(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Ag(a).sort())===JSON.stringify(c))return e;let p=Kn(c.map(u=>`@${u}`)),f=s.flatMap(u=>{let y=r.length===0?Un(u,n,o):Hn(u,n,p,o);return y?[y]:[]});return f.length>0?Jn(e,f):e}var Ua,W,Oe=g(()=>{"use strict";l();Ua=new Set(["describe","test","it"]);W=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Mg from"path";var Xt,Ja=g(()=>{"use strict";l();Oe();Xt=class{name="cypress";canHandle(e){return W.has(Mg.extname(e).toLowerCase())}apply(e,r,n){return Yt(e,r,n,"tags")}}});import Lg from"path";function Og(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
36
|
+
`),null}}var _g,Og,Gg,jg,$g,Wg,Rn=d(()=>{"use strict";p();Y();Vr();To();Fo();fc();dc();Do();bc();kc();Po();wc();$c();zc();Ao();Uc();Do();Hc();Jc();Vc();_g=20,Og=new Set(["css","scss","less"]),Gg=/(?:^|\/)(?:__tests__|__mocks__|__snapshots__|tests?|e2e)\/|\.(?:test|spec)\.[^/]*$|\.snap$/,jg=3,$g=6,Wg=120});var Fe,An=d(()=>{"use strict";p();Fe=class{affectedSymbols=new Map;constructor(e,n){this.affectedSymbols.set(e,new Set(["default",...n]))}updateAffectedSymbols(e,n){let r=this.affectedSymbols.get(n)||new Set,o=e.imports.find(c=>c.toPath===n);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||r.has("*")||r.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function De(t,e){let n=t.nodes.get(e);if(n)return{category:n.category,exports:n.exports.map(r=>r.name)}}function Mo(t,e,n=1){let r=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return r.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:n}),r}function Dt(t,e){let n=[];return t.traverse(e,r=>{if(r.path===e)return!0;let o=r.imports.find(s=>s.toPath===e);return n.push({path:r.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),n}function _o(t,e,n={}){let{testsOnly:r=!1,changedSymbols:o}=n,s=o?new Fe(e,o):null,i=[];return t.traverse(e,(a,c,l)=>{if(a.path===e)return!0;if(s&&l&&!s.updateAffectedSymbols(a,l))return!1;let u=a.category==="test"||a.tags.some(f=>f.name==="test");return(!r||u)&&i.push(a.path),!0},{direction:"incoming"}),i}function Oo(t,e,n={}){let{depth:r=1,withEdgeDetail:o=!1}=n,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:r}),s}function rt(t,e={}){let{metric:n="cognitiveComplexity",threshold:r=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[n]>=r).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[n]-s[n]).slice(0,o)}function Go(t){return{nodes:t.nodes.map(n=>({path:n.path,type:n.type,category:n.category,exports:n.exports.map(r=>r.name),tags:n.tags.filter(r=>r.kind==="comment-marker"||r.kind==="import").map(r=>r.name),importsFiles:n.imports.filter(r=>!r.isExternal&&r.toPath).map(r=>r.toPath),...n.package!==void 0&&{package:n.package},...n.description!==void 0&&{description:n.description},...n.testedBy!==void 0&&{testedBy:n.testedBy},...n.coveragePct!==void 0&&{coveragePct:n.coveragePct},...n.avgExportUsage!==void 0&&{avgExportUsage:n.avgExportUsage},...n.maxExportUsage!==void 0&&{maxExportUsage:n.maxExportUsage}})),cycles:t.cycles}}function jo(t){let e=t.getPackageDependencies(),n=Array.from(t.packages.values()).map(({graph:r,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:r.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:n.length,packages:n}}function ge(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function Qc(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function $o(t){return[...t.nodes.values()].some(e=>e.lastCommitAt!==void 0)}function ot(t,e={}){let{metric:n="cognitiveComplexity",minComplexity:r=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=Qc(t),c=[...t.nodes.values()].filter(l=>l.coveragePct!==void 0&&l.coveragePct<=o&&(!a||(l.commitCount90d??0)>=s)).flatMap(l=>(l.functions??[]).filter(u=>u[n]>=r).map(u=>({file:l.path,name:u.name,line:u.line,complexity:u.complexity,cognitiveComplexity:u.cognitiveComplexity,coveragePct:l.coveragePct,...l.commitCount90d!==void 0&&{commitCount90d:l.commitCount90d}}))).sort((l,u)=>u[n]-l[n]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Ln=d(()=>{"use strict";p();An()});import{execFileSync as zo}from"child_process";import Wo from"fs";import Jg from"os";import Vg from"path";function Bo(t,e){try{return zo("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error(`Could not resolve git ref "${e}" in ${t}`)}}async function Yc(t,e,n){let r=Wo.mkdtempSync(Vg.join(Jg.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));Wo.rmdirSync(r);try{return zo("git",["worktree","add","--detach",r,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await n(r)}finally{try{zo("git",["worktree","remove","--force",r],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{Wo.rmSync(r,{recursive:!0,force:!0})}}}var Xc=d(()=>{"use strict";p()});import Qg from"path";async function rl(t,e,n,r={}){let o=Bo(t,e),s=ki(t,o);if(s)return{sha:o,graph:s};let i=await Yc(t,o,async a=>{if(r.workspaceBuilder)return r.workspaceBuilder(a);let c=r.pathAliases?new ie(a,{pathAliases:r.pathAliases}):void 0;return new Te(a,null,c,void 0,r.gitStats??!1,new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[]).build(n)});return Ci(t,o,i),{sha:o,graph:i}}function Yg(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function Xg(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function Zg(t,e=4){let n=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),r=t.occurrences.length-n.length,o=r>0?`, +${r} more`:"";return`${t.lines}L x${t.occurrences.length}: ${n.join(", ")}${o}`}function qg(t,e){let{files:n,staleReferences:r,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],l=[n.added.length&&`${n.added.length} added`,n.changed.length&&`${n.changed.length} changed`,n.removed.length&&`${n.removed.length} removed`].filter(Boolean);c.push(l.length?`Files: ${l.join(", ")}`:"No file changes"),r.length>0&&c.push(`\u26A0 ${Ne(r.length,"stale reference")} \u2014 removed export still imported`);let u=s.newHotspots[0];return u?c.push(`+${Ne(s.newHotspots.length,"complexity hotspot")} (max ${e} ${u[e]} in ${u.file})`):s.resolvedHotspots.length>0&&c.push(`${Ne(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${Ne(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${Ne(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${Ne(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${Ne(a.newHotspots.length,"risk hotspot")}`),c}function eh(t){let{staleReferences:e,duplication:n,complexity:r,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":r.newHotspots.length>0||n.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function Uo(t,e={}){let n=e.metric??"cognitiveComplexity",r=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:l,coverage:u}=t,f=Zc(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),h=s.added.length+s.changed.length+s.removed.length,y={base:`${t.base.ref}@${qc(t.base.sha)}`,head:`${t.head.ref}@${qc(t.head.sha)}`,verdict:eh(t),headline:qg(t,n),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...h<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(y.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(y.complexity={avgDelta:f,newHotspots:c.newHotspots.slice(0,r).map(b=>Yg(b,n)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(y.duplication={newGroups:a.newGroups.slice(0,r).map(b=>Zg(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(l.newlyStale.length>0||l.resolved.length>0)&&(y.docDrift={newlyStale:l.newlyStale.slice(0,r).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:l.newlyStale.length,resolvedCount:l.resolved.length}),u&&(u.newHotspots.length>0||u.resolvedHotspots.length>0)&&(y.coverage={avgDelta:Zc(u.head.avgCoveragePct-u.base.avgCoveragePct),newHotspots:u.newHotspots.slice(0,r).map(b=>Xg(b,n)),newHotspotCount:u.newHotspots.length,resolvedCount:u.resolvedHotspots.length}),y}function th(t,e){let n=[],r=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){n.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(u=>u.name).sort(),imports:a.imports.map(u=>u.toPath).sort()}),l=JSON.stringify({category:i.category,exports:i.exports.map(u=>u.name).sort(),imports:i.imports.map(u=>u.toPath).sort()});c!==l&&r.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:n,removed:o,changed:r}}function nh(t,e){let n=[];for(let[r,o]of t.nodes){let s=e.nodes.get(r);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let l=[...e.nodes.values()].filter(u=>u.imports.some(f=>f.toPath===r&&f.symbols?.includes(c))).map(u=>u.path);l.length>0&&n.push({file:r,symbol:c,stillReferencedBy:l})}}return n}function In(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function rh(t,e,n,r,o){let s=Qg.join(Yt(t),`${r}-${be}`),i=Ze(s),[{groups:a},{groups:c}]=await Promise.all([nt(e,t,{minLines:o,tokenCache:i}),nt(n,t,{minLines:o})]);qe(i,s);let l=new Set(a.map(In)),u=new Set(c.map(In));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(f=>!l.has(In(f))),resolvedGroups:a.filter(f=>!u.has(In(f)))}}function el(t){let e=[...t.nodes.values()].map(n=>n.cognitiveComplexity).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function oh(t,e,n,r){let o=rt(t,{metric:n,threshold:r,limit:1/0}),s=rt(e,{metric:n,threshold:r,limit:1/0}),i=l=>`${l.file}:${l.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:el(t)},head:{avgCognitiveComplexity:el(e)},newHotspots:s.filter(l=>!a.has(i(l))),resolvedHotspots:o.filter(l=>!c.has(i(l)))}}function tl(t){let e=new Set;for(let n of t.nodes.values())if(!(n.type!=="markdown"||!n.staleFor))for(let r of n.staleFor)e.add(`${n.path}::${r}`);return e}function sh(t,e){let n=tl(t),r=tl(e);return{base:{staleCount:n.size},head:{staleCount:r.size},newlyStale:[...r].filter(o=>!n.has(o)),resolved:[...n].filter(o=>!r.has(o))}}function nl(t){let e=[...t.nodes.values()].map(n=>n.coveragePct).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function ih(t,e,n){if(!ge(t)||!ge(e))return null;let r=ot(t,{maxCoveragePct:n,limit:1/0}).hotspots,o=ot(e,{maxCoveragePct:n,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(r.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:nl(t)},head:{avgCoveragePct:nl(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:r.filter(c=>!a.has(s(c)))}}async function Ho(t,e,n,r={}){let{sha:o,graph:s}=await rl(t,e,r.entryPoints??[],r),i=Bo(t,r.headRef??"HEAD"),[a,c]=await Promise.all([rh(t,s,n,o,r.minDuplicateLines),Promise.resolve(ih(s,n,r.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:r.headRef??"HEAD",sha:i},files:th(s,n),staleReferences:nh(s,n),duplication:a,complexity:oh(s,n,r.complexityMetric,r.complexityThreshold),docDrift:sh(s,n),coverage:c}}var Zc,qc,Ne,ol=d(()=>{"use strict";p();Y();vi();wo();Rn();Ln();xn();Xc();Zc=t=>Math.round(t*100)/100,qc=t=>t.length>8?t.slice(0,8):t;Ne=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import Mn from"path";function ah(t){let e=new Map;for(let[n,r]of t){let o=r.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(n,o)}return e}function ch(t,e,n){let r=new Map;for(let[o,s]of e){if(s<n)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Mn.extname(o),c=Mn.basename(o,a),l=c==="index"?Mn.basename(Mn.dirname(o)):c;r.set(o,{path:o,outDegree:s,tag:`feature:${l}`})}return r}function Pe(t,e){let n=e?.minOutDegree??5;return ch(t,ah(t),n)}var _n=d(()=>{"use strict";p()});function ph(t,e){let n=new Map;for(let r of e.values()){let o=new Set;t.traverse(r.path,s=>(s.path!==r.path&&o.add(s.path),!0),{direction:"outgoing"}),n.set(r.path,o)}return n}function uh(t,e,n,r){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())n.get(a.path)?.has(s)&&(!i||r(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function fh(t,e){let n=new Map;for(let r of t.values()){let o=r.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===r.path&&s.push(i);n.set(o,{hub:r.path,outDegree:r.outDegree,files:s})}return n}function mh(t,e,n){let r=[];for(let o of t.keys())!e.has(o)&&!n.has(o)&&r.push(o);return r}function Nt(t,e){let n=e?.detectFn??Pe,r=e?.hubComparator??lh,o=n(t.nodes,e),s=ph(t,o),i=uh(t.nodes,o,s,r);return{features:fh(o,i),unassigned:mh(t.nodes,o,i)}}var lh,On=d(()=>{"use strict";p();_n();lh=(t,e)=>t.outDegree-e.outDegree});function sl(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,n=hh(e);for(let r of dh)if(r.segments?.some(o=>gh(e,o))||r.basenames?.includes(n))return r.role;return"other"}function gh(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function hh(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var dh,il=d(()=>{"use strict";p();dh=[{role:"component",segments:["component","components"]},{role:"controller",segments:["controller","controllers"]},{role:"middleware",segments:["middleware"]},{role:"router",segments:["router","routes","route"]},{role:"store",segments:["store","stores"]},{role:"service",segments:["service","services"]},{role:"handler",segments:["handler","handlers"]},{role:"adapter",segments:["adapter","adapters"]},{role:"plugin",segments:["plugin","plugins"]},{role:"api",segments:["api"]},{role:"cli",segments:["cli","commands"],basenames:["cli"]},{role:"util",segments:["util","utils","helper","helpers"]},{role:"model",segments:["model","models"],basenames:["model"]},{role:"parser",segments:["parser","parsers"],basenames:["parser"]},{role:"builder",basenames:["builder"]},{role:"resolver",basenames:["resolver"]}]});function Ko(t,e){let n=Nt(t,e),r=new Map;for(let[s,i]of n.features){for(let a of i.files)r.set(a,s);r.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=r.get(s.path);o.set(s.path,{path:s.path,role:sl(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Jo=d(()=>{"use strict";p();On();il()});function Vo(t,e){let n=[];for(let r of t.nodes.values())if(r.exports.some(o=>o.name===e))if(fn.has(r.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});n.push({path:r.path,category:r.category,precision:"call",callers:o})}else{let o=Dt(t,r.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));n.push({path:r.path,category:r.category,precision:"file-level",importers:o})}return n}var al=d(()=>{"use strict";p();mn();Ln()});function Xo(t){let e=new Map;for(let r of t)for(let o of r.nodes.values())for(let s of o.tags){let i=e.get(s.name);i===void 0&&(i={name:s.name,count:0,kinds:[]},e.set(s.name,i)),i.count+=1,i.kinds.includes(s.kind)||i.kinds.push(s.kind)}let n={};for(let r of e.values()){r.kinds.sort((o,s)=>cl.indexOf(o)-cl.indexOf(s));for(let o of r.kinds)n[o]=(n[o]??0)+1}return{entries:e,byKind:n,totalDistinct:e.size}}function Zo(t,e={}){let n=Number.isFinite(e.minCount)?Math.max(1,Math.trunc(e.minCount)):ll,r=Number.isFinite(e.limit)?Math.max(0,Math.trunc(e.limit)):pl,o=Math.min(r,Yo),s=e.prefix?.toLowerCase(),i=y=>e.kind===void 0?y.kinds.some(b=>Qo.includes(b))&&Kt(y.name):e.kind==="all"?!0:y.kinds.includes(e.kind),a=[...t.entries.values()].filter(y=>y.count>=n&&i(y)&&(s===void 0||y.name.toLowerCase().includes(s))).sort((y,b)=>b.count-y.count||y.name.localeCompare(b.name)),c=a.length,l=a.slice(0,o),u=e.kind===void 0?`${Qo.join(" + ")} kinds, noise-filtered`:e.kind==="all"?"all kinds":`${e.kind} kind`,f=c>l.length,h={tags:l.map(y=>({name:y.name,count:y.count,kinds:y.kinds})),count:l.length,matched:c,totalDistinct:t.totalDistinct,byKind:t.byKind,hint:`${c} tag${c===1?"":"s"} match (${u}, count>=${n})${f?`; showing the top ${l.length}`:""}. ${t.totalDistinct} distinct tag names exist across all kinds \u2014 see byKind. Narrow with prefix:"\u2026", a higher minCount, or kind:"comment-marker"|"import"|"function"|"variable"|"library"|"all". This response is always capped at ${Yo} tags.`};return f&&(h.truncated=!0),h}var Qo,ll,pl,Yo,cl,ul=d(()=>{"use strict";p();xe();Qo=Ut,ll=2,pl=50,Yo=250,cl=["function","class","variable","type","import","library","comment-marker"]});function yh(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function xh(t,e){if(e==="type-only")return!0;let n=t.signature??"";return n.startsWith("interface ")||n.startsWith("class ")||n.startsWith("enum ")}function qo(t){let e=new Map;for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript"))for(let o of r.exports){if(!xh(o,r.category))continue;let s=`${r.path}::${o.name}`;e.set(s,{name:o.name,file:r.path,kind:yh(o.signature),...o.doc?{doc:o.doc}:{}})}let n=[];for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript")){for(let o of r.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&n.push({fromFile:r.path,toType:s,toFile:o.toPath})}return{types:e,edges:n}}function es(t,e){let n=null;for(let s of t.types.values())if(s.name===e){n=s;break}if(!n)return{type:null,usedByFiles:[],uses:[]};let r=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===n.file&&r.add(s.fromFile),s.fromFile===n.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:n,usedByFiles:Array.from(r),uses:Array.from(o.values())}}var ts=d(()=>{"use strict";p()});import fl from"fs";import jE from"path";function Gn(t){try{return fl.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function jn(t){try{return fl.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Pt=d(()=>{"use strict";p()});import bh from"fs";import ns from"path";function ml(t,e=[]){let n;try{n=bh.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let r of n){let o=ns.join(t,r.name);r.isDirectory()?!kh.has(r.name)&&!r.name.startsWith(".")&&ml(o,e):r.isFile()&&Sh.has(ns.extname(r.name).toLowerCase())&&e.push(o)}return e}function $n(t,e,n){if(!Gn(e))return null;let r=ml(e);return r.length===0?null:{name:n,root:e,relativeRoot:ns.relative(t,e),entryPoints:r}}var Sh,kh,rs=d(()=>{"use strict";p();Y();Pt();Sh=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),kh=new Set($)});import dl from"fs";import gl from"path";function Ch(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function vh(t){let e=Ch(t),n=new Set;for(let r of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=r[1].replace(/^:/,"").replace(/:$/,"");o&&n.add(o)}return[...n]}var hl,yl=d(()=>{"use strict";p();rs();hl={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>gl.join(t,s)).find(s=>dl.existsSync(s));if(!e)return null;let n;try{n=dl.readFileSync(e,"utf-8")}catch{return null}let r=vh(n);if(r.length===0)return null;let o=[];for(let s of r){let i=gl.join(t,...s.split(":")),a=$n(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import Rt from"fs";import ae from"path";function ss(t,e){let n=ae.join(e,"package.json");if(!Rt.existsSync(n))return null;let r={};try{r=JSON.parse(Rt.readFileSync(n,"utf-8"))}catch{return null}let o=r.name;return o?{name:o,root:e,relativeRoot:ae.relative(t,e),entryPoints:Eh(e,r)}:null}function os(t,e){if(typeof t=="string"){wh.test(t)&&!t.endsWith(".d.ts")&&e(t);return}if(t&&typeof t=="object"&&!Array.isArray(t))for(let[n,r]of Object.entries(t))n!=="types"&&os(r,e)}function Eh(t,e){let n=[],r=new Set,o=a=>{let c=ae.join(t,a);r.has(c)||(r.add(c),n.push(c))},s=e.exports;if(typeof s=="string")os(s,o);else if(s&&typeof s=="object"&&!Array.isArray(s))for(let a of Object.values(s))os(a,o);e.main&&o(e.main);for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])o(a);let i=n.filter(jn);return i.length>0?i:n.slice(0,1)}function st(t,e){let n=[],r=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");Th(t,s,r,n)}return n}function Th(t,e,n,r){if(!e.includes("*")){Fh(t,e,n,r);return}let o=e.split("/");o.includes("**")?Dh(t,o,n,r):Nh(t,o,n,r)}function Fh(t,e,n,r){let o=ae.join(t,e);if(n.has(o)||!Gn(o))return;n.add(o);let s=ss(t,o);s&&r.push(s)}function Dh(t,e,n,r){let o=ae.join(t,e[0]==="**"?"":e[0]??"");xl(t,o,n,r)}function Nh(t,e,n,r){let o=e.findIndex(a=>a.includes("*")),s=ae.join(t,...e.slice(0,o)),i;try{i=Rt.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=ae.join(s,a.name);if(n.has(c))continue;n.add(c);let l=ss(t,c);l&&r.push(l)}}function xl(t,e,n,r){let o;try{o=Rt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=ae.join(e,s.name);if(Rt.existsSync(ae.join(i,"package.json"))&&!n.has(i)){n.add(i);let a=ss(t,i);a&&r.push(a)}else xl(t,i,n,r)}}var wh,Wn=d(()=>{"use strict";p();Pt();Pt();wh=/\.[mc]?[jt]sx?$/});import is from"fs";import bl from"path";var Sl,kl=d(()=>{"use strict";p();Wn();Sl={type:"npm",detect(t){let e=bl.join(t,"package.json");if(!is.existsSync(e))return null;let n;try{n=JSON.parse(is.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n||is.existsSync(bl.join(t,"yarn.lock")))return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:st(t,r)}}});import it from"fs";import I from"path";function vl(t,e,n,r){if(r>4)return[];let o;try{o=it.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=I.join(e,a);it.existsSync(I.join(c,"project.json"))&&!n.has(c)?(n.add(c),s.push(c)):s.push(...vl(t,c,n,r+1))}return s}function Ph(t,e,n){let r={};try{r=JSON.parse(it.readFileSync(n,"utf-8"))}catch{return null}let o=r.name,s,i,a=I.join(e,"package.json");if(it.existsSync(a))try{let c=JSON.parse(it.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:I.relative(t,e),entryPoints:Rh(e,r,s,i)}:null}function Rh(t,e,n,r){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=I.resolve(t,"../..");o.push(I.resolve(a,s)),o.push(I.resolve(t,s))}if(r){let a=r;if(typeof a=="string")o.push(I.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(I.join(t,c))}}if(n&&o.push(I.join(t,n)),e.sourceRoot){let a=I.resolve(t,"../.."),c=I.resolve(a,e.sourceRoot);o.push(I.join(c,"index.ts"),I.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(I.join(t,a));let i=o.filter(jn);return i.length>0?i.slice(0,1):o.slice(0,1)}var Cl,wl=d(()=>{"use strict";p();Pt();Cl={type:"nx",detect(t){return it.existsSync(I.join(t,"nx.json"))?vl(t,t,new Set,0).map(n=>Ph(t,n,I.join(n,"project.json"))).filter(n=>n!==null):null}}});import El from"fs";import Ah from"path";import{load as Lh}from"js-yaml";var Tl,Fl=d(()=>{"use strict";p();Wn();Tl={type:"pnpm",detect(t){let e=Ah.join(t,"pnpm-workspace.yaml");if(!El.existsSync(e))return null;let n=[];try{n=Lh(El.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return st(t,n)}}});import At from"fs";import zn from"path";function Ih(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function Mh(t){let e=Ih(t),n=new Map;for(let r of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=r[1],i=r[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");n.has(c)||n.set(c,{name:o,dir:c})}return[...n.values()]}var Dl,Nl=d(()=>{"use strict";p();rs();Dl={type:"sbt",detect(t){let e=zn.join(t,"build.sbt"),n=zn.join(t,"project");if(!At.existsSync(e)||!At.existsSync(n))return null;let r=[];try{r.push(At.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of At.readdirSync(n))a.endsWith(".scala")&&r.push(At.readFileSync(zn.join(n,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of r)for(let c of Mh(a))o.has(c.dir)||(o.add(c.dir),s.push(c));if(s.length===0)return null;let i=[];for(let a of s){let c=zn.join(t,...a.dir.split("/")),l=$n(t,c,a.name);l&&i.push(l)}return i.length>0?i:null}}});import _h from"fs";import Oh from"path";var Pl,Rl=d(()=>{"use strict";p();Pl={type:"turborepo",detect(t){return _h.existsSync(Oh.join(t,"turbo.json"))?[]:null}}});import as from"fs";import Al from"path";var Ll,Il=d(()=>{"use strict";p();Wn();Ll={type:"yarn",detect(t){if(!as.existsSync(Al.join(t,"yarn.lock")))return null;let e=Al.join(t,"package.json");if(!as.existsSync(e))return null;let n;try{n=JSON.parse(as.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n)return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:st(t,r)}}});function q(t){Ml.push(t)}function _l(){return Ml}var Ml,Bn=d(()=>{"use strict";p();Ml=[]});import jT from"fs";import WT from"path";var Ol=d(()=>{"use strict";p()});import jh from"path";function Lt(t,e=_l()){let n=jh.resolve(t),r=new Map,o=[];for(let i of e){let a=i.detect(n);if(a!==null){o.push(i.type);for(let c of a)r.has(c.name)||r.set(c.name,c)}}if(o.length===0)return{root:n,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(r.values());return{root:n,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var cs=d(()=>{"use strict";p();yl();kl();wl();Fl();Nl();Rl();Il();Bn();Ol();Bn();q(Pl);q(Cl);q(Tl);q(Ll);q(Sl);q(hl);q(Dl)});function ls(t,e){return t===e.relativeRoot||t.startsWith(`${e.relativeRoot}/`)}var It,ps=d(()=>{"use strict";p();$e();It=class t{constructor(e,n){this.monorepoRoot=e;this.type=n}monorepoRoot;type;packages=new Map;flattened;addPackage(e,n){this.packages.set(e.name,{graph:n,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let n of e.nodes.values()){let r=this.getPackageForFile(n.path);if(r)for(let o of n.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==r.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}flatten(){if(this.flattened)return this.flattened;let e=new Map,n=new Map;for(let{graph:r,pkg:o}of this.packages.values())for(let[s,i]of r.nodes)ls(s,o)&&(e.set(s,i),n.set(s,o.name));return this.flattened={graph:new _(e),packageOf:n},this.flattened}getPackageForFile(e){for(let{pkg:n}of this.packages.values())if(e===n.relativeRoot||e.startsWith(`${n.relativeRoot}/`))return n}getPackageDependencies(){let e=new Map;for(let{graph:n,pkg:r}of this.packages.values()){let o=new Set;for(let s of n.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(r.name,[...o])}return e}getAffectedAcrossPackages(e){let{graph:n,packageOf:r}=this.flatten();if(!n.nodes.has(e))return[];let o=[];return n.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.get(s.path)??""}),!0),{direction:"incoming"}),o}summarizeAffectedAcrossPackages(e,n={}){let r=n.maxFilesPerPackage??10,o=this.getAffectedAcrossPackages(e),s=new Map;for(let{file:c,package:l}of o){let u=s.get(l)??[];u.push(c),s.set(l,u)}let i=!1,a=[...s.entries()].map(([c,l])=>{let u=l.slice(0,r),f=l.length-u.length;return f>0&&(i=!0),{package:c,count:l.length,sample:u,more:f}}).sort((c,l)=>l.count-c.count);return{file:e,totalAffected:o.length,packageCount:a.length,byPackage:a,truncated:i}}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:n})=>({pkg:{name:n.name,relativeRoot:n.relativeRoot,entryPoints:n.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let n=new t(e.monorepoRoot,e.type);for(let{pkg:r,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new _(s);n.packages.set(r.name,{graph:i,pkg:{...r,root:""}})}return n}}});function us(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function $h(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function Mt(t,e,n,r){return gy.every(o=>o(t,e,n,r))}var Wh,zh,Bh,Uh,Hh,Kh,Jh,Vh,Qh,Yh,Xh,Zh,qh,ey,ty,ny,ry,oy,sy,iy,ay,cy,ly,py,uy,fy,my,dy,gy,fs=d(()=>{"use strict";p();xe();Wh=(t,e)=>!e.category||us(t.category,e.category),zh=(t,e)=>!e.type||us(t.type,e.type),Bh=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Uh=(t,e)=>!e.path||$h(t.path,e.path),Hh=(t,e,n,r)=>{if(!e.package||!r)return!0;let o=r.get(t.path)??"";return us(o,e.package)},Kh=(t,e)=>e.isExternal===void 0?!0:t.imports.some(r=>r.isExternal)===e.isExternal,Jh=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let n=new Set(t.tags.filter(ye).map(s=>s.name)),r=e.tags.filter(s=>!s.startsWith("!")),o=e.tags.filter(s=>s.startsWith("!")).map(s=>s.slice(1));return!(r.length>0&&!r.some(s=>n.has(s))||o.some(s=>n.has(s)))},Vh=(t,e)=>{if(!e.allTags?.length)return!0;let n=new Set(t.tags.filter(ye).map(r=>r.name));return e.allTags.every(r=>n.has(r))},Qh=(t,e)=>!e.importsFile||t.imports.some(n=>n.toPath?.includes(e.importsFile)),Yh=(t,e,n)=>e.importedBy===void 0?!0:(n?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),Xh=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Zh=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,qh=(t,e)=>e.minSize===void 0||t.size>=e.minSize,ey=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,ty=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,ny=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,ry=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,oy=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,sy=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,iy=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,ay=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,cy=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,ly=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,py=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,uy=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,fy=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,my=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,dy=(t,e,n,r)=>!e.any?.length||e.any.some(o=>Mt(t,o,n,r)),gy=[Wh,zh,Bh,Uh,Hh,Kh,Jh,Vh,Qh,Yh,Xh,Zh,qh,ey,ty,ny,ry,oy,sy,iy,ay,cy,ly,py,uy,fy,my,dy]});function Un(t,e,n={}){let{packageOf:r}=n,o=new Map;if(e.importedBy!==void 0){for(let c of t.nodes)for(let l of c.imports)if(l.toPath){let u=o.get(l.toPath)??[];u.push(c.path),o.set(l.toPath,u)}}let s=t.nodes.filter(c=>Mt(c,e,o,r)),i=new Set(s.map(c=>c.path)),a=s.map(c=>{let l=r?.get(c.path);return{...c,imports:c.imports.filter(u=>!u.toPath||i.has(u.toPath)),...l!==void 0&&{package:l}}});if(e.sort){let c=e.sortDir==="asc"?-1:1;a.sort((l,u)=>{let f=0;switch(e.sort){case"size":f=u.size-l.size;break;case"imports":f=u.imports.length-l.imports.length;break;case"commitCount90d":f=(u.commitCount90d??0)-(l.commitCount90d??0);break;case"exportUsage":f=(u.avgExportUsage??0)-(l.avgExportUsage??0);break;case"complexity":f=(u.complexity??0)-(l.complexity??0);break;case"cognitiveComplexity":f=(u.cognitiveComplexity??0)-(l.cognitiveComplexity??0);break}return f*c})}return e.limit!==void 0&&a.splice(e.limit),{nodes:a,cycles:t.cycles?.filter(c=>c.every(l=>i.has(l)))??void 0}}var Gl=d(()=>{"use strict";p();fs();fs()});function yy(t,e,n,r){let o=t;switch(n){case"string":o[e]=r;break;case"int":o[e]=parseInt(r,10);break;case"float":o[e]=parseFloat(r);break;case"boolNotFalse":o[e]=r.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=r.toLowerCase()==="true";break}}function $l(t,e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(r==="tag"||r==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(r==="sort"){t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=hy[r];s&&yy(t,s.field,s.kind,o)}function xy(t){let e=[];for(let n of t.split("|")){let r=n.trim();if(!r)continue;let o={};$l(o,r),Object.keys(o).length>0&&e.push(o)}return e}function Hn(t){let e={},n=t.split(",");for(let r of n){let o=r.trim();if(o.toLowerCase().startsWith(jl)&&o.endsWith(")")){let s=o.slice(jl.length,-1),i=xy(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}$l(e,r)}return e}var hy,jl,Wl=d(()=>{"use strict";p();hy={category:{field:"category",kind:"string"},type:{field:"type",kind:"string"},path:{field:"path",kind:"string"},package:{field:"package",kind:"string"},importsfile:{field:"importsFile",kind:"string"},importedby:{field:"importedBy",kind:"string"},lastauthor:{field:"lastAuthor",kind:"string"},external:{field:"isExternal",kind:"boolIsTrue"},hasdocstring:{field:"hasDocstring",kind:"boolNotFalse"},isdocumented:{field:"isDocumented",kind:"boolNotFalse"},isstale:{field:"isStale",kind:"boolNotFalse"},minimports:{field:"minImports",kind:"int"},maximports:{field:"maxImports",kind:"int"},minsize:{field:"minSize",kind:"int"},maxsize:{field:"maxSize",kind:"int"},limit:{field:"limit",kind:"int"},mincoverage:{field:"minCoverage",kind:"int"},maxcoverage:{field:"maxCoverage",kind:"int"},minexportusage:{field:"minExportUsage",kind:"float"},maxexportusage:{field:"maxExportUsage",kind:"float"},mincomplexity:{field:"minComplexity",kind:"int"},maxcomplexity:{field:"maxComplexity",kind:"int"},mincognitivecomplexity:{field:"minCognitiveComplexity",kind:"int"},maxcognitivecomplexity:{field:"maxCognitiveComplexity",kind:"int"},mincommits:{field:"minCommits",kind:"int"},maxcommits:{field:"maxCommits",kind:"int"}};jl="any("});var zl=d(()=>{"use strict";p();To();Fo();Gl();Wl()});import Sy from"path";import R from"typescript";function Re(t,e){let n=t[e];if(n===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return n}function ms(t){let e=[];for(let n of t.statements){if(!R.isExpressionStatement(n))continue;let r=n.expression;if(!R.isCallExpression(r))continue;let o=r.expression;R.isIdentifier(o)&&Bl.has(o.text)&&e.push(r),R.isPropertyAccessExpression(o)&&R.isIdentifier(o.expression)&&Bl.has(o.expression.text)&&e.push(r)}return e}function ds(t,e,n){for(let r of t.arguments){if(!R.isObjectLiteralExpression(r))continue;let o=r.properties.find(s=>R.isPropertyAssignment(s)&&R.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!R.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(R.isStringLiteral).map(s=>s.text)}return null}function gs(t,e,n,r){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=Re(t.arguments,s);if(!R.isObjectLiteralExpression(i))continue;let a=i.properties.find(l=>R.isPropertyAssignment(l)&&R.isIdentifier(l.name)&&l.name.text===e);if(a)return{start:a.initializer.getStart(r),end:a.initializer.getEnd(),text:n};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${n}`}}let o=Re(t.arguments,t.arguments.length-1);return{start:o.getStart(r),end:o.getStart(r),text:`{ ${e}: ${n} }, `}}function hs(t,e,n){let r=t.arguments;for(let o=1;o<r.length;o++){let s=Re(r,o);if(!R.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>R.isPropertyAssignment(c)&&R.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:Re(r,o-1).getEnd(),end:s.getEnd(),text:""};let a=Re(s.properties,i);return i===s.properties.length-1?{start:Re(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(n),end:Re(s.properties,i+1).getStart(n),text:""}}return null}function ys(t,e){let n=[...e].sort((o,s)=>s.start-o.start),r=t;for(let o of n)r=r.slice(0,o.start)+o.text+r.slice(o.end);return r}function xs(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function ky(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Kn(t,e,n,r){let o=R.createSourceFile(Sy.basename(t),e,R.ScriptTarget.Latest,!0),s=ms(o),[i]=s;if(!i)return e;let a=ds(i,r,o),c=[...n].sort();if(a!==null&&JSON.stringify(ky(a).sort())===JSON.stringify(c))return e;let l=xs(c.map(f=>`@${f}`)),u=s.flatMap(f=>{let h=n.length===0?hs(f,r,o):gs(f,r,l,o);return h?[h]:[]});return u.length>0?ys(e,u):e}var Bl,ee,at=d(()=>{"use strict";p();Bl=new Set(["describe","test","it"]);ee=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Cy from"path";var Jn,Ul=d(()=>{"use strict";p();at();Jn=class{name="cypress";canHandle(e){return ee.has(Cy.extname(e).toLowerCase())}apply(e,n,r){return Kn(e,n,r,"tags")}}});import vy from"path";function wy(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
28
37
|
`)}
|
|
29
38
|
|
|
30
|
-
`}function
|
|
31
|
-
`}function
|
|
32
|
-
${
|
|
39
|
+
`}function Ey(t){let e=new Set;Ss.lastIndex=0;let n=Ss.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=Ss.exec(t);return e}var bs,Ss,Vn,Hl=d(()=>{"use strict";p();bs=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ss=/^@([a-zA-Z0-9_-]+)/gm;Vn=class{name="gherkin";canHandle(e){return vy.extname(e).toLowerCase()===".feature"}apply(e,n,r){let o=n.replace(bs,""),s=Ey(o),i=r.filter(c=>!s.has(c)),a=i.length>0?wy(i):"";return bs.test(n)?n.replace(bs,a):a?n.replace(/^(Feature:)/m,`${a}$1`):n}}});function Kl(t,e){let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/"),o="";for(let s=0;s<n.length;s++){let i=n[s];i==="*"?n[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(r)}var Jl=d(()=>{"use strict";p()});import Ty from"path";function Dy(t){return`//go:build ${t.map(n=>`mokosh_${n}`).join(" || ")}
|
|
40
|
+
`}function Ny(t){let e=ks.exec(t);if(!e)return null;let n=e[0]??"",r=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=r.exec(n);for(;s!==null;)s[1]&&o.push(s[1]),s=r.exec(n);return o}var ks,Fy,Qn,Vl=d(()=>{"use strict";p();ks=/^\/\/go:build mokosh_[^\n]+\n/m,Fy=/^package\s+\S+/m;Qn=class{name="go";canHandle(e){return Ty.basename(e).endsWith("_test.go")}apply(e,n,r){let o=Ny(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(ks,"");let i=Dy(s);if(o!==null)return n.replace(ks,i);let a=Fy.exec(n);if(!a)return n;let c=a.index;return`${n.slice(0,c)+i}
|
|
41
|
+
${n.slice(c)}`}}});import Py from"path";function Ay(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
33
42
|
`)}
|
|
34
43
|
|
|
35
|
-
`}function
|
|
44
|
+
`}function Ly(t){let e=[];Cs.lastIndex=0;let n=Cs.exec(t);for(;n!==null;)n[1]&&e.push(n[1]),n=Cs.exec(t);return e}var Ry,Cs,Yn,Ql=d(()=>{"use strict";p();at();Ry=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Cs=/^ \* @group (.+)$/gm;Yn=class{name="jest";canHandle(e){return ee.has(Py.extname(e).toLowerCase())}apply(e,n,r){let o=Ry.exec(n),s=o?Ly(o[0]):null,i=[...r].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return n;let a=o?n.slice(o[0].length):n;return r.length===0?a:Ay(i)+a}}});import Yl from"path";function jy(t){let e=vs.exec(t);if(!e)return null;let n=[],r=/@Tag\("([^"]*)"\)/g,o=r.exec(e[0]);for(;o!==null;)o[1]&&n.push(o[1]),o=r.exec(e[0]);return n}function $y(t){return`${Iy}
|
|
36
45
|
${t.map(e=>`@Tag("${e}")`).join(`
|
|
37
46
|
`)}
|
|
38
|
-
`}function
|
|
39
|
-
`+t.slice(
|
|
40
|
-
`+
|
|
41
|
-
`+t.slice(
|
|
42
|
-
`+t}function
|
|
43
|
-
`),
|
|
47
|
+
`}function Xl(t,e){if(e.importRe.test(t))return t;let n=e.lastImportRe.exec(t);if(n){let o=n.index+n[0].length;return t.slice(0,o)+e.importLine+`
|
|
48
|
+
`+t.slice(o)}let r=e.packageRe.exec(t);if(r){let o=r.index+r[0].length;return t.slice(0,o)+`
|
|
49
|
+
`+e.importLine+`
|
|
50
|
+
`+t.slice(o)}return e.importLine+`
|
|
51
|
+
`+t}function Wy(t,e){return/@Tag\b/.test(t)?t:t.replace(e.importRe,"")}var Iy,vs,My,_y,Oy,Gy,Xn,Zl=d(()=>{"use strict";p();Iy="// mokosh:tags",vs=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,My=/\/src\/(test|androidTest|integrationTest|it)\//,_y=/(Test|Tests|Spec|IT)\.(java|groovy|kt)$/,Oy={importLine:"import org.junit.jupiter.api.Tag;",importRe:/^import org\.junit\.jupiter\.api\.Tag;?\n/m,typeDeclRe:/^(?:public\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+|strictfp\s+)*(?:class|interface|enum|record|@interface)\s+\w+/m,lastImportRe:/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,packageRe:/^package\s+[^\n]+;\n/m},Gy={importLine:"import org.junit.jupiter.api.Tag",importRe:/^import org\.junit\.jupiter\.api\.Tag;?\n/m,typeDeclRe:/^(?:public\s+|private\s+|protected\s+|internal\s+|open\s+|abstract\s+|final\s+|sealed\s+|data\s+|inner\s+|value\s+|annotation\s+)*(?:enum\s+)?(?:class|interface|object)\s+\w+/m,lastImportRe:/^import\s+[^\n]+\n(?![\s\S]*^import\s)/m,packageRe:/^package\s+[^\n]+\n/m};Xn=class{name="junit";canHandle(e){let n=e.replace(/\\/g,"/"),r=Yl.extname(n).toLowerCase();return r!==".java"&&r!==".groovy"&&r!==".kt"?!1:My.test(n)||_y.test(n)}apply(e,n,r){let o=Yl.extname(e.replace(/\\/g,"/")).toLowerCase()===".kt"?Gy:Oy,s=jy(n),i=[...r].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return n;if(r.length===0)return s===null?n:Wy(n.replace(vs,""),o);let a=$y(i);if(s!==null)return Xl(n.replace(vs,a),o);let c=o.typeDeclRe.exec(n);if(!c)return n;let l=n.slice(0,c.index)+a+n.slice(c.index);return Xl(l,o)}}});import zy from"path";var Zn,ql=d(()=>{"use strict";p();at();Zn=class{name="playwright";canHandle(e){return ee.has(zy.extname(e).toLowerCase())}apply(e,n,r){return Kn(e,n,r,"tag")}}});import By from"path";function Hy(t){let e=t.map(n=>`pytest.mark.${n}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ky(t){let e=ws.exec(t);if(!e)return null;let n=e[0],r=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(n);for(;s!==null;)s[1]&&r.push(s[1]),s=o.exec(n);return r}function Jy(t){let e=t.split(`
|
|
52
|
+
`),n=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(n=s)}),n<0?0:e.slice(0,n+1).reduce((o,s)=>o+s.length+1,0)}var ws,Uy,qn,ep=d(()=>{"use strict";p();ws=/^pytestmark\s*=\s*.+$/m,Uy=/^import pytest\s*$/m;qn=class{name="pytest";canHandle(e){return By.extname(e).toLowerCase()===".py"}apply(e,n,r){let o=Ky(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(ws,"").replace(/\n{3,}/g,`
|
|
44
53
|
|
|
45
|
-
`);let i=
|
|
46
|
-
`,
|
|
54
|
+
`);let i=Hy(s);if(o!==null)return n.replace(ws,i);let a=Uy.test(n),c=Jy(n),l=n.slice(0,c),u=n.slice(c),f=a?"":`import pytest
|
|
55
|
+
`,h=l.endsWith(`
|
|
47
56
|
|
|
48
57
|
`)?"":`
|
|
49
|
-
`;return`${
|
|
50
|
-
${
|
|
51
|
-
`;if(o!==null)return r.replace(to,i);let a=ld.exec(r);return a?r.slice(0,a.index)+i+r.slice(a.index):r}}});import oc from"path";import sc from"typescript";var ud,ir,ic=g(()=>{"use strict";l();Oe();ud=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,ir=class{name="vitest";canHandle(e){return W.has(oc.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(ud,""),s=sc.createSourceFile(oc.basename(e),o,sc.ScriptTarget.Latest,!0),i=zn(s),[a]=i;if(!a)return o;let c=Bn(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(u=>{let y=n.length===0?Un(u,"tags",s):Hn(u,"tags",Kn(p),s);return y?[y]:[]});return f.length>0?Jn(o,f):o}}});import ro from"path";import ar from"typescript";function dd(t){let e=ar.createSourceFile("detect.ts",t,ar.ScriptTarget.Latest,!0);for(let r of e.statements){if(!ar.isImportDeclaration(r)||!ar.isStringLiteral(r.moduleSpecifier))continue;let n=gd[r.moduleSpecifier.text];if(n)return n}return null}function cc(t="vitest",e={},r=process.cwd()){return[new Zt,new or,new er,new rr,new sr,new no(r,t,Object.entries(e))]}function lc(t,e){return e.find(r=>r.canHandle(t))??null}var ac,gd,no,pc=g(()=>{"use strict";l();Ja();Ka();qa();Qa();Ya();ec();tc();rc();nc();Oe();ic();ac={vitest:()=>new ir,playwright:()=>new nr,cypress:()=>new Xt,jest:()=>new tr},gd={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};no=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return W.has(ro.extname(e).toLowerCase())}apply(e,r,n){let o=dd(r)??this.matchOverride(e)??this.defaultFramework;return(ac[o]??ac.vitest)().apply(e,r,n)}matchOverride(e){let r=ro.relative(this.rootDir,e).split(ro.sep).join("/");for(let[n,o]of this.frameworkOverrides)if(Va(n,r))return o;return null}}});import fc from"fs/promises";import hd from"path";async function Sd(t,e,r,n){let o;try{o=await fc.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=lc(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await fc.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function oo(t,e,r){let n=he(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=cc(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,f=[];for(let x of c.tags)xd.has(x.kind)&&yd.test(x.name)&&(bd.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),f.push(x.name)));f.sort();let u=hd.resolve(e,c.path),y=await Sd(u,f,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var yd,xd,bd,mc=g(()=>{"use strict";l();wr();pc();yd=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,xd=new Set(["import"]),bd=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var cr,so=g(()=>{"use strict";l();cr=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});var uc=g(()=>{"use strict";l();Pr();dn();Ir();Mr();Ot();Wt();zt();xe();Lt();Nn();_t();Rn();jn();$n()});var io=g(()=>{"use strict";l();uc()});function gc(t,e){return{identifier:e?.identifier??new cr,featureMap:e?.featureDetection===!1?new Map:fe(t.nodes,e?.featureDetection??void 0)}}function dc(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new ce(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let u=r.get(c.path);if(u)return n(u),!1}return o(c),!0},{direction:"incoming"})}}function ao(t,e,r){let{identifier:n,featureMap:o}=gc(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return dc(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function co(t,e,r){let{identifier:n,featureMap:o}=gc(t,r),s=new Set;return dc(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var hc=g(()=>{"use strict";l();io();so()});var yc=g(()=>{"use strict";l();mc();so();hc()});import Cd from"fs";import ct from"path";async function M(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=ct.resolve(t);return await new ae(s,r,n.pathAliases?new J(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(e)}async function xc(t,e={}){let r=ct.resolve(t),n=Gn(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new it(r,n.type);for(let a of o){let c=e.silent?void 0:u=>{process.stderr.write(`[${a.name}] Processed ${u} files...\r`)},f=await new ae(r,null,new J(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,f)}return i.annotateCrossPackageEdges(),i}function L(t,e={}){let r=[],n=new Set([...e.ignoreDirs??I,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Er,...e.additionalExtensions??[]]);function s(i){try{let a=Cd.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=ct.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has(ct.extname(c.name).toLowerCase())&&r.push(ct.relative(t,p))}}catch{}}return s(t),r}var k=g(()=>{"use strict";l();wr();G();jo();Wo();Pr();Ir();Mr();pa();Ot();Wt();zt();It();xe();Gt();Nn();ua();_t();Rn();jn();Vt();$n();de();Be();Ha();yc();G();io()});var lo=g(()=>{"use strict";l();G()});import lt from"path";import{parseArgs as kd}from"util";function vd(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return lt.resolve(t[e+1]);return process.cwd()}function K(t){return t?parseInt(t,10):void 0}function bc(t){return t?t.split(",").map(e=>e.trim()):void 0}function Ed(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(wd.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in po&&e.push(n)}return e}function Td(t){return{mermaid:t.mermaid??!1,proposeTags:t["propose-tags"]??!1,plain:t.plain??!1,affectedTests:t["affected-tests"]??!1,detectFeatures:t["detect-features"]??!1,findUnused:t["find-unused"]??!1,excludeTests:t["exclude-tests"]??!1,checkCycles:t["check-cycles"]??!1,checkDocDrift:t["check-doc-drift"]??!1,findUncovered:t["find-uncovered"]??!1}}function Fd(t){return{listTags:t["list-tags"]??!1,callers:t.callers??!1,silent:t.silent??!1,queryHelp:t["query-help"]??!1,typeGraph:t["type-graph"]??!1,moduleResponsibility:t["module-responsibility"]??!1,featureGraph:t["feature-graph"]??!1,callGraph:t["call-graph"]??!1,findSymbol:t["find-symbol"]??!1,apiSurface:t["api-surface"]??!1}}function Nd(t){return{applyTags:t["apply-tags"]??!1,dryRun:t["dry-run"]??!1,initSkill:t["init-skill"]??!1,initConfig:t["init-config"]??!1,force:t.force??!1,dependencies:t.dependencies??!1,dependents:t.dependents??!1,affected:t.affected??!1,testsOnly:t["tests-only"]??!1,cached:t.cached??!1}}function Pd(t){return{withMeta:t["with-meta"]??!1,withEdgeDetail:t["with-edge-detail"]??!1,findComplexFunctions:t["find-complex-functions"]??!1,findDuplicates:t["find-duplicates"]??!1,findRiskHotspots:t["find-risk-hotspots"]??!1,workspacePackages:t["workspace-packages"]??!1,workspaceAffected:t["workspace-affected"]??!1,clearCache:t["clear-cache"]??!1,slim:t.slim??!1,watch:t.watch??!1}}function Sc(t){let e=vd(t),r=lt.join(lt.resolve(e,V),ye),{values:n,positionals:o}=kd({args:Ed(t),allowPositionals:!0,options:po}),s=n.cache,i=n.config,a=n.metric,c=n;return{rootDir:e,cachePath:s?lt.resolve(e,s):r,configPath:i?lt.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:bc(n.paths),featureThreshold:K(n["feature-threshold"]),minOutDegree:K(n["min-out-degree"]),...Td(c),...Fd(c),help:t.length===0||(n.help??!1),...Nd(c),changedSymbols:bc(n["changed-symbols"]),depth:K(n.depth),...Pd(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:K(n["complexity-threshold"]),limit:K(n.limit),minDuplicateLines:K(n["min-duplicate-lines"]),maxCoveragePct:K(n["max-coverage-pct"]),minChurn:K(n["min-churn"]),base:n.base,compareBranches:n["compare-branches"],compareFull:n["compare-full"]??!1,compareMaxItems:K(n["compare-max-items"]),entryPoints:o}}var po,wd,Cc=g(()=>{"use strict";l();lo();po={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"find-risk-hotspots":{type:"boolean"},"max-coverage-pct":{type:"string"},"min-churn":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"},base:{type:"string"},"compare-branches":{type:"string"},"compare-full":{type:"boolean"},"compare-max-items":{type:"string"}},wd=new Set(Object.entries(po).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function fo(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(u=>({path:u,...le(e,u)})):f;if(s){let f=Rr(e),u=Ar(f,r),y=n?u.filter(b=>e.nodes.get(b)?.category==="test"):u,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=xn(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var kc=g(()=>{"use strict";l();k()});import mo from"path";function ue(t){return t.filter(e=>{let r=mo.basename(e).toLowerCase();return Dd.some(n=>r.includes(n))})}function lr(t,e){return new yt().getChangedFiles(t,e).map(r=>mo.relative(t,mo.resolve(t,r)))}var Dd,pr=g(()=>{"use strict";l();Or();Dd=[".test.",".spec.","-test.","-spec."]});async function vc(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s,base:i}=t,a=lr(r,i);if(![...e.nodes.values()].some(f=>ue([f.path]).length>0)){let f=L(r,n);e=await M(r,ue(f),e,T(s))}let p=co(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
|
|
52
|
-
`))}var
|
|
53
|
-
`):JSON.stringify({file:
|
|
54
|
-
`);for(let
|
|
55
|
-
`);process.exit(1)}console.log("No cycles detected.")}var
|
|
56
|
-
`);
|
|
57
|
-
`);
|
|
58
|
-
`):JSON.stringify({
|
|
59
|
-
`):JSON.stringify({
|
|
60
|
-
`):JSON.stringify({
|
|
58
|
+
`;return`${l+h+f+i}
|
|
59
|
+
${u}`}}});import Vy from"path";function Zy(t){let e=Es.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var Es,Qy,Yy,Xy,er,tp=d(()=>{"use strict";p();Es=/^\/\/ mokosh:tags .*\n/m,Qy=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,Yy=/\/src\/(test|it)\//,Xy=/(Spec|Suite|Test|Props)\.scala$/;er=class{name="scalatest";canHandle(e){let n=e.replace(/\\/g,"/");return Vy.extname(n).toLowerCase()!==".scala"?!1:Yy.test(n)||Xy.test(n)}apply(e,n,r){let o=Zy(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return o===null?n:n.replace(Es,"");let i=`// mokosh:tags ${s.join(", ")}
|
|
60
|
+
`;if(o!==null)return n.replace(Es,i);let a=Qy.exec(n);return a?n.slice(0,a.index)+i+n.slice(a.index):n}}});import np from"path";import rp from"typescript";var qy,tr,op=d(()=>{"use strict";p();at();qy=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,tr=class{name="vitest";canHandle(e){return ee.has(np.extname(e).toLowerCase())}apply(e,n,r){let o=n.replace(qy,""),s=rp.createSourceFile(np.basename(e),o,rp.ScriptTarget.Latest,!0),i=ms(s),[a]=i;if(!a)return o;let c=ds(a,"tags",s),l=[...r].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(l))return o;let u=i.flatMap(f=>{let h=r.length===0?hs(f,"tags",s):gs(f,"tags",xs(l),s);return h?[h]:[]});return u.length>0?ys(o,u):o}}});import Ts from"path";import nr from"typescript";function tx(t){let e=nr.createSourceFile("detect.ts",t,nr.ScriptTarget.Latest,!0);for(let n of e.statements){if(!nr.isImportDeclaration(n)||!nr.isStringLiteral(n.moduleSpecifier))continue;let r=ex[n.moduleSpecifier.text];if(r)return r}return null}function ip(t="vitest",e={},n=process.cwd()){return[new Vn,new qn,new Qn,new Xn,new er,new Fs(n,t,Object.entries(e))]}function ap(t,e){return e.find(n=>n.canHandle(t))??null}var sp,ex,Fs,cp=d(()=>{"use strict";p();Ul();Hl();Jl();Vl();Ql();Zl();ql();ep();tp();at();op();sp={vitest:()=>new tr,playwright:()=>new Zn,cypress:()=>new Jn,jest:()=>new Yn},ex={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Fs=class{constructor(e,n,r){this.rootDir=e;this.defaultFramework=n;this.frameworkOverrides=r}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return ee.has(Ts.extname(e).toLowerCase())}apply(e,n,r){let o=tx(n)??this.matchOverride(e)??this.defaultFramework;return(sp[o]??sp.vitest)().apply(e,n,r)}matchOverride(e){let n=Ts.relative(this.rootDir,e).split(Ts.sep).join("/");for(let[r,o]of this.frameworkOverrides)if(Kl(r,n))return o;return null}}});import lp from"fs/promises";import nx from"path";async function rx(t,e,n,r){let o;try{o=await lp.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=ap(t,r);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(n||await lp.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Ds(t,e,n){let r=Oe(e),o=r.tagApplier?.framework??"vitest",s=r.tagApplier?.frameworkOverrides??{},i=ip(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let l=new Set,u=[];for(let y of c.tags)ye(y)&&(l.has(y.name)||(l.add(y.name),u.push(y.name)));u.sort();let f=nx.resolve(e,c.path),h=await rx(f,u,n.dryRun,i);h.path=c.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var pp=d(()=>{"use strict";p();Er();xe();cp()});var rr,Ns=d(()=>{"use strict";p();rr=class{isTestNode(e){return e.category==="test"||e.tags.some(n=>n.name==="test")}}});var up=d(()=>{"use strict";p();Vt();Pr();wo();Ar();Mr();Rn();_n();On();$e();xn();Jo();An();ts();cs();ps()});var Ps=d(()=>{"use strict";p();up()});function fp(t,e){return{identifier:e?.identifier??new rr,featureMap:e?.featureDetection===!1?new Map:Pe(t.nodes,e?.featureDetection??void 0)}}function mp(t,e,n,r,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new Fe(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,l,u)=>{if(!u)return!0;if(!a.updateAffectedSymbols(c,u))return!1;if(l>0){let f=n.get(c.path);if(f)return r(f),!1}return o(c),!0},{direction:"incoming"})}}function Rs(t,e,n){let{identifier:r,featureMap:o}=fp(t,n),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return mp(t,e,o,i=>s.add(i.tag),i=>{if(r.isTestNode(i))for(let a of Cr(i.tags))s.add(a)}),Array.from(s)}function As(t,e,n){let{identifier:r,featureMap:o}=fp(t,n),s=new Set;return mp(t,e,o,()=>{},i=>{r.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var dp=d(()=>{"use strict";p();Ps();xe();Ns()});var gp=d(()=>{"use strict";p();pp();Ns();dp()});import vN from"crypto";import ox from"fs";import sx from"os";import Ae from"path";async function B(t,e,n=null,r={}){let o=r.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=Ae.resolve(t);return await new Te(s,n,r.pathAliases?new ie(s,{pathAliases:r.pathAliases}):void 0,o,r.gitStats??!1,r.coverageMap??new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[],r.docFiles??null).build(e)}function ix(t){let e=Number.parseInt(process.env.MOKOSH_WORKSPACE_CONCURRENCY??"",10),n=Number.isFinite(e)&&e>0?e:sx.cpus().length||1;return Math.max(1,Math.min(n,Math.max(1,t)))}function ax(t,e,n){let r=new Map(e.map(s=>[s.name,[]])),o=[...e].sort((s,i)=>i.root.length-s.root.length);for(let s of n){if(!s.endsWith(".md")&&!s.endsWith(".mdx"))continue;let i=Ae.join(t,s),a=o.find(c=>i===c.root||i.startsWith(`${c.root}${Ae.sep}`));a&&r.get(a.name)?.push(i)}return r}async function Ls(t,e={}){let n=Ae.resolve(t),r=e.layout??Lt(n),o=e.projectFiles??z(n),s=e.additionalIgnoreDirs??[],i=e.packages?r.packages.filter(k=>e.packages?.includes(k.name)||e.packages?.includes(k.relativeRoot)):r.packages,a=new Map(r.packages.map(k=>[k.name,k.root])),c=new It(n,r.type),l=new Ee(s),u=ax(n,i,o),f=ix(i.length),h=f>1?!1:e.parallelParsing??!0,y=new Array(i.length),b=0,v=async()=>{for(let k=b++;k<i.length;k=b++){let E=i[k],A=e.silent?void 0:N=>{process.stderr.write(`[${E.name}] Processed ${N} files...\r`)},G=new Te(n,e.previousWorkspace?.packages.get(E.name)?.graph??null,new ie(n,{workspaceMap:a,tsconfigSearchPaths:[E.root,n],pathAliases:e.pathAliases,langResolvers:hn({jvm:l})}),A,e.gitStats??!1,new Map,h,s,u.get(E.name)??[]);y[k]=await G.build(E.entryPoints)}};return await Promise.all(Array.from({length:f},v)),i.forEach((k,E)=>{c.addPackage(k,y[E])}),c.annotateCrossPackageEdges(),c}function z(t,e={}){let n=[],r=new Set([...e.ignoreDirs??$,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Fr,...e.additionalExtensions??[]]);function s(i){try{let a=ox.readdirSync(i,{withFileTypes:!0});for(let c of a){let l=Ae.join(i,c.name);c.isDirectory()?r.has(c.name)||s(l):c.isFile()&&o.has(Ae.extname(c.name).toLowerCase())&&n.push(Ae.relative(t,l))}}catch{}}return s(t),n}var w=d(()=>{"use strict";p();Er();Y();mi();gi();Vt();Pr();Ar();Mr();ol();Rn();_n();On();mn();$e();Ln();Jo();al();An();ul();ts();cs();Bn();ps();_e();ht();zl();xe();gp();Y();Ps();vo()});var Is=d(()=>{"use strict";p();Y()});import _t from"path";import{parseArgs as cx}from"util";function lx(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return _t.resolve(t[e+1]);return process.cwd()}function J(t){return t?parseInt(t,10):void 0}function hp(t){return t?t.split(",").map(e=>e.trim()):void 0}function px(t){return t==="src"||t==="tests"||t==="all"?t:void 0}function fx(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r!==void 0)if(!r.startsWith("--"))e.push(r);else if(ux.has(r)){let o=t[n+1];o!==void 0&&!o.startsWith("--")&&(e.push(r,o),n++)}else r.slice(2)in Ms&&e.push(r)}return e}function mx(t){return{mermaid:t.mermaid??!1,proposeTags:t["propose-tags"]??!1,plain:t.plain??!1,affectedTests:t["affected-tests"]??!1,detectFeatures:t["detect-features"]??!1,findUnused:t["find-unused"]??!1,excludeTests:t["exclude-tests"]??!1,checkCycles:t["check-cycles"]??!1,checkDocDrift:t["check-doc-drift"]??!1,findUncovered:t["find-uncovered"]??!1}}function dx(t){return{listTags:t["list-tags"]??!1,callers:t.callers??!1,silent:t.silent??!1,queryHelp:t["query-help"]??!1,typeGraph:t["type-graph"]??!1,moduleResponsibility:t["module-responsibility"]??!1,featureGraph:t["feature-graph"]??!1,callGraph:t["call-graph"]??!1,findSymbol:t["find-symbol"]??!1,apiSurface:t["api-surface"]??!1}}function gx(t){return{applyTags:t["apply-tags"]??!1,dryRun:t["dry-run"]??!1,initSkill:t["init-skill"]??!1,initConfig:t["init-config"]??!1,force:t.force??!1,dependencies:t.dependencies??!1,dependents:t.dependents??!1,affected:t.affected??!1,testsOnly:t["tests-only"]??!1,cached:t.cached??!1}}function hx(t){return{withMeta:t["with-meta"]??!1,withEdgeDetail:t["with-edge-detail"]??!1,findComplexFunctions:t["find-complex-functions"]??!1,findDuplicates:t["find-duplicates"]??!1,findRiskHotspots:t["find-risk-hotspots"]??!1,workspacePackages:t["workspace-packages"]??!1,workspaceAffected:t["workspace-affected"]??!1,clearCache:t["clear-cache"]??!1,slim:t.slim??!1,watch:t.watch??!1}}function yp(t){let e=lx(t),n=_t.join(_t.resolve(e,ue),Ge),{values:r,positionals:o}=cx({args:fx(t),allowPositionals:!0,options:Ms}),s=r.cache,i=r.config,a=r.metric,c=r;return{rootDir:e,cachePath:s?_t.resolve(e,s):n,configPath:i?_t.resolve(e,i):void 0,query:r.query,file:r.file,packageName:r.package,typeFilter:r.type,functionName:r.function,filterPaths:hp(r.paths),featureThreshold:J(r["feature-threshold"]),minOutDegree:J(r["min-out-degree"]),...mx(c),...dx(c),help:t.length===0||(r.help??!1),...gx(c),changedSymbols:hp(r["changed-symbols"]),depth:J(r.depth),...hx(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:J(r["complexity-threshold"]),limit:J(r.limit),minDuplicateLines:J(r["min-duplicate-lines"]),tagKind:r["tag-kind"],tagPrefix:r["tag-prefix"],tagMinCount:J(r["tag-min-count"]),tagLimit:J(r["tag-limit"]),dupQuery:r["dup-query"],dupSlim:!(r["dup-full"]??!1),includeGenerated:r["include-generated"]??!1,includeSameFile:r["include-same-file"]??!1,includeSvgMarkup:r["include-svg-markup"]??!1,includeDocs:r["include-docs"]??!1,duplicateScope:px(r.scope),maxCoveragePct:J(r["max-coverage-pct"]),minChurn:J(r["min-churn"]),base:r.base,compareBranches:r["compare-branches"],compareFull:r["compare-full"]??!1,compareMaxItems:J(r["compare-max-items"]),entryPoints:o}}var Ms,ux,xp=d(()=>{"use strict";p();Is();Ms={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},package:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},"tag-kind":{type:"string"},"tag-prefix":{type:"string"},"tag-min-count":{type:"string"},"tag-limit":{type:"string"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"dup-query":{type:"string"},"dup-full":{type:"boolean"},"include-generated":{type:"boolean"},"include-same-file":{type:"boolean"},"include-svg-markup":{type:"boolean"},"include-docs":{type:"boolean"},scope:{type:"string"},"find-risk-hotspots":{type:"boolean"},"max-coverage-pct":{type:"string"},"min-churn":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"},base:{type:"string"},"compare-branches":{type:"string"},"compare-full":{type:"boolean"},"compare-max-items":{type:"string"}},ux=new Set(Object.entries(Ms).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function _s(t){let{graph:e,file:n,testsOnly:r,changedSymbols:o,cached:s,withMeta:i}=t;n||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=u=>i?u.map(f=>({path:f,...De(e,f)})):u;if(s){let u=Lr(e),f=Ir(u,n),h=r?f.filter(b=>e.nodes.get(b)?.category==="test"):f,y=a(h);console.log(JSON.stringify({file:n,affected:y,count:y.length},null,2));return}let c=_o(e,n,{testsOnly:r,changedSymbols:o}),l=a(c);console.log(JSON.stringify({file:n,affected:l,count:l.length},null,2))}var bp=d(()=>{"use strict";p();w()});import Os from"path";function Le(t){return t.filter(e=>{let n=Os.basename(e).toLowerCase();return yx.some(r=>n.includes(r))})}function or(t,e){return new Xt().getChangedFiles(t,e).map(n=>Os.relative(t,Os.resolve(t,n)))}var yx,sr=d(()=>{"use strict";p();Or();yx=[".test.",".spec.","-test.","-spec."]});async function Sp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s,base:i}=t,a=or(n,i);if(![...e.nodes.values()].some(u=>Le([u.path]).length>0)){let u=z(n,r);e=await B(n,Le(u),e,F(s))}let l=As(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(l.join(`
|
|
61
|
+
`))}var kp=d(()=>{"use strict";p();w();sr()});async function Cp(t){let{graph:e,rootDir:n,entryPoints:r}=t,o=r.length?r:Dr(e,n);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=Nr(e,o);console.log(JSON.stringify(s,null,2))}var vp=d(()=>{"use strict";p();w()});async function wp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=z(n,r);e=await B(n,Le(c),e,F(i))}let a=await Ds(e,n,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Ep=d(()=>{"use strict";p();w();sr()});async function Tp(t){let{graph:e,functionName:n}=t;n||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let r=Rr(e,n);console.log(JSON.stringify(r,null,2))}var Fp=d(()=>{"use strict";p();w()});async function Gs(t){let{graph:e,file:n,plain:r,depth:o,withEdgeDetail:s}=t;n||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=Oo(e,n,{depth:o??1,withEdgeDetail:s});console.log(r?i.map(a=>a.file).join(`
|
|
62
|
+
`):JSON.stringify({file:n,callers:i,count:i.length},null,2))}var Dp=d(()=>{"use strict";p();w()});async function js(t){let{graph:e}=t,n=e.findCycles();if(n.length>0){process.stderr.write(`Found ${n.length} cycle(s):
|
|
63
|
+
`);for(let r of n)process.stderr.write(` ${r.join(" \u2192 ")}
|
|
64
|
+
`);process.exit(1)}console.log("No cycles detected.")}var Np=d(()=>{"use strict";p()});async function $s(t){let{graph:e}=t;if(!$o(e)){process.stderr.write(`Warning: no git-stats data \u2014 rebuild with --git-stats (or config equivalent). Doc drift cannot be detected.
|
|
65
|
+
`),console.log("No doc drift detected.");return}let n=[...e.nodes.values()].filter(r=>r.type==="markdown"&&r.staleFor&&r.staleFor.length>0).map(r=>({doc:r.path,staleFor:r.staleFor}));if(n.length>0){process.stderr.write(`Found ${n.length} doc(s) that may be out of date:
|
|
66
|
+
`);for(let{doc:r,staleFor:o}of n)process.stderr.write(` ${r} \u2014 references changed more recently: ${o.join(", ")}
|
|
67
|
+
`);process.exit(1)}console.log("No doc drift detected.")}var Pp=d(()=>{"use strict";p();w()});import ir from"fs";import Ws from"path";function Rp(t){let e=Ws.dirname(t),n=Ws.join(e,be),r=Ws.join(e,ft),o=!1;for(let s of[t,n])ir.existsSync(s)&&(ir.unlinkSync(s),console.log(`Cache cleared: ${s}`),o=!0);ir.existsSync(r)&&(ir.rmSync(r,{recursive:!0,force:!0}),console.log(`Cache cleared: ${r}`),o=!0),o||console.log(`No cache file present at ${t}`)}var Ap=d(()=>{"use strict";p();w()});async function Lp(t){let{graph:e,rootDir:n,compareBranches:r,rawConfig:o}=t;if(!r){console.error("Error: --compare-branches requires a base ref, e.g. --compare-branches main"),process.exit(1);return}let s=await Ho(n,r,e,{entryPoints:t.entryPoints,minDuplicateLines:t.minDuplicateLines,complexityMetric:t.metric,complexityThreshold:t.complexityThreshold,maxCoveragePct:t.maxCoveragePct,...F(o)}),i=t.compareFull?s:Uo(s,{metric:t.metric,maxItems:t.compareMaxItems});console.log(JSON.stringify(i,null,2))}var Ip=d(()=>{"use strict";p();w()});async function zs(t){let{graph:e,file:n,depth:r,withMeta:o}=t;n||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=Mo(e,n,r??1),i=o?s.map(a=>({...a,...De(e,a.path)})):s;console.log(JSON.stringify({file:n,dependencies:i},null,2))}var Mp=d(()=>{"use strict";p();w()});async function Bs(t){let{graph:e,file:n,withMeta:r}=t;n||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=Dt(e,n),s=r?o.map(i=>({...i,...De(e,i.path)})):o;console.log(JSON.stringify({file:n,dependents:s},null,2))}var _p=d(()=>{"use strict";p();w()});async function Op(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=z(n,r);e=await B(n,c,e,F(s))}let i=Pe(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,l)=>l.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var Gp=d(()=>{"use strict";p();w()});async function jp(t){let{graph:e}=t,{rootDir:n,scanOptions:r,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=z(n,r);e=await B(n,c,e,F(s))}let i=Nt(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var $p=d(()=>{"use strict";p();w()});async function Us(t){let{graph:e,metric:n,complexityThreshold:r,limit:o}=t,s=r??10,i=rt(e,{metric:n,threshold:s,limit:o});console.log(JSON.stringify({metric:n??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var Wp=d(()=>{"use strict";p();w()});import ar from"path";async function Hs(t){let{graph:e,rootDir:n,scanOptions:r,minDuplicateLines:o,includeGenerated:s,includeSameFile:i,includeSvgMarkup:a,includeDocs:c,duplicateScope:l,dupQuery:u,dupSlim:f,limit:h,cachePath:y}=t,b=o??6,v=[...r.ignoreDirs??$,...r.additionalIgnoreDirs??[]],k=ar.join(ar.dirname(y),be),E=Ze(k),A=u?Xe(u):void 0,G=A?Number.MAX_SAFE_INTEGER:h,N={minLines:b,limit:G,ignoreDirs:v,includeGenerated:s||t.rawConfig.duplication?.includeGenerated||!1,includeSameFile:i||t.rawConfig.duplication?.includeSameFile||!1,includeSvgMarkup:a||t.rawConfig.duplication?.includeSvgMarkup||!1,includeDocs:c||t.rawConfig.duplication?.includeDocs||!1,scope:l??t.rawConfig.duplication?.scope,ignoreGlobs:t.rawConfig.duplication?.ignoreGlobs??[]},U=ar.join(ar.dirname(y),Tr),ct={minLines:b,ignoreLiterals:!0,maxPunctuationRatio:.5,limit:h??50,scope:N.scope,includeGenerated:N.includeGenerated,includeSameFile:N.includeSameFile,includeSvgMarkup:N.includeSvgMarkup,includeDocs:N.includeDocs,ignoreDirs:v,ignoreGlobs:N.ignoreGlobs},te=A===void 0,V=te?vn(e.nodes.values()):"",ce=te?wn(ct):"",Ie=te?En(U,V,ce):null,j,H;Ie?{groups:j,clusters:H}=Ie:({groups:j,clusters:H}=await nt(e,n,{...N,...u!==void 0&&{filter:u},tokenCache:E}),qe(E,k),te&&Tn(U,V,ce,j,H));let Gt=Fn(j),pr=A?.limit??h??50,lt=A?Sn(j,{...A,limit:pr}):j,jt=H.slice(0,pr),he=f?lt.map(Nn):lt,S=f?jt.map(Pn):jt;console.log(JSON.stringify({minLines:b,...u!==void 0&&{filter:u},summary:Gt,groups:he,count:he.length,clusters:S},null,2))}var zp=d(()=>{"use strict";p();w()});async function Ks(t){let{graph:e,metric:n,complexityThreshold:r,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!ge(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let a=r??10,c=o??50,l=s??0,{hotspots:u,count:f,churnDataAvailable:h}=ot(e,{metric:n,minComplexity:a,maxCoveragePct:c,minChurn:l,limit:i});console.log(JSON.stringify({metric:n??"cognitiveComplexity",minComplexity:a,maxCoveragePct:c,minChurn:l,churnDataAvailable:h,hotspots:u,count:f},null,2))}var Bp=d(()=>{"use strict";p();w()});async function Up(t){let{graph:e,functionName:n,plain:r}=t;n||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=Vo(e,n);console.log(r?o.map(s=>s.path).join(`
|
|
68
|
+
`):JSON.stringify({name:n,matches:o,count:o.length},null,2))}var Hp=d(()=>{"use strict";p();w()});async function Js(t){let{graph:e,featureThreshold:n,rawConfig:r,plain:o}=t,s=n??r.coverageThreshold??80;if(!ge(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
|
|
69
|
+
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var Kp=d(()=>{"use strict";p();w()});import xx from"path";function Sx(t){let e=xx.basename(t).toLowerCase();return bx.some(n=>e.includes(n))}async function Jp(t){let{graph:e,rootDir:n,scanOptions:r,excludeTests:o}=t,s=z(n,r),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!Sx(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var bx,Vp=d(()=>{"use strict";p();w();bx=[".test.",".spec.","-test.","-spec.",".stories."]});async function Vs(t){let{graph:e,packageOf:n,queryStr:r,mermaidOutput:o,slim:s}=t,i=e.serialize();if(r){let l=Hn(r);i=Un(i,l,{packageOf:n})}if(o){let l=_.deserialize(i);console.log(Jt.serialize(l));return}let a=e.findCycles();a.length>0&&(i.cycles=a);let c=fo(e);console.log(JSON.stringify(s?{...Go(i),languageCoverage:c}:{...i,languageCoverage:c},null,2))}var Qp=d(()=>{"use strict";p();w()});import kx from"fs";import Qs from"path";function cr(t,e,n){let r=t;for(let o=0;o<6;o++){let s=Qs.join(r,"templates",...e);if(kx.existsSync(Qs.join(s,n)))return s;let i=Qs.dirname(r);if(i===r)break;r=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Ys=d(()=>{"use strict";p()});import Yp from"fs";import Xp from"path";function Zp(t,e=process.cwd()){let n=cr(m,["config"],"mokosh.config.js"),r=Xp.join(n,"mokosh.config.js"),o=Xp.join(e,"mokosh.config.js");if(Yp.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}Yp.copyFileSync(r,o),console.log("wrote mokosh.config.js")}var qp=d(()=>{"use strict";p();Ys()});import Xs from"fs";import lr from"path";function eu(t,e=process.cwd()){let n=cr(m,["skill"],"SKILL.md");for(let r of Cx){let o=lr.join(n,r.templateFile),s=lr.join(e,...r.destPath),i=lr.join(...r.destPath);if(Xs.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Xs.mkdirSync(lr.dirname(s),{recursive:!0}),Xs.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Cx,tu=d(()=>{"use strict";p();Ys();Cx=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function Zs(t){let{graph:e,plain:n,tagKind:r,tagPrefix:o,tagMinCount:s,tagLimit:i}=t,a=Zo(Xo([e]),{kind:r,prefix:o,minCount:s,limit:i});console.log(n?a.tags.map(c=>c.name).join(`
|
|
70
|
+
`):JSON.stringify(a,null,2))}var nu=d(()=>{"use strict";p();w()});async function ru(t){let{graph:e,filterPaths:n,minOutDegree:r}=t,o=Ko(e,r!==void 0?{minOutDegree:r}:void 0);if(n?.length){let s=n.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var ou=d(()=>{"use strict";p();w()});async function su(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,plain:s,rawConfig:i,base:a}=t;s||console.log("Proposing test tags based on git diff...");let c=or(n,a);if(e.nodes.size===0){let u=z(n,r);e=await B(n,Le(u),e,F(i))}let l=Rs(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?l.join(" "):JSON.stringify({proposedTags:l},null,2))}var iu=d(()=>{"use strict";p();w();sr()});async function au(t){let{graph:e,typeFilter:n}=t,r=qo(e);if(n){let o=es(r,n);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(r.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var cu=d(()=>{"use strict";p();w()});function lu(t,e){let n=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:n,count:n.length},null,2))}var pu=d(()=>{"use strict";p()});function uu(t){console.log(JSON.stringify(jo(t),null,2))}var fu=d(()=>{"use strict";p();w()});import qs from"path";function vx(t,e,n,r){return t!==e?t:n?qs.resolve(r,n):e}function mu(t){let{rootDir:e,entryPoints:n,cachePath:r,configPath:o}=t,s=o?Oe(o,{isExplicitPath:!0}):Oe(e),i=qs.join(qs.resolve(e,ue),Ge),a=n.length>0?n:s.entryPoints??[],c=vx(r,i,s.cachePath,e),l={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:l,rawConfig:s}}var du=d(()=>{"use strict";p();w();Is()});import Ot from"fs";import wx from"path";function gu(t){if(!Ot.existsSync(t))return null;let e=Ot.readFileSync(t,"utf-8");return _.deserialize(JSON.parse(e))}function ei(t,e){let n=wx.dirname(e);Ot.existsSync(n)||Ot.mkdirSync(n,{recursive:!0}),Ot.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function ti(t,e,n,r={silent:!1,...F(void 0)}){return B(t,e,n,r)}var hu=d(()=>{"use strict";p();w()});var yu,xu,bu=d(()=>{"use strict";p();yu=`
|
|
61
71
|
Usage: mokosh [options] <entry-point1> <entry-point2> ...
|
|
62
72
|
|
|
63
73
|
Options:
|
|
@@ -77,10 +87,19 @@ Options:
|
|
|
77
87
|
--find-unused Find files that are not reachable from entry points
|
|
78
88
|
--exclude-tests Exclude test files from --find-unused output
|
|
79
89
|
--find-uncovered List non-test files whose coverage is below the threshold (requires coverageReportPath in config)
|
|
80
|
-
--list-tags
|
|
81
|
-
|
|
90
|
+
--list-tags Bounded tag inventory (always <=250 tags): by default the
|
|
91
|
+
query-meaningful kinds (comment-marker, import) with count>=2,
|
|
92
|
+
top 50, plus a byKind histogram. Use --plain for a bare name list
|
|
93
|
+
--tag-kind <k|all> --list-tags: restrict to one kind (comment-marker|import|function|
|
|
94
|
+
variable|library) or all
|
|
95
|
+
--tag-prefix <s> --list-tags: case-insensitive substring match on the tag name
|
|
96
|
+
--tag-min-count <N> --list-tags: min node count per tag (default: 2)
|
|
97
|
+
--tag-limit <N> --list-tags: max tags to print (default: 50; hard-capped at 250)
|
|
82
98
|
--callers List files whose exported functions call into --file
|
|
83
99
|
--file <path> Target file for --callers/--dependencies/--dependents/--affected/--workspace-affected
|
|
100
|
+
--package <name> On a monorepo root (with no entry points given): narrow every
|
|
101
|
+
command to this one package. Omit to run across the whole
|
|
102
|
+
flattened workspace (see --workspace-packages for the names)
|
|
84
103
|
--check-cycles Check for circular dependencies; exits non-zero if found (CI gate)
|
|
85
104
|
--check-doc-drift Flag markdown docs whose referenced files changed more recently
|
|
86
105
|
than the doc itself; exits non-zero if found (CI gate; requires
|
|
@@ -122,11 +141,31 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
|
|
|
122
141
|
--complexity-threshold <N> Minimum score to include (default: 10, use with --find-complex-functions)
|
|
123
142
|
--limit <N> Max results for --find-complex-functions/--find-duplicates
|
|
124
143
|
--find-duplicates Find duplicated code blocks (token-based, works for every parsed
|
|
125
|
-
language), largest-first. Lock files
|
|
126
|
-
directory (--config's ignoreDirs, merged with the defaults)
|
|
127
|
-
always excluded
|
|
144
|
+
language), largest-first. Lock files, files under an ignored
|
|
145
|
+
directory (--config's ignoreDirs, merged with the defaults), and
|
|
146
|
+
generated / vendored files are always excluded
|
|
128
147
|
--min-duplicate-lines <N> Minimum duplicated block size in lines to report (default: 6,
|
|
129
148
|
use with --find-duplicates)
|
|
149
|
+
--include-generated Scan generated / vendored files too (protobuf output, *.generated.*,
|
|
150
|
+
generated/ & __snapshots__/ dirs, *.snap, @generated-marked
|
|
151
|
+
files); use with --find-duplicates
|
|
152
|
+
--include-same-file Include matches where every occurrence is in one file (default:
|
|
153
|
+
excluded \u2014 usually a file's own repetitive shape, not copy-paste);
|
|
154
|
+
use with --find-duplicates
|
|
155
|
+
--include-svg-markup Include matches whose occurrences are all inline SVG / SVG-shaped
|
|
156
|
+
JSX markup (default: excluded \u2014 two different icons share a
|
|
157
|
+
literal-normalized skeleton); use with --find-duplicates
|
|
158
|
+
--include-docs Include markdown-family matches (default: excluded \u2014 mirrored
|
|
159
|
+
prose docs, README \u2194 *.mdx); use with --find-duplicates
|
|
160
|
+
--scope <src|tests|all> Which duplicates to surface by test-file involvement (default:
|
|
161
|
+
src \u2014 drops test clusters). tests = only substantive shared
|
|
162
|
+
test-logic clusters; all = everything. Use with --find-duplicates
|
|
163
|
+
--dup-query "<k:v,...>" Filter --find-duplicates results (AND across keys): path / allPaths
|
|
164
|
+
/ family / type / kind / defKind / minLines / maxLines / minScore
|
|
165
|
+
/ maxScore / minOccurrences / crossFile / signal, plus sort
|
|
166
|
+
(lines|score|occurrences) / sortDir / limit. Unknown keys error.
|
|
167
|
+
--dup-full Print full --find-duplicates groups/clusters (source text +
|
|
168
|
+
per-occurrence metadata). Default is the compact shape.
|
|
130
169
|
--find-risk-hotspots List functions that are complex, undertested, and (if gitStats is
|
|
131
170
|
enabled) frequently changed \u2014 requires coverageReportPath in config
|
|
132
171
|
--max-coverage-pct <N> Max file coverage % to include (default: 50, use with --find-risk-hotspots)
|
|
@@ -157,9 +196,13 @@ Notes:
|
|
|
157
196
|
pass/fail exit code, is useful to an AI assistant deciding which docs to fix.
|
|
158
197
|
--config files may be .js/.cjs and are executed for CLI convenience (allowJs: true); the MCP
|
|
159
198
|
server only loads JSON config (allowJs: false) for security. This is intentional.
|
|
160
|
-
--workspace-packages/--workspace-affected require explicit opt-in
|
|
161
|
-
|
|
162
|
-
|
|
199
|
+
--workspace-packages/--workspace-affected require explicit opt-in and build a WorkspaceGraph
|
|
200
|
+
directly. Every other command, given no entry points on a detected monorepo root, runs against
|
|
201
|
+
the whole workspace flattened into one Graph (WorkspaceGraph.flatten() \u2014 every package's own
|
|
202
|
+
nodes in one namespace, cross-package edges intact), so blast radius, call graphs and --query
|
|
203
|
+
span package boundaries and results report each node's package. Pass --package <name> to narrow
|
|
204
|
+
to one package, or --entry explicitly for whole-repo-from-these-entry-points behavior.
|
|
205
|
+
`,xu=`
|
|
163
206
|
Query filter reference (--query "key:value,key:value,...")
|
|
164
207
|
All keys are case-insensitive. Multiple keys are AND'd together.
|
|
165
208
|
|
|
@@ -182,6 +225,11 @@ FILTERING
|
|
|
182
225
|
path:<substr> File path contains substring. Negate with !.
|
|
183
226
|
Examples: path:src/api path:!__tests__
|
|
184
227
|
|
|
228
|
+
package:<value> Exact match on the owning workspace package name. Negate with !.
|
|
229
|
+
Monorepo roots only \u2014 on a monorepo, --query runs across the whole
|
|
230
|
+
workspace and every node reports its package; elsewhere this is a no-op.
|
|
231
|
+
Examples: package:@org/app package:!@org/legacy
|
|
232
|
+
|
|
185
233
|
external:<bool> true = node has at least one external (node_modules) import.
|
|
186
234
|
Example: external:true
|
|
187
235
|
|
|
@@ -282,5 +330,5 @@ COMMON PATTERNS
|
|
|
282
330
|
|
|
283
331
|
Large TypeScript logic files:
|
|
284
332
|
--query "type:typescript,category:logic,sort:size,limit:5"
|
|
285
|
-
`});var
|
|
333
|
+
`});var Su,ku=d(()=>{"use strict";p();Su=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Ex from"fs";function Cu(t,e,n){let r=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await n()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Ex.watch(t,{recursive:!0},(c,l)=>{!l||Su.test(l)||(r&&clearTimeout(r),r=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{r&&clearTimeout(r),a?.close(),process.exit(0)})}var vu=d(()=>{"use strict";p();ku()});function Fx(t){t.help&&(console.log(yu),process.exit(0)),t.queryHelp&&(console.log(xu),process.exit(0)),t.initSkill&&(eu(t.force),process.exit(0)),t.initConfig&&(Zp(t.force),process.exit(0)),t.clearCache&&(Rp(t.cachePath),process.exit(0))}async function Dx(t,e,n){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let r=await Ls(n,F(e.rawConfig));return t.workspacePackages?uu(r):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),lu(r,t.file)),!0}async function Nx(t,e,n){let r=await Ls(n,F(e.rawConfig));if(t.packageName){let o=r.packages.get(t.packageName);return o||(console.error(`Error: unknown package "${t.packageName}". Run --workspace-packages to list packages.`),process.exit(1)),{graph:o.graph,packageOf:new Map}}return t.file&&!r.getPackageForFile(t.file)&&(console.error(`Error: no workspace package owns "${t.file}".`),process.exit(1)),r.flatten()}function Px(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.findRiskHotspots||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface||!!t.compareBranches}function Rx(t){let n=[{name:"--propose-tags",flag:t.proposeTags,handler:su},{name:"--apply-tags",flag:t.applyTags,handler:wp},{name:"--affected-tests",flag:t.affectedTests,handler:Sp},{name:"--detect-features",flag:t.detectFeatures,handler:Op},{name:"--find-unused",flag:t.findUnused,handler:Jp},{name:"--check-cycles",flag:t.checkCycles,handler:js},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:$s},{name:"--find-uncovered",flag:t.findUncovered,handler:Js},{name:"--list-tags",flag:t.listTags,handler:Zs},{name:"--callers",flag:t.callers,handler:Gs},{name:"--dependencies",flag:t.dependencies,handler:zs},{name:"--dependents",flag:t.dependents,handler:Bs},{name:"--affected",flag:t.affected,handler:_s},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:Us},{name:"--find-duplicates",flag:t.findDuplicates,handler:Hs},{name:"--find-risk-hotspots",flag:t.findRiskHotspots,handler:Ks},{name:"--type-graph",flag:t.typeGraph,handler:au},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:ru},{name:"--feature-graph",flag:t.featureGraph,handler:jp},{name:"--call-graph",flag:t.callGraph,handler:Tp},{name:"--find-symbol",flag:t.findSymbol,handler:Up},{name:"--api-surface",flag:t.apiSurface,handler:Cp},{name:"--compare-branches",flag:!!t.compareBranches,handler:Lp}].filter(r=>r.flag);return n.length>1&&(console.error(`Error: conflicting flags: ${n.map(r=>r.name).join(", ")} (pass only one command flag)`),process.exit(1)),n[0]?.handler??Vs}async function Ax(t,e,n,r,o,s,i){Tx.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --find-risk-hotspots, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),Cu(n,300,async()=>{let a=await ti(n,r,e.graph,{silent:s,...F(i)});ei(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function wu(){let t=process.argv.slice(2),e=yp(t);Fx(e);let n=mu(e);wr(n.rawConfig);let{rootDir:r,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=n;if(await Dx(e,n,r))return;let a=Px(e),c=o.length===0&&Lt(r).type!=="none",l,u=new Map;c?(e.watch&&(console.error("Error: --watch is not supported on a monorepo root (use --package/--file with a single package instead)"),process.exit(1)),{graph:l,packageOf:u}=await Nx(e,n,r)):(l=gu(s)??new _(new Map),(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),l=await ti(r,o,l,{silent:e.silent,...F(n.rawConfig)}),ei(l,s)));let f={graph:l,packageOf:u,rootDir:r,cachePath:s,entryPoints:o.map(y=>y.replace(`${r}/`,"")),scanOptions:i,rawConfig:n.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,tagKind:e.tagKind,tagPrefix:e.tagPrefix,tagMinCount:e.tagMinCount,tagLimit:e.tagLimit,minDuplicateLines:e.minDuplicateLines,dupQuery:e.dupQuery,dupSlim:e.dupSlim,includeGenerated:e.includeGenerated,includeSameFile:e.includeSameFile,includeSvgMarkup:e.includeSvgMarkup,includeDocs:e.includeDocs,duplicateScope:e.duplicateScope,maxCoveragePct:e.maxCoveragePct,minChurn:e.minChurn,base:e.base,compareBranches:e.compareBranches,compareFull:e.compareFull,compareMaxItems:e.compareMaxItems},h=Rx(e);if(e.watch){await Ax(h,f,r,o,s,e.silent,n.rawConfig);return}await h(f)}var Tx,Eu=d(()=>{"use strict";p();w();xp();bp();kp();vp();Ep();Fp();Dp();Np();Pp();Ap();Ip();Mp();_p();Gp();$p();Wp();zp();Bp();Hp();Kp();Vp();Qp();qp();tu();nu();ou();iu();cu();pu();fu();du();hu();bu();vu();Tx=new Set([Vs,Gs,zs,Bs,_s,Js,Us,Hs,Ks,js,$s,Zs])});var Lx=Fu(()=>{p();Eu();wu().catch(t=>{console.error(t),process.exit(1)})});export default Lx();
|
|
286
334
|
//# sourceMappingURL=cli.mjs.map
|