@omfalos/mokosh 0.5.0 → 0.5.1

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/mcp.js CHANGED
@@ -1,53 +1,57 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var fa=Object.create;var ot=Object.defineProperty;var ma=Object.getOwnPropertyDescriptor;var ga=Object.getOwnPropertyNames;var da=Object.getPrototypeOf,ha=Object.prototype.hasOwnProperty;var ya=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},Wn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ga(e))!ha.call(t,s)&&s!==r&&ot(t,s,{get:()=>e[s],enumerable:!(n=ma(e,s))||n.enumerable});return t};var g=(t,e,r)=>(r=t!=null?fa(da(t)):{},Wn(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t)),xa=t=>Wn(ot({},"__esModule",{value:!0}),t);var Ef={};ya(Ef,{createMcpServer:()=>Xt});module.exports=xa(Ef);var ua=require("@modelcontextprotocol/sdk/server/stdio.js");var pa=require("@modelcontextprotocol/sdk/server/index.js"),Zt=require("@modelcontextprotocol/sdk/types.js");var qt=g(require("fs")),Vt=g(require("path"));var pt=g(require("fs")),ar=g(require("path"));var ba=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],er=[];function it(t){er.push(t)}function $n(t){return[...ba,...er].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Sa=[".test.",".spec.","-test.","-spec."],tr=[];function at(t){tr.push(t)}function Ne(){return[...Sa,...tr]}var va=["jest","vitest","playwright","cypress","@testing-library/"],rr=[];function ct(t){rr.push(t)}function nr(){return[...va,...rr]}var Bn=.8,sr=Bn;function or(t){sr=t}function ir(){return sr}function lt(){er.length=0,tr.length=0,rr.length=0,sr=Bn}var ka=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function De(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=ar.default.resolve(t);return pt.default.existsSync(n)?n.endsWith(".json")?Hn(n):e?Un(n):{}:{}}for(let n of ka){let s=ar.default.resolve(t,n);if(pt.default.existsSync(s)){if(n.endsWith(".json"))return Hn(s);if(e)return Un(s)}}return{}}function Hn(t){return JSON.parse(pt.default.readFileSync(t,"utf-8"))}function Un(t){let e=require(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function cr(t){lt();for(let e of t.configMatchers??[])it(e);for(let e of t.testPatterns??[])at(e);for(let e of t.testLibraries??[])ct(e);t.barrelThreshold!==void 0&&or(t.barrelThreshold)}function J(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var ae="mokosh-cache",Re="duplication-tokens.json",lr="graph.json",pr="branch-graphs",P=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],ur=[".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"];var Jn=g(require("fs")),fr=g(require("path"));function mr(t,e){let r=fr.default.resolve(t,e);try{let n=Jn.default.readFileSync(r,"utf-8"),s=JSON.parse(n),o=new Map;if(typeof s!="object"||s===null)return o;for(let[i,a]of Object.entries(s)){if(i==="total")continue;let c=a?.lines?.pct;if(typeof c!="number")continue;let l=fr.default.relative(t,i);o.set(l,c)}return o}catch{return new Map}}var ut={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let s=`"${n.path}"`;for(let o of n.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${n.path} -> ${o.toPath}`;if(!r.has(a)){let c=o.isStyle?"-- styles -->":"-->";e.push(` ${s} ${c} ${i}`),r.add(a)}}}return e.join(`
3
- `)}};var gr=g(require("fs")),Kn=g(require("path"));function dr(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function qn(t,e){if(typeof t=="string")return dr(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let s=qn(r[n],e);if(s)return s}}return null}function wa(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 Ea(t,e){let r=new Set,n=new Set,s=[...e];for(;s.length;){let o=s.shift();if(n.has(o))continue;n.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.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 p of l.exports)r.add(p.name);s.push(a.toPath)}else for(let l of a.symbols)r.add(l)}}}return r}function hr(t,e){let r=[],n=Kn.default.join(e,"package.json");if(gr.default.existsSync(n))try{let s=JSON.parse(gr.default.readFileSync(n,"utf8"));if(s.exports&&typeof s.exports=="object"&&!Array.isArray(s.exports))for(let o of Object.values(s.exports)){let i=qn(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof s.exports=="string"){let o=dr(s.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[s.main,s.module].filter(Boolean)){let i=dr(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let s of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(s)){r.push(s);break}}return r}function Fa(t,e){let r=new Set(e);for(let n of e)t.traverse(n,s=>(r.add(s.path),!0),{direction:"outgoing"});return r}function Ta(t,e,r){let n=new Map;for(let s of e){if(r.includes(s))continue;let o=t.nodes.get(s);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let c=n.get(a.name),l=!!(a.signature||a.doc);(!c||l&&!i)&&n.set(a.name,{file:s,symbol:a})}}return n}function Pa(t,e,r,n){let s=[];for(let o of t){let i=e.get(o),a=n.flatMap(u=>r.nodes.get(u)?.exports??[]).find(u=>u.name===o),c=i?.symbol??a,l=i?.file??n.find(u=>r.nodes.get(u)?.exports.some(m=>m.name===o))??n[0],p={name:o,definedIn:l,kind:wa(c?.signature)};c?.doc&&(p.doc=c.doc),c?.signature&&(p.signature=c.signature),s.push(p)}return s.sort((o,i)=>o.name.localeCompare(i.name)),s}function Aa(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",s=[...e].filter(c=>!r.includes(c)&&!n(c)),o=[...t.nodes.keys()].filter(c=>!e.has(c)),i=o.filter(c=>!n(c)),a=o.filter(c=>n(c));return{internalFiles:s,unreachableFromEntry:i,testFiles:a}}function yr(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 r=Fa(t,e),n=Ta(t,r,e),s=Ea(t,e),o=Pa(s,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Aa(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:c}}function xr(t,e){let r=null,n=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from})}let s=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&s.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:s}}var Na=g(require("fs")),Da=g(require("path"));function Vn(t){let e=[...t.nodes.entries()].sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${s.mtime}:${s.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function br(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,s=>(s.path!==r&&n.push(s.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Vn(t)}}function Sr(t,e){return t.impact.get(e)??[]}var jo=g(require("path"));var ce=g(require("fs")),vr=g(require("path"));var Ie=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let s=n.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:s?.toPath??""})}return r.sort((n,s)=>s.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,s=[],o=i=>{r.add(i),n.add(i),s.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let l=s.indexOf(c.toPath);e.push([...s.slice(l),c.toPath])}else r.has(c.toPath)||o(c.toPath)}n.delete(i),s.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}};var A=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let s=e.get(n.toPath)||[];s.push(r.path),e.set(n.toPath,s)}return this._incomingEdgesCache=e,e}dfs(e,r,n,s){let o=new Set,i=n.maxDepth??1/0,a=(c,l,p)=>{if(l>i||o.has(c))return;let u=this.nodes.get(c);if(u&&(o.add(c),r(u,l,p)!==!1))for(let m of s(c))a(m,l+1,c)};a(e,0,null)}traverse(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>s==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let s=e.get(n.toFile)??[];s.push(r.path),e.set(n.toFile,s)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>s==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new Ie(this.nodes).findUnusedFiles(e)}findCycles(){return new Ie(this.nodes).findCycles()}};function ft(t){return vr.default.join(t,ae,pr)}function Qn(t,e){return vr.default.join(ft(t),`${e}.json`)}function Yn(t,e){let r=Qn(t,e);if(!ce.default.existsSync(r))return null;try{let n=ce.default.readFileSync(r,"utf-8");return A.deserialize(JSON.parse(n))}catch{return null}}function Zn(t,e,r){let n=ft(t);ce.default.existsSync(n)||ce.default.mkdirSync(n,{recursive:!0}),ce.default.writeFileSync(Qn(t,e),JSON.stringify(r.serialize()))}var xe=g(require("fs")),F=g(require("path")),yo=g(require("piscina"));var mt=require("child_process"),gt=class{getChangedFiles(e,r){try{let s=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...r?[["diff","--name-only","--end-of-options",`${r}...HEAD`]]:[]].flatMap(o=>{try{return(0,mt.execFileSync)("git",o,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
4
- `).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(s))}catch(n){return console.error("Error getting git diff:",n),[]}}},Xn="%x00%H%x09%ae%x09%at",es=256*1024*1024;function ts(t,e){let r="",n=0;for(let s of t.split(`
5
- `)){if(s.startsWith("\0")){let[,c,l]=s.slice(1).split(" ");r=c??"",n=l?Number(l)*1e3:0;continue}if(s==="")continue;let o=s.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,n)}}function rs(t){let e=new Map;try{let r=(0,mt.execFileSync)("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${Xn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:es});ts(r,(n,s,o)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:s||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=(0,mt.execFileSync)("git",["-C",t,"log","--name-status","-M",`--format=${Xn}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:es});ts(r,(n,s,o)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var Le=g(require("fs")),ns=g(require("path")),kr=require("js-yaml");var Me=["package-lock.json","yarn.lock","pnpm-lock.yaml"];function ss(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Ra(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),ss(r)}).filter(Boolean)}function Ia(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function Ma(t){try{let e=(0,kr.load)(t),r={dependencies:{}};for(let[n,s]of Object.entries(e))if(!(n==="__metadata"||!s?.version))for(let o of n.split(", ")){let i=ss(o);i&&(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}return r}catch{return null}}function La(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
6
- `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let s=n[0];if(!s||s.startsWith(" "))continue;let o=Ra(s);if(o.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of o)e.dependencies[c]={version:a}}return e}function os(t){let e=Le.default.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[s,o]of Object.entries(r.packages)){if(!s.startsWith("node_modules/"))continue;let i=s.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[s,o]of Object.entries(r.dependencies))n.dependencies[s]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return n}function is(t){let e=Le.default.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Ma(e);if(r!==null)return r}return La(e)}function as(t){let e=Le.default.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=(0,kr.load)(e);if(n.packages)for(let[s,o]of Object.entries(n.packages)){let{name:i,version:a}=Ia(s,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(n.dependencies)for(let[s,o]of Object.entries(n.dependencies)){if(r.dependencies[s])continue;let i=typeof o=="string"?o:o.version;r.dependencies[s]={version:i||""}}}catch{}return r}var _a={"package-lock.json":os,"yarn.lock":is,"pnpm-lock.yaml":as};function Cr(t){for(let e of Me){let r=ns.default.join(t,e);if(Le.default.existsSync(r))return _a[e](r)}return null}var Oe=g(require("fs")),Ge=g(require("path"));function cs(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 Ga(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=cs(e).split(":");return a.length>=3&&a[0]&&a[2]?{group:a[0],version:a[2]}:null}if(!e.startsWith("{"))return null;let r=e.match(/module\s*=\s*["']([^"']+)["']/),n=e.match(/group\s*=\s*["']([^"']+)["']/),s=r?r[1].split(":")[0]:n?.[1];if(!s)return null;let o=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:s,...i?.[1]!==void 0&&{version:i[1]},...o?.[1]!==void 0&&{versionRef:o[1]}}}function wr(t){let e=t.split(/\r?\n/).map(o=>o.replace(/#.*$/,"").trim()),r={},n="";for(let o of e){let i=o.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="versions"||!o)continue;let a=o.indexOf("=");if(a===-1)continue;let c=o.slice(0,a).trim(),l=cs(o.slice(a+1));c&&l&&(r[c]=l)}let s={};n="";for(let o of e){let i=o.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="libraries"||!o)continue;let a=o.indexOf("=");if(a===-1)continue;let c=Ga(o.slice(a+1));if(!c)continue;let l=c.versionRef?r[c.versionRef]:c.version;l&&(s[c.group]=l)}return s}function Er(t){let e={};for(let r of t.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#")||n.startsWith("empty="))continue;let o=n.split("=")[0].split(":");o.length>=3&&o[0]&&o[2]&&(e[o[0]]=o[2])}return e}function Fr(t){let e={},r=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let s=r.exec(t);s;s=r.exec(t)){let[,o,,i]=s;o&&i&&/\d/.test(i)&&(e[o]=i)}let n=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let s=n.exec(t);s;s=n.exec(t))s[1]&&s[2]&&/\d/.test(s[2])&&(e[s[1]]=s[2]);return e}function dt(t){let e={},r=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let n=r.exec(t);n;n=r.exec(t)){let[,s,,o]=n;s&&o&&(e[s]=o)}return e}var Oa=new Set(["node_modules","build",".gradle","target",".git","dist"]),ja=2;function _e(t){try{return Oe.default.existsSync(t)?Oe.default.readFileSync(t,"utf-8"):null}catch{return null}}function Tr(t){let e={},r=p=>{for(let[u,m]of Object.entries(p))!e[u]&&m&&(e[u]=m)},n=_e(Ge.default.join(t,"gradle","libs.versions.toml"));n&&r(wr(n));let s=[],o=[],i=[],a=(p,u)=>{let m;try{m=Oe.default.readdirSync(p,{withFileTypes:!0})}catch{return}for(let h of m){let y=Ge.default.join(p,h.name);if(h.isDirectory()){u<ja&&!h.name.startsWith(".")&&!Oa.has(h.name)&&a(y,u+1);continue}h.isFile()&&(h.name==="gradle.lockfile"?s.push(y):h.name==="build.gradle"||h.name==="build.gradle.kts"?o.push(y):h.name==="build.sbt"&&i.push(y))}};a(t,0);for(let p of s){let u=_e(p);u&&r(Er(u))}for(let p of o){let u=_e(p);u&&r(Fr(u))}for(let p of i){let u=_e(p);u&&r(dt(u))}try{let p=Ge.default.join(t,"project");for(let u of Oe.default.readdirSync(p,{withFileTypes:!0}))if(u.isFile()&&u.name.endsWith(".scala")){let m=_e(Ge.default.join(p,u.name));m&&r(dt(m))}}catch{}let c=Object.keys(e);if(c.length===0)return null;let l={};for(let p of c)l[p]={version:e[p]};return l}function ls(t){let e=Cr(t),r=Tr(t);return r?{...e??{dependencies:{}},jvmDependencies:r}:e}var Pr=g(require("path"));function G(t){switch(Pr.default.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 N(t){let e=Pr.default.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var us=g(require("coffeescript"));function W(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function le(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function pe(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function fs(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return W(t.value)}}function K(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function za(t,e){let r=fs(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:N(r),type:"static"}:null}function Wa(t,e){let r=e.variable?.base?.value==="require",n=fs(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:N(n),type:"require"}}function ps(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let s=K(r.variable);return s?[{name:s}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(s=>K(s.variable)??K(s)).filter(s=>!!s).map(s=>({name:s}));let n=K(r);return n?[{name:n}]:[]}function $a(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=K(t.variable)??K(t.variable?.base);return e?[{name:e}]:[]}function Ba(t,e,r,n){let s=e.constructor?.name;if(s==="ImportDeclaration"){let o=za(t,e);o&&r.push(o)}else if(s==="Call"){let o=Wa(t,e);o&&r.push(o)}else if(s==="Assign"){let o=K(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;o==="module"&&i==="exports"?n.push(...ps(e,void 0)):o==="exports"&&typeof i=="string"&&n.push(...ps(e,i))}else s==="ExportNamedDeclaration"&&e.clause?n.push(...$a(e.clause)):s==="ExportDefaultDeclaration"&&n.push({name:"default"})}function Ar(t,e,r,n){if(!(!e||typeof e!="object")){Ba(t,e,r,n);for(let s in e){if(s==="locationData")continue;let o=e[s];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)Ar(t,i,r,n);else Ar(t,o,r,n)}}}function ms(t,e){let r=le(e),n=pe(t,r),s=[],o=[];try{Ar(t,us.default.nodes(e),s,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var fe=require("@cucumber/gherkin"),hs=require("@cucumber/messages");var gs=new Map;function ue(t,e){gs.set(t,e)}function ds(t){return gs.get(t)}var Ha=hs.IdGenerator.uuid();function Nr(t,e){let r=new Set,n=s=>{for(let o of s)r.add(o.name.startsWith("@")?o.name.slice(1):o.name)};try{let s=new fe.AstBuilder(Ha),o=new fe.GherkinClassicTokenMatcher,a=new fe.Parser(s,o).parse(e);if(a.feature){n(a.feature.tags);for(let c of a.feature.children){if(c.scenario){n(c.scenario.tags);for(let l of c.scenario.examples)n(l.tags)}if(c.rule)for(let l of c.rule.children)l.scenario&&n(l.scenario.tags)}}}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}ue("gherkin",Nr);var vs=g(require("path")),ks=require("@lezer/go");function q(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function V(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
7
- `&&r++;return r}function Ua(t,e){let r=1;function n(s){switch(s.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{s.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(s.from,s.to);(i==="&&"||i==="||")&&r++;break}}let o=s.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),r}function xs(t,e,r,n){let s=r?1:1+e,o=q(t),i=r?e:e+1,a=o[1];a&&a.type.name!=="Block"&&(s+=me(a,i,!1,n));let c=o.find(p=>p.type.name==="Block");c&&(s+=me(c,i,!1,n));let l=o.findIndex(p=>p.type.name==="else");if(l>=0){let p=o[l+1];p?.type.name==="IfStatement"?s+=xs(p,e,!0,n):p&&(s+=1+me(p,e+1,!1,n))}return s}function ys(t,e,r){let n=1+e,s=t.firstChild;for(;s;)n+=me(s,e+1,!1,r),s=s.nextSibling;return n}function Ja(t,e,r){let n=0,s=t.firstChild;for(;s;)n+=me(s,e,!1,r),s=s.nextSibling;return n}function Ka(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function me(t,e,r,n){let s=t.type.name;if(s==="IfStatement")return xs(t,e,r,n);if(s==="ForStatement"||s==="SwitchStatement"||s==="SelectStatement")return ys(t,e,n);let o=s==="LogicOp"&&Ka(t,n)?1:0;return e>0&&s==="FunctionLiteral"?o+ys(t,e,n):o+Ja(t,e,n)}function qa(t,e){return me(t,0,!1,e)}function ht(t,e){return{complexity:Ua(t,e),cognitiveComplexity:qa(t,e)}}function Dr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),s=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return s?e.slice(s.from,s.to):void 0}function bs(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let s=n.node.getChild("DefName");if(s){let o=e.slice(s.from,s.to),{complexity:i,cognitiveComplexity:a}=ht(n.node,e);r.push({name:o,line:V(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let s=n.node.getChild("FieldName");if(s){let o=e.slice(s.from,s.to),i=Dr(n.node,e),a=i?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:l}=ht(n.node,e);r.push({name:a,line:V(e,n.from),complexity:c,cognitiveComplexity:l})}}while(n.next());return r}var Va=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Qa=/^\/\/go:build\s+(.+)$/,Ya=/^\/\/\s*\+build\s+(.+)$/;function Cs(t,e){let r=[],n=new Map,s=new Set,o=new Set,i=new Map,a=ks.parser.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let x=e.slice(c.from,c.to),k=x.match(Va);k?.[1]&&s.add(k[1]);let R=x.match(Qa);R&&Ss(R[1],o);let D=x.match(Ya);D&&Ss(D[1],o);break}case"ImportSpec":{let x=c.node.getChild("String");if(x){let R=e.slice(x.from,x.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:R,isExternal:!0,isStyle:!1,type:"static"});let D=c.node.getChild("DefName"),U=D?e.slice(D.from,D.to):R.split("/").pop();U&&U!=="_"&&U!=="."&&i.set(U,R)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let x=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(x){let k=e.slice(x.from,x.to);k!=="_"&&/^[A-Z]/.test(k)&&!n.has(k)&&n.set(k,{name:k})}break}}while(c.next());let l=r.some(x=>x.rawSpecifier==="testing"),p=vs.default.basename(t).endsWith("_test.go")||s.has("test")||l?"test":"logic",u=new Set([...s,...o]),{complexity:m,cognitiveComplexity:h}=ht(a.topNode,e),y=bs(a,e),v=p==="test"?[]:Za(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(u).map(x=>({name:x,kind:"comment-marker"})),category:p,rawCallEdges:v,complexity:m,cognitiveComplexity:h,...y.length>0?{functions:y}:{}}}function Za(t,e,r){let n=[];function s(i,a){if(i.type.name==="CallExpr"){let l=i.firstChild;if(l?.type.name==="SelectorExpr"){let p=l.firstChild,u=l.getChild("FieldName");if(p?.type.name==="VariableName"&&u){let m=e.slice(p.from,p.to),h=r.get(m);if(h){let y=e.slice(u.from,u.to);n.push({from:a,to:y,toSpecifier:h})}}}}let c=i.firstChild;for(;c;)s(c,a),c=c.nextSibling}let o=t.cursor();do if(o.name==="FunctionDecl"){let i=o.node.getChild("DefName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&s(a,c)}}else if(o.name==="MethodDecl"){let i=o.node.getChild("FieldName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),l=Dr(o.node,e);s(a,l?`${l}.${c}`:c)}}while(o.next());return n}function Ss(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var Xa=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,ec=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework"];function ge(t){let e=new Set;for(let r of t.matchAll(Xa))r[1]&&e.add(r[1]);return e}function $(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,r=>r.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,r=>" ".repeat(r.length)),e}function de(t){let e=$(t),r=new Set;for(let s of e.matchAll(/@([A-Z]\w*)/g))s[1]&&r.add(s[1]);let n=new Set;for(let s of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))s[1]&&n.add(s[1]);return{annotations:[...r],typeNames:[...n]}}function he(t,e){return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static"}}function B(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect"}}function I(t,e){let r=[];for(let n of $(t).split(`
8
- `)){let s=n.trim();if(!s||s.startsWith("@")||s.startsWith("*"))continue;let o=s.match(/^package\s+(?:object\s+)?([\w.]+)/);if(o?.[1]){if(r.push(o[1]),!e)break;continue}if(!(e&&/^import\s/.test(s)))break}return r.length>0?r.join("."):null}var tc=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),rc=new Set(["Composable","Preview"]),nc=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),sc=["Activity","Fragment","ViewModel","Screen","Composable"];function O(t,e,r={}){let n=t.replace(/\\/g,"/"),s=n.split("/").pop()??"";if(s.endsWith(".gradle")||s==="build.gradle.kts"||s==="settings.gradle.kts")return"config";if(/\/src\/(test|androidTest|integrationTest|it)\//.test(n)||e.some(i=>ec.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let o=r.annotations??[];return o.some(i=>tc.has(i))?"config":o.some(i=>rc.has(i))||(r.typeNames??[]).some(i=>sc.some(a=>i.endsWith(a)))?"ui":(o.some(i=>nc.has(i)),"logic")}var oc=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,ic=/^(?:@\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 ac(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function ws(t,e){let r=ge(e),s=$(e).split(`
9
- `),o=[],i=new Set;for(let l of s){let p=l.match(oc);if(p?.[2]){let m=ac(!!p[1],p[2]);m&&o.push(he(t,m));continue}let u=l.match(ic);u?.[2]&&i.add(u[2])}let a=I(e,!1);a&&o.push(B(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:O(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:de(e).annotations})}}var Ps=require("@lezer/java");var Es=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),cc=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"]);function lc(t,e){let r=1;function n(s){let o=s.type.name;if(o==="IfStatement"||o==="CatchClause"||o==="TernaryExpression")r++;else if(Es.has(o))r++;else if(o==="SwitchLabel")s.firstChild?.type.name==="case"&&r++;else if(o==="LogicOp"){let a=e.slice(s.from,s.to);(a==="&&"||a==="||")&&r++}let i=s.firstChild;for(;i;)n(i),i=i.nextSibling}return n(t),r}function Fs(t,e,r,n){let s=r?1:1+e,o=[];for(let p=t.firstChild;p;p=p.nextSibling)o.push(p);let i=r?e:e+1,a=o[1];a&&a.type.name!=="Block"&&(s+=ye(a,i,!1,n));let c=o.find(p=>p.type.name==="Block");c&&(s+=ye(c,i,!1,n));let l=o.findIndex(p=>p.type.name==="else");if(l>=0){let p=o[l+1];p?.type.name==="IfStatement"?s+=Fs(p,e,!0,n):p&&(s+=1+ye(p,e+1,!1,n))}return s}function Rr(t,e,r){let n=1+e,s=t.firstChild;for(;s;)n+=ye(s,e+1,!1,r),s=s.nextSibling;return n}function pc(t,e,r){let n=0,s=t.firstChild;for(;s;)n+=ye(s,e,!1,r),s=s.nextSibling;return n}function uc(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function ye(t,e,r,n){let s=t.type.name;if(s==="IfStatement")return Fs(t,e,r,n);if(Es.has(s)||s==="SwitchStatement"||s==="CatchClause"||s==="TernaryExpression")return Rr(t,e,n);let o=s==="LogicOp"&&uc(t,n)?1:0;return e>0&&s==="LambdaExpression"?o+Rr(t,e,n):o+pc(t,e,n)}function fc(t,e){return ye(t,0,!1,e)}function Ir(t,e){return{complexity:lc(t,e),cognitiveComplexity:fc(t,e)}}function Mr(t,e){for(let r=t.parent;r;r=r.parent)if(cc.has(r.type.name)){let n=r.getChild("Definition");if(n)return e.slice(n.from,n.to)}}function Ts(t,e){let r=[],n=t.cursor();do if(n.name==="MethodDeclaration"||n.name==="ConstructorDeclaration"){let s=n.node.getChild("Definition");if(s){let o=e.slice(s.from,s.to),i=Mr(n.node,e),a=i&&n.name==="MethodDeclaration"?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:l}=Ir(n.node,e);r.push({name:a,line:V(e,n.from),complexity:c,cognitiveComplexity:l})}}while(n.next());return r}var mc=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/;function gc(t,e){let r=t.getChild("ScopedIdentifier");if(!r)return null;let n=t.getChild("static")!=null,s=t.getChild("Asterisk")!=null,o=e.slice(r.from,r.to);return n?(s||(o=o.split(".").slice(0,-1).join(".")),o?{specifier:o,wildcard:!1}:null):s?{specifier:`${o}.*`,wildcard:!0}:{specifier:o,wildcard:!1}}function dc(t){let e=new Map;for(let r of t){if(r.type==="side-effect")continue;let n=r.rawSpecifier;if(n.endsWith(".*"))continue;let s=n.split(".").pop();s&&e.set(s,n)}return e}function hc(t,e,r){let n=[];function s(i,a){let c=i.type.name;if(c==="MethodInvocation"){let p=i.firstChild;if(p?.type.name==="Identifier"){let u=r.get(e.slice(p.from,p.to)),m=i.getChild("MethodName");u&&m&&n.push({from:a,to:e.slice(m.from,m.to),toSpecifier:u})}}else if(c==="ObjectCreationExpression"){let p=i.getChild("TypeName");if(p){let u=r.get(e.slice(p.from,p.to));u&&n.push({from:a,to:"new",toSpecifier:u})}}let l=i.firstChild;for(;l;)s(l,a),l=l.nextSibling}let o=t.cursor();do if(o.name==="MethodDeclaration"||o.name==="ConstructorDeclaration"){let i=o.node.getChild("Definition"),a=o.node.getChild("Block")??o.node.getChild("ConstructorBody");if(i&&a){let c=e.slice(i.from,i.to),l=Mr(o.node,e),p=l&&o.name==="MethodDeclaration"?`${l}.${c}`:c;s(a,p)}}while(o.next());return n}function As(t,e){let r=[],n=new Map,s=new Set,o=new Set,i;try{i=Ps.parser.parse(e)}catch{return{imports:[],exports:[],tags:[],category:O(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let y=e.slice(a.from,a.to).match(mc);y?.[1]&&s.add(y[1]);break}case"MarkerAnnotation":case"Annotation":{let y=a.node.getChild("Identifier");y&&o.add(e.slice(y.from,y.to));break}case"ImportDeclaration":{let y=gc(a.node,e);y&&r.push({fromPath:t,toPath:"",rawSpecifier:y.specifier,isExternal:!0,isStyle:!1,type:"static"});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let y=a.node.getChild("Definition");if(y){let v=e.slice(y.from,y.to);n.has(v)||n.set(v,{name:v})}}break}}while(a.next());let c=I(e,!1);c&&r.push(B(t,c));let l=O(t,r.map(y=>y.rawSpecifier),{typeNames:[...n.keys()],annotations:[...o]}),{complexity:p,cognitiveComplexity:u}=Ir(i.topNode,e),m=Ts(i,e),h=l==="test"?[]:hc(i,e,dc(r));return{imports:r,exports:Array.from(n.values()),tags:Array.from(s).map(y=>({name:y,kind:"comment-marker"})),category:l,rawCallEdges:h,complexity:p,cognitiveComplexity:u,...m.length>0?{functions:m}:{}}}var yc=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Lr="(?: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+)*",xc=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Lr}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),bc=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Lr}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Sc=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Lr}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`);function Ns(t,e){let r=ge(e),s=$(e).split(`
10
- `),o=[],i=new Set;for(let l of s){let p=l.match(yc);if(p?.[1]){o.push(he(t,p[1]));continue}let u=l.match(xc);if(u?.[2]){i.add(u[2]);continue}let m=l.match(bc);if(m?.[1]){i.add(m[1]);continue}let h=l.match(Sc);h?.[1]&&i.add(h[1])}let a=I(e,!1);a&&o.push(B(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:O(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:de(e).annotations})}}var Ds=g(require("livescript"));function Q(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function vc(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=Q(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>Q(r.key)??Q(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=Q(t);return e?[{name:e}]:[]}function kc(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=Q(r.head),o=r.tails?.[0]?.key?.name;if(n==="module"&&o==="exports")return vc(t.right);if(n==="exports"&&typeof o=="string")return[{name:o}];if(r.head?.verb==="out"&&typeof o=="string")return[{name:o}]}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=>Q(n.val)??Q(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}var Cc=new Set(["first_line","first_column","last_line","last_column","line","column"]);function wc(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let s=W(n);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:N(s),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let s=n.args?.[0]?.value;if(typeof s=="string"){let o=W(s);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"}}}}return null}function _r(t,e,r){if(!t||typeof t!="object")return[];let n=[],s=wc(t,e);s&&n.push(s),r.push(...kc(t));for(let o in t){if(Cc.has(o))continue;let i=t[o];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(..._r(a,e,r));else n.push(..._r(i,e,r))}return n}function Rs(t,e){let r=le(e),n=pe(t,r),s=[],o=[];try{s=_r(Ds.default.ast(e),t,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Is=g(require("luaparse"));function Ec(t,e){let r=[];function n(s){if(!(!s||typeof s!="object")){if((s.type==="CallExpression"||s.type==="StringCallExpression")&&s.base?.type==="Identifier"&&s.base?.name==="require"){let o;if(s.type==="CallExpression"){let i=s.arguments?.[0];i?.type==="StringLiteral"&&(o=W(i.raw))}else if(s.type==="StringCallExpression"){let i=s.argument;i?.type==="StringLiteral"&&(o=W(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:N(o),type:"require"})}for(let o in s){if(o==="loc")continue;let i=s[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Fc(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,s)=>{r.init[s]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Tc(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 s of r.fields)s.type==="TableKeyString"&&n.push({name:s.key.name});return n}function Pc(t){let e=t.body,r=Fc(e),n=Tc(e);for(let o of e)if(o.type==="FunctionDeclaration")o.identifier?.type==="MemberExpression"?o.identifier.base.type==="Identifier"&&r.has(o.identifier.base.name)&&n.push({name:o.identifier.identifier.name}):o.identifier?.type==="Identifier"&&!o.isLocal&&n.push({name:o.identifier.name});else if(o.type==="AssignmentStatement")for(let i of o.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let s=new Set;return n.filter(o=>s.has(o.name)?!1:(s.add(o.name),!0))}function Ms(t,e){let r=le(e),n=pe(t,r),s=[],o=[];try{let i=Is.default.parse(e);s=Ec(i,t),o=Pc(i)}catch{}return{imports:s,exports:o,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Ac=["http://","https://","mailto:","//"],Nc="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Dc=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Nc})\\b`,"g"),Ls;async function Rc(){return Ls??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Ls}function Ic(t){let e=t.trim();return e.length===0||e.startsWith("#")||Ac.some(r=>e.startsWith(r))}function Mc(t,e){let r=t.match(Dc);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function _s(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Ic(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(...Mc(t.value,e)),Array.isArray(t.children))for(let n of t.children)_s(n,e,r)}async function Gs(t,e){let n=(await Rc()).parse(e),s=[];_s(n,t,s);let o=new Set;return{imports:s.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var zs=g(require("path")),Ws=require("@lezer/python");function Lc(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=q(n).filter(o=>o.type.name==="if"||o.type.name==="elif").length;break}case"TryStatement":{e+=q(n).filter(o=>o.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let s=n.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),e}function _c(t,e){let r=0,n=q(t),s=0,o=0;for(;o<n.length;){let i=n[o];if(i?.type.name==="if"||i?.type.name==="elif"){let a=s>0;r+=a?1:1+e;let c=a?e:e+1,l=n[o+1],p=n[o+2];l&&(r+=j(l,c)),p&&(r+=j(p,c)),s++,o+=3}else if(i?.type.name==="else"){r+=1;let a=n[o+1];a&&(r+=j(a,e+1)),o+=2}else o++}return r}function Gc(t,e){let r=0,n=q(t),s=0;for(;s<n.length;){let o=n[s];if(o?.type.name==="except"){for(r+=1+e,s++;s<n.length&&n[s]?.type.name!=="Body";)r+=j(n[s],e),s++;s<n.length&&(r+=j(n[s],e),s++)}else o?.type.name==="Body"&&(r+=j(o,e)),s++}return r}function Os(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=j(n,e+1),n=n.nextSibling;return r}function Oc(t,e){let r=0,n=t.firstChild;for(;n;)r+=j(n,e),n=n.nextSibling;return r}function j(t,e){let r=t.type.name;switch(r){case"IfStatement":return _c(t,e);case"TryStatement":return Gc(t,e);case"ForStatement":case"WhileStatement":return Os(t,e);default:{let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+Os(t,e):n+Oc(t,e)}}}function jc(t){return j(t,0)}function Gr(t){return{complexity:Lc(t),cognitiveComplexity:jc(t)}}function js(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:l}=Gr(i);r.push({name:a,line:V(e,i.from),complexity:c,cognitiveComplexity:l})}function s(i){let a=i.firstChild;for(;a;)o(a),a=a.nextSibling}function o(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 p=l.firstChild;for(;p;){if(p.type.name==="FunctionDefinition"){let u=p.getChild("VariableName"),m=u?e.slice(u.from,u.to):void 0;m&&n(p,c?`${c}.${m}`:m),s(p)}else o(p);p=p.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),s(i);return}s(i)}return o(t.topNode),r}var zc=new Set(["pytest","unittest","nose","hypothesis"]);function $s(t,e){let r=[],n=[],s=new Set,o=zs.default.basename(t).toLowerCase(),i=Ws.parser.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let h=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);h?.[1]&&s.add(h[1]);break}case"ImportStatement":{for(let h of Wc(a.node,e,t))r.push(h);break}case"FunctionDefinition":case"ClassDefinition":{let h=a.node.parent;if(h?.name==="Script"||h?.name==="DecoratedStatement"&&h.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&n.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let h=a.node.firstChild;h?.name==="VariableName"&&n.push({name:e.slice(h.from,h.to)})}break}}while(a.next());let c=Kc(o,r,s);c==="test"&&s.add("test");let{complexity:l,cognitiveComplexity:p}=Gr(i.topNode),u=js(i,e),m=c==="test"?[]:Jc(i,e);return{imports:r,exports:n,tags:Array.from(s).map(h=>({name:h,kind:"comment-marker"})),category:c,rawCallEdges:m,complexity:l,cognitiveComplexity:p,...u.length>0?{functions:u}:{}}}function Wc(t,e,r){let n=t.firstChild;return n?n.name==="from"?$c(t,e,r):Bc(t,e,r):[]}function $c(t,e,r){let n=t.firstChild;if(!n)return[];let s=n.nextSibling;for(;s&&s.name!=="import";)s=s.nextSibling;if(!s)return[];let o=e.slice(n.to,s.from).trim(),i=Hc(s.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let c=o.slice(a);if(a===0)return[je(r,o,i,!0)];let l=a===1?"./":"../".repeat(a-1);return c?[je(r,l+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[je(r,l.slice(0,-1),["*"],!1)]:i.map(p=>je(r,l+p,[p],!1))}function Bc(t,e,r){let n=[],s=t.firstChild?.nextSibling??null;for(;s;){if(s.name==="VariableName"){let o=e.slice(s.from,s.to);for(;s.nextSibling?.name==="."&&s.nextSibling.nextSibling?.name==="VariableName";)s=s.nextSibling.nextSibling,o+=`.${e.slice(s.from,s.to)}`;s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling),n.push(je(r,o,["*"],!0))}s=s.nextSibling}return n}function Hc(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 Uc(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let o=n.node.firstChild;if(o?.type.name!=="from")continue;let i=o.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(o.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let l=a.slice(c),p=c<=1?"./":"../".repeat(c-1),u=i.nextSibling;for(;u;){if(u.type.name==="VariableName"){let m=e.slice(u.from,u.to),h=m;if(u.nextSibling?.type.name==="as"){let v=u.nextSibling.nextSibling;v?.type.name==="VariableName"&&(h=e.slice(v.from,v.to),u=v)}let y=c===0?a:l?p+l.replace(/\./g,"/"):p+m;r.set(h,y)}u=u.nextSibling}}while(n.next());return r}function Jc(t,e){let r=Uc(t,e),n=[];function s(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let p=a.firstChild,u=e.slice(p.from,p.to),m=r.get(u);m&&n.push({from:c,to:u,toSpecifier:m})}let l=a.firstChild;for(;l;)s(l,c),l=l.nextSibling}function o(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,p=a.getChild("Body");if(p){let u=p.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let m=u.getChild("VariableName"),h=m?e.slice(m.from,m.to):void 0;h&&s(u,l?`${l}.${h}`:h)}else i(u);u=u.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&s(a,e.slice(c.from,c.to));return}o(a)}return i(t.topNode),n}function je(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function Kc(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=>zc.has(n.rawSpecifier))?"test":"logic"}var qc=/^\s*import\s+(.+?)\s*$/,Vc=/^(?:@\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_$]*)/;function Qc(t,e){let r=e.split("=>")[0]?.trim();return r?r==="_"||r==="*"||r==="given"?`${t}.*`:`${t}.${r}`:null}function Yc(t){let e=t.indexOf("{");if(e!==-1){let n=t.indexOf("}",e),s=t.slice(0,e).trim().replace(/\.$/,""),o=t.slice(e+1,n===-1?void 0:n);return s?o.split(",").map(i=>Qc(s,i.trim())).filter(i=>i!=null):[]}let r=[];for(let n of t.split(",")){let s=n.trim().replace(/\s+as\s+\w+$/,"");if(s)if(s.endsWith("._")||s.endsWith(".*")||s.endsWith(".given")){let o=s.replace(/\.(_|\*|given)$/,"");o&&r.push(`${o}.*`)}else r.push(s)}return r}function Bs(t,e){let r=ge(e),s=$(e).split(`
11
- `),o=[],i=new Set;for(let l of s){let p=l.match(qc);if(p?.[1]){for(let m of Yc(p[1]))o.push(he(t,m));continue}let u=l.match(Vc);u?.[2]&&i.add(u[2])}let a=I(e,!0);a&&o.push(B(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:O(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:de(e).annotations})}}var zr=g(require("path")),d=g(require("typescript"));var S=g(require("typescript"));function Zc(t){let e=1;function r(n){switch(n.kind){case S.default.SyntaxKind.IfStatement:case S.default.SyntaxKind.ConditionalExpression:case S.default.SyntaxKind.ForStatement:case S.default.SyntaxKind.ForInStatement:case S.default.SyntaxKind.ForOfStatement:case S.default.SyntaxKind.WhileStatement:case S.default.SyntaxKind.DoStatement:case S.default.SyntaxKind.CatchClause:case S.default.SyntaxKind.CaseClause:e++;break;case S.default.SyntaxKind.BinaryExpression:{let s=n.operatorToken.kind;(s===S.default.SyntaxKind.AmpersandAmpersandToken||s===S.default.SyntaxKind.BarBarToken||s===S.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}S.default.forEachChild(n,r)}return r(t),e}function Us(t,e,r){let n=r?1:1+e,s=r?e:e+1;return n+=Y(t.expression,s,!1),n+=Y(t.thenStatement,s,!1),t.elseStatement&&(S.default.isIfStatement(t.elseStatement)?n+=Us(t.elseStatement,e,!0):n+=1+Y(t.elseStatement,e+1,!1)),n}function Hs(t,e){let r=1+e;return S.default.forEachChild(t,n=>{r+=Y(n,e+1,!1)}),r}function Xc(t,e){let r=1+e;return S.default.forEachChild(t,n=>{r+=Y(n,e,!1)}),r}function el(t,e){let r=0;return S.default.forEachChild(t,n=>{r+=Y(n,e,!1)}),r}function tl(t){let e=t.operatorToken.kind;return e===S.default.SyntaxKind.AmpersandAmpersandToken||e===S.default.SyntaxKind.BarBarToken||e===S.default.SyntaxKind.QuestionQuestionToken}function Y(t,e,r){if(S.default.isIfStatement(t))return Us(t,e,r);if(S.default.isForStatement(t)||S.default.isForInStatement(t)||S.default.isForOfStatement(t)||S.default.isWhileStatement(t)||S.default.isDoStatement(t)||S.default.isSwitchStatement(t))return Hs(t,e);if(S.default.isCatchClause(t))return Xc(t,e);let n=0;return S.default.isConditionalExpression(t)&&(n+=1),S.default.isBinaryExpression(t)&&tl(t)&&(n+=1),e>0&&(S.default.isFunctionDeclaration(t)||S.default.isFunctionExpression(t)||S.default.isArrowFunction(t))?n+Hs(t,e):n+el(t,e)}function rl(t){return Y(t,0,!1)}function Or(t){return{complexity:Zc(t),cognitiveComplexity:rl(t)}}var C=g(require("typescript")),jr=new Set(["test","describe","it"]);function Js(t,e){nl(t,e),ol(t,e),il(t,e),al(t,e)}function nl(t,e){if((C.default.isFunctionDeclaration(t)||C.default.isVariableDeclaration(t))&&t.name&&C.default.isIdentifier(t.name)&&sl(t)){let r;if(C.default.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(C.default.isArrowFunction(n)||C.default.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function sl(t){if(C.default.isFunctionDeclaration(t))return C.default.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&C.default.isSourceFile(e.parent)}function ol(t,e){if(!C.default.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 il(t,e){if(!C.default.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),s=r.exec(n);for(;s!==null;)s[1]&&e.tags.add({name:s[1],kind:"comment-marker"}),s=r.exec(n)}function al(t,e){if(C.default.isCallExpression(t)&&cl(t.expression))for(let r of t.arguments)C.default.isObjectLiteralExpression(r)&&ll(r,e)}function cl(t){return C.default.isIdentifier(t)?jr.has(t.text):!!(C.default.isPropertyAccessExpression(t)&&(jr.has(t.name.text)||C.default.isIdentifier(t.expression)&&jr.has(t.expression.text)))}function ll(t,e){for(let r of t.properties){if(!C.default.isPropertyAssignment(r)||!C.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,s=C.default.isArrayLiteralExpression(n)?n.elements.filter(C.default.isStringLiteral):r.name.text==="tag"&&C.default.isStringLiteral(n)?[n]:[];for(let o of s)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function Wr(t,e,r){let n=[],s=new Map,o=new Set,i=d.default.createSourceFile(t,e,d.default.ScriptTarget.Latest,!0,r==="typescript"?d.default.ScriptKind.TSX:d.default.ScriptKind.JSX),a={filePath:t,imports:n,exports:s,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{ml(v,a),d.default.forEachChild(v,c)};c(i);let l=wl(t,a);(l==="test"||l==="barrel")&&o.add({name:l,kind:"comment-marker"}),l!=="test"&&El(a,i);let p=i.statements[0],u=p?qs(p):void 0,{complexity:m,cognitiveComplexity:h}=Or(i),y=pl(i);return{imports:n,exports:Array.from(s.values()),tags:Array.from(o),category:l,rawCallEdges:a.rawCallEdges??[],complexity:m,cognitiveComplexity:h,...y.length>0?{functions:y}:{},...u!==void 0?{description:u}:{}}}function pl(t){let e=[],r=(s,o)=>{let{complexity:i,cognitiveComplexity:a}=Or(o),c=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:s,line:c,complexity:i,cognitiveComplexity:a})},n=(s,o)=>{if(d.default.isFunctionDeclaration(s)&&s.name&&s.body?r(s.name.text,s):d.default.isVariableDeclaration(s)&&d.default.isIdentifier(s.name)&&s.initializer&&(d.default.isArrowFunction(s.initializer)||d.default.isFunctionExpression(s.initializer))?r(s.name.text,s.initializer):o&&d.default.isMethodDeclaration(s)&&d.default.isIdentifier(s.name)&&s.body?r(`${o}.${s.name.text}`,s):o&&d.default.isConstructorDeclaration(s)&&s.body?r(`${o}.constructor`,s):o&&d.default.isGetAccessorDeclaration(s)&&d.default.isIdentifier(s.name)&&s.body?r(`${o}.get ${s.name.text}`,s):o&&d.default.isSetAccessorDeclaration(s)&&d.default.isIdentifier(s.name)&&s.body&&r(`${o}.set ${s.name.text}`,s),d.default.isClassDeclaration(s)&&s.name){let i=s.name.text;d.default.forEachChild(s,a=>n(a,i));return}d.default.forEachChild(s,i=>n(i,o))};return n(t,void 0),e}function Ks(t,e,r,n){let s={name:t},o=qs(r);o!==void 0&&(s.doc=o);let i=ul(e);i!==void 0&&(s.flags=i);let a=fl(e,n);return a!==void 0&&(s.signature=a),s}function qs(t){let e=d.default.getJSDocCommentsAndTags(t);for(let r of e)if(d.default.isJSDoc(r)&&r.comment)return d.default.getTextOfJSDocComment(r.comment)||void 0}function ul(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=d.default.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function fl(t,e){let r=d.default.createPrinter({removeComments:!0}),n=s=>r.printNode(d.default.EmitHint.Unspecified,s,e);if(d.default.isFunctionDeclaration(t)||d.default.isMethodDeclaration(t)){let s=t.parameters.map(n).join(", "),o=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${s}) => ${o}`}if(d.default.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(d.default.isArrowFunction(t.initializer)||d.default.isFunctionExpression(t.initializer))){let s=t.initializer,o=s.parameters.map(n).join(", "),i=s.type?n(s.type):"unknown";return`(${o}) => ${i}`}return}if(d.default.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(d.default.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(d.default.isTypeAliasDeclaration(t))return n(t.type);if(d.default.isEnumDeclaration(t))return`enum ${t.name.text}`}function ml(t,e){gl(t,e),dl(t,e),yl(t,e),xl(t,e),Cl(t,e),Js(t,e)}function gl(t,e){if(!d.default.isSourceFile(t))return;let r=t.statements.filter(n=>!d.default.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>d.default.isExportDeclaration(n)||d.default.isExportAssignment(n)||$r(n)).length}function dl(t,e){if(d.default.isJsxElement(t)||d.default.isJsxSelfClosingElement(t)||d.default.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(d.default.isFunctionDeclaration(t)||d.default.isMethodDeclaration(t)||d.default.isArrowFunction(t)||d.default.isClassDeclaration(t)||d.default.isVariableStatement(t)||d.default.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}d.default.isExportDeclaration(t)&&!hl(t)&&(e.hasTypesOnly=!1)}function hl(t){return t.isTypeOnly?!0:!t.exportClause||!d.default.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function yl(t,e){if(!d.default.isImportDeclaration(t)||!t.moduleSpecifier||!d.default.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(d.default.isNamedImports(t.importClause.namedBindings))for(let s of t.importClause.namedBindings.elements)r.push(s.name.text);else d.default.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:N(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function xl(t,e){d.default.isExportDeclaration(t)?bl(t,e):d.default.isExportAssignment(t)?e.exports.set("default",{name:"default"}):$r(t)&&kl(t,e)}function bl(t,e){if(t.moduleSpecifier&&d.default.isStringLiteral(t.moduleSpecifier))Sl(t,t.moduleSpecifier.text,e);else if(t.exportClause&&d.default.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function Sl(t,e,r){let n=vl(t),s={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:N(e),type:"re-export"};n.length>0&&(s.symbols=n),r.imports.push(s)}function vl(t){return t.exportClause?d.default.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function kl(t,e){if((d.default.isFunctionDeclaration(t)||d.default.isClassDeclaration(t)||d.default.isInterfaceDeclaration(t)||d.default.isTypeAliasDeclaration(t)||d.default.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,Ks(n,t,t,e.sourceFile));return}if(d.default.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(d.default.isIdentifier(n.name)){let s=n.name.text;e.exports.set(s,Ks(s,n,t,e.sourceFile))}}}function Cl(t,e){if(!d.default.isCallExpression(t))return;let r=t.arguments[0];!r||!d.default.isStringLiteral(r)||(t.expression.kind===d.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"dynamic"}):d.default.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"require"}))}function wl(t,e){let r=zr.default.basename(t).toLowerCase(),n=zr.default.extname(t).toLowerCase();return Ne().some(o=>r.includes(o))?"test":$n(r)?"config":e.imports.some(o=>nr().some(i=>o.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>ir()?"barrel":"logic"}function $r(t){return d.default.canHaveModifiers(t)&&d.default.getModifiers(t)?.some(e=>e.kind===d.default.SyntaxKind.ExportKeyword)===!0}function El(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let s of e.statements){if(!d.default.isImportDeclaration(s)||!d.default.isStringLiteral(s.moduleSpecifier))continue;let o=s.moduleSpecifier.text,i=s.importClause;if(i&&(i.name&&n.set(i.name.text,o),i.namedBindings&&d.default.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,o)}if(n.size!==0)for(let s of e.statements){let o=Tl(s);if(o){let i=Pl(s);i&&yt(i,o,n,r);continue}d.default.isClassDeclaration(s)&&s.name&&Fl(s,s.name.text,n,r)}}function Fl(t,e,r,n){for(let s of t.members)d.default.isMethodDeclaration(s)&&s.body&&d.default.isIdentifier(s.name)?yt(s.body,`${e}.${s.name.text}`,r,n):d.default.isConstructorDeclaration(s)&&s.body&&yt(s.body,`${e}.constructor`,r,n)}function Tl(t){if($r(t)){if(d.default.isFunctionDeclaration(t)&&t.name)return t.name.text;if(d.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(d.default.isIdentifier(e.name)&&e.initializer&&(d.default.isArrowFunction(e.initializer)||d.default.isFunctionExpression(e.initializer)))return e.name.text}}}function Pl(t){if(d.default.isFunctionDeclaration(t))return t.body;if(d.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(d.default.isArrowFunction(e.initializer)||d.default.isFunctionExpression(e.initializer)))return e.initializer}}function yt(t,e,r,n){if(d.default.isCallExpression(t)&&d.default.isIdentifier(t.expression)){let s=t.expression.text,o=r.get(s);o&&!n.some(i=>i.from===e&&i.to===s&&i.toSpecifier===o)&&n.push({from:e,to:s,toSpecifier:o})}d.default.forEachChild(t,s=>yt(s,e,r,n))}function xt(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 Br=g(require("postcss")),Al=g(require("postcss-less")),Nl=Al,Qs=new Set(["reference","inline"]);function Vs(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Dl(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Rl(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Qs.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Vs(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),s=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return s?{fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static",...Vs(s)?{isExternal:!0}:{}}:null}function Il(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"";Dl(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),s=n.exec(t)}return r}function Ys(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let s=Rl(n.params,e);s&&r.push(s)}n.type==="decl"&&r.push(...Il(n.value,e))}),r}function Ml(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Ll(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"",i=s[2]??"";if(i){let a=Qs.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}s=n.exec(t)}return r}function bt(t,e){let r=Br.default.parse(Ml(t));return{imports:Ys(r,e),root:r}}function _l(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:s}=n;if(s===void 0)continue;let o=n.name;o&&(e.push({name:o}),r.push({name:o,kind:"variable"}))}return{exports:e,tags:r}}function St(t,e){try{let r=Nl.parse(t),{exports:n,tags:s}=_l(r);return{imports:Ys(r,e),root:r,exports:n,tags:s}}catch{return{imports:Ll(t,e),root:Br.default.parse(""),exports:[],tags:[]}}}var Xs=require("postcss-scss");function Zs(t){return t.startsWith("_")||t.startsWith("-")}function Gl(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Ol(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],s=t.match(/\bas\s+(\S+)/)?.[1];return s!==void 0?{specifier:r,alias:s}:{specifier:r}}function jl(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let s=n.prop.slice(1);if(!s||Zs(s))continue;e.push({name:s}),r.push({name:s,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let o=n.params.match(/^([\w-]+)/)?.[1];if(!o||Zs(o))continue;let i=n.params.trim();e.push(i.includes("(")?{name:o,signature:i}:{name:o}),r.push({name:o,kind:"function"})}}return{exports:e,tags:r}}function vt(t,e){let r=(0,Xs.parse)(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:l,alias:p}=Ol(c);if(!l)return;let u={fromPath:e,toPath:"",rawSpecifier:l,isStyle:!0,type:a==="forward"?"re-export":"static",...Gl(l)?{isExternal:!0}:{}};p&&(u.symbols=[p]),n.push(u)});let{exports:s,tags:o}=jl(r);return{imports:n,root:r,exports:s,tags:o}}function eo(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),s=n.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(s=o.exec(t);s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),s=o.exec(t)}return r}function to(t,e){if(e.length===0)return"ui";try{let r=require("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function ze(t,e){let r=G(t);if(r==="stylus"){let o=eo(e,t);return{imports:o,exports:[],tags:[],category:to(e,o)}}if(r==="scss"){let{imports:o,root:i,exports:a,tags:c}=vt(e,t);return{imports:o,exports:a,tags:c,category:xt(i,o)}}if(r==="less"){let{imports:o,root:i,exports:a,tags:c}=St(e,t);return{imports:o,exports:a,tags:c,category:xt(i,o)}}let{imports:n,root:s}=bt(e,t);return{imports:n,exports:[],tags:[],category:xt(s,n)}}for(let[t,e]of[["javascript",(r,n)=>Wr(r,n,"javascript")],["typescript",(r,n)=>Wr(r,n,"typescript")],["css",ze],["scss",ze],["less",ze],["stylus",ze],["coffeescript",ms],["livescript",Rs],["lua",Ms],["python",$s],["go",Cs],["java",As],["kotlin",Ns],["scala",Bs],["groovy",ws],["gherkin",Nr],["markdown",Gs]])ue(t,e);async function ro(t,e){let r=G(t),n=ds(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Hr=g(require("path"));function zl(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function so(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(s=>s.name===n)&&e.push({name:n,kind:"library"})}}function Wl(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 $l(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 no(t){return Math.round(t*1e4)/1e4}function Bl(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let s=e.get(n.toPath);if(!s||s.exports.length===0)continue;let o;if(n.symbols===void 0){if(n.type==="side-effect")continue;o=1}else n.symbols.includes("*")?o=1:o=n.symbols.length/s.exports.length;n.exportUsageRatio=no(Math.min(1,o)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=no(r.reduce((n,s)=>n+s,0)/r.length),t.maxExportUsage=Math.max(...r))}function Ur(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Hl(t,e){let r=e.toPath,n=Hr.default.basename(r,Hr.default.extname(r)).replace(/\.(test|spec)$/,"");Ur(t.tags,n,"import")}function Ul(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Ur(t.tags,r,"import")}function Jl(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let s of n.tags)s.kind==="comment-marker"&&Ur(t.tags,s.name,"comment-marker")}function Kl(t,e,r){!e.toPath||e.isExternal||(Hl(t,e),Ul(t,e),Jl(t,e,r))}function oo(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(Bl(r,t),e.size>0&&zl(r,e),r.category==="test")for(let n of r.imports)Wl(r,n,t),Kl(r,n,t);$l(r,t)}}var io=new Set(["java","kotlin","scala","groovy"]),ao=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),co=new Set(["typescript","javascript","python"]),kt=new Set(["typescript","javascript","go","python","java"]);function Jr(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:ao.has(r),importSymbolsTracked:co.has(r),callEdgesTracked:kt.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var Ve=g(require("fs")),M=g(require("path"));var Kr=g(require("fs")),Z=g(require("path")),We=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,s){let{mod:o,replaces:i}=this.readGoMod(n);if(!o)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return po(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let c=r.slice(o.length).replace(/^\//,"");return c?po(Z.default.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let s=Kr.default.readFileSync(Z.default.join(e,"go.mod"),"utf-8"),o=ql(s,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[s,o]of r){if(e===s)return o;if(e.startsWith(`${s}/`)){let i=e.slice(s.length+1);return Z.default.join(o,i)}}}};function ql(t,e){let r=t.split(`
12
- `),n=null,s=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){lo(a,e,s);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&lo(a.replace(/^replace\s+/,""),e,s)}return{mod:n,replaces:s}}function lo(t,e,r){let[n,s]=t.split("=>").map(a=>a.trim());if(!n||!s)return;let o=n.split(/\s+/)[0];if(!s.startsWith(".")&&!s.startsWith("/"))return;let i=Z.default.isAbsolute(s)?s:Z.default.resolve(e,s);r.set(o,i)}function po(t){let e;try{e=Kr.default.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:Z.default.join(t,n.name),isExternal:!1})).sort((n,s)=>n.path.localeCompare(s.path));return r.length>0?r:null}var $e=g(require("fs")),Be=g(require("path"));var Vl=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Ql=12,uo=4096,He=class{extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,r,n,s){let o=this.getIndex(n);if(o.size===0)return null;let i=r.endsWith(".*"),a=(i?r.slice(0,-2):r).split(".").filter(Boolean);if(a.length===0)return null;if(i)return qr(o.get(a.join(".")));for(let c=a.length-1;c>=1;c--){let l=o.get(a.slice(0,c).join("."));if(!l)continue;let p=a[c],u=l.filter(m=>Xl(m)===p);if(u.length>0)return qr(u);if(c===a.length-1)return qr(l)}return null}getIndex(e){let r=this.indexCache.get(e);if(r)return r;let n=Yl(e);return this.indexCache.set(e,n),n}};function Yl(t){let e=new Map,r=new Set(P),n=(s,o)=>{if(o>Ql)return;let i;try{i=$e.default.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){let c=Be.default.join(s,a.name);if(a.isDirectory()){!a.name.startsWith(".")&&!r.has(a.name)&&n(c,o+1);continue}if(!a.isFile())continue;let l=Be.default.extname(a.name);if(!Vl.has(l))continue;let p=Zl(c,l===".scala"||l===".sc");if(!p)continue;let u=e.get(p);u?u.push(c):e.set(p,[c])}};n(t,0);for(let s of e.values())s.sort();return e}function Zl(t,e){let r;try{let n=$e.default.openSync(t,"r");try{let s=Buffer.alloc(uo),o=$e.default.readSync(n,s,0,uo,0);r=s.toString("utf8",0,o)}finally{$e.default.closeSync(n)}}catch{return null}return I(r,e)}function qr(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function Xl(t){return Be.default.basename(t,Be.default.extname(t))}var fo=g(require("fs")),Ct=g(require("path")),Ue=class{extensions=[".lua"];resolve(e,r,n,s){let o=r.replace(/\./g,Ct.default.sep),i=[n,Ct.default.join(n,"lib")];for(let a of i){if(!fo.default.existsSync(a))continue;let c=s(Ct.default.join(a,"_dummy.lua"),o);if(c)return[c]}return null}};var mo=g(require("path"));var ep=new Set(P),Je=class{extensions=[".md",".mdx"];resolve(e,r,n,s){let o=r.replace(/^\.\//,"").split("/")[0];if(o&&ep.has(o))return null;let i=s(mo.default.join(n,"_dummy"),`./${r}`);return i?[i]:null}};var ho=g(require("fs")),wt=g(require("path")),Ke=class{extensions=[".py"];resolve(e,r,n,s){let o=r.replace(/\./g,wt.default.sep),i=wt.default.join(n,`${o}.py`);if(go(i))return[{path:i,isExternal:!1}];let a=wt.default.join(n,o,"__init__.py");return go(a)?[{path:a,isExternal:!1}]:null}};function go(t){try{return ho.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Vr=g(require("path")),tp=["~","http://","https://","//","data:","sass:"],qe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,s){if(tp.some(p=>r.startsWith(p)))return null;let o=s(e,r);if(o)return[o];let i=Vr.default.dirname(r),a=Vr.default.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,l=s(e,c);return l?[l]:null}};var z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new Ke,new Ue,new We,new He,new qe,new Je]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let r=0;r<this.langResolvers.length;r++)if(this.langResolvers[r]?.extensions.some(n=>e.endsWith(n)))return String(r);return"none"}cacheKey(e,r){return`${M.default.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),s=this.resolutionCache.get(n);if(s!==void 0)return s??[];let o=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,o.length>0?o:null),o}resolveAllUncached(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let s=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,s);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=M.default.dirname(e),s=r.startsWith("/")?r:M.default.resolve(n,r),o=!s.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=s.match(/\.(js|mjs|cjs)$/);if(a){let c=s.slice(0,-a[0].length);for(let l of[".ts",".tsx"]){let p=this.tryExtensions(c,l,o);if(p)return p}}for(let c of i){let l=this.tryExtensions(s,c,o);if(l)return l}return o?{path:s,isExternal:!0}:null}tryExtensions(e,r,n){let s=e+r;if(this.isFile(s))return{path:s,isExternal:n};let o=M.default.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:n};if(r===".py"){let i=M.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return Ve.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),s=this.pathAliases[r];if(n&&s){let o=this.tryAliasSubstitutions(s,n[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let n=M.default.join(r,"tsconfig.json");if(Ve.default.existsSync(n))try{let o=JSON.parse(Ve.default.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${s}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let s=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=M.default.resolve(n,i);for(let c of s){let l=this.tryExtensions(a,c,!1);if(l)return l}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let s=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!s){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=M.default.join(n,a);try{if(Ve.default.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...o,path:c}}catch{}}return{...o,path:n}}let i=this.resolveLocalPath(M.default.join(n,"_dummy"),s.slice(1));return i?{...o,path:i.path}:null}return null}};var rp=["tests","test","__tests__","specs","spec"],np=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],sp=600;function op(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function ip(t,e){if(t.length===0)return e;let r=t.map(i=>F.default.dirname(i).split(F.default.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let s=n.join(F.default.sep)||F.default.sep,o=F.default.relative(e,s);return o.startsWith("..")||F.default.isAbsolute(o)?e:s}var X=class{constructor(e,r=null,n,s,o=!1,i=new Map,a=!0,c=[]){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.walkIgnoreDirs=new Set([...np,...c,...op()]),this.resolver=n||new z(e),this.lockFile=ls(e),s&&(this.progressCallback=s)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;walkIgnoreDirs;async build(e){let r=e.map(n=>F.default.isAbsolute(n)?n:F.default.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=rs(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(ip(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
2
+ "use strict";var Ia=Object.create;var mt=Object.defineProperty;var Ma=Object.getOwnPropertyDescriptor;var _a=Object.getOwnPropertyNames;var La=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var Oa=(t,e)=>{for(var r in e)mt(t,r,{get:e[r],enumerable:!0})},ts=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _a(e))!Ga.call(t,s)&&s!==r&&mt(t,s,{get:()=>e[s],enumerable:!(n=Ma(e,s))||n.enumerable});return t};var d=(t,e,r)=>(r=t!=null?Ia(La(t)):{},ts(e||!t||!t.__esModule?mt(r,"default",{value:t,enumerable:!0}):r,t)),ja=t=>ts(mt({},"__esModule",{value:!0}),t);var pf={};Oa(pf,{createMcpServer:()=>ar});module.exports=ja(pf);var Ra=require("@modelcontextprotocol/sdk/server/stdio.js");var Na=require("@modelcontextprotocol/sdk/server/index.js"),ir=require("@modelcontextprotocol/sdk/types.js");var Q=d(require("fs")),B=d(require("path"));var yt=d(require("fs")),dr=d(require("path"));var Wa=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],cr=[];function ft(t){cr.push(t)}function rs(t){return[...Wa,...cr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var za=[".test.",".spec.","-test.","-spec."],lr=[];function gt(t){lr.push(t)}function Ge(){return[...za,...lr]}var $a=["jest","vitest","playwright","cypress","@testing-library/"],pr=[];function dt(t){pr.push(t)}function ur(){return[...$a,...pr]}var ns=.8,mr=ns;function fr(t){mr=t}function gr(){return mr}function ht(){cr.length=0,lr.length=0,pr.length=0,mr=ns}var Ba=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function Oe(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=dr.default.resolve(t);return yt.default.existsSync(n)?n.endsWith(".json")?ss(n):e?os(n):{}:{}}for(let n of Ba){let s=dr.default.resolve(t,n);if(yt.default.existsSync(s)){if(n.endsWith(".json"))return ss(s);if(e)return os(s)}}return{}}function ss(t){return JSON.parse(yt.default.readFileSync(t,"utf-8"))}function os(t){let e=require(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function hr(t){ht();for(let e of t.configMatchers??[])ft(e);for(let e of t.testPatterns??[])gt(e);for(let e of t.testLibraries??[])dt(e);t.barrelThreshold!==void 0&&fr(t.barrelThreshold)}function K(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var X="mokosh-cache",je="duplication-tokens.json",yr="graph.json",xr="workspace-graph.json",br="branch-graphs",R=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],Sr=[".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"];var is=d(require("fs")),kr=d(require("path"));function vr(t,e){let r=kr.default.resolve(t,e);try{let n=is.default.readFileSync(r,"utf-8"),s=JSON.parse(n),o=new Map;if(typeof s!="object"||s===null)return o;for(let[i,a]of Object.entries(s)){if(i==="total")continue;let c=a?.lines?.pct;if(typeof c!="number")continue;let l=kr.default.relative(t,i);o.set(l,c)}return o}catch{return new Map}}var xt={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let s=`"${n.path}"`;for(let o of n.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${n.path} -> ${o.toPath}`;if(!r.has(a)){let c=o.isStyle?"-- styles -->":"-->";e.push(` ${s} ${c} ${i}`),r.add(a)}}}return e.join(`
3
+ `)}};var de=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let s=n.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:s?.toPath??""})}return r.sort((n,s)=>s.maxExportUsage-n.maxExportUsage)}findCycles(e={}){let r=new Set(e.includeKinds??[]),n=[],s=new Set,o=new Set,i=[],a=c=>{s.add(c),o.add(c),i.push(c);let l=this.nodes.get(c);if(l){for(let p of l.imports)if(!(!p.toPath||p.isExternal)&&!(p.isSamePackage&&!r.has("samePackage"))&&!(p.isDocReference&&!r.has("docReference")))if(o.has(p.toPath)){let u=i.indexOf(p.toPath);n.push([...i.slice(u),p.toPath])}else s.has(p.toPath)||a(p.toPath)}o.delete(c),i.pop()};for(let c of this.nodes.keys())s.has(c)||a(c);return n}};var Cr=d(require("fs")),as=d(require("path"));function wr(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function cs(t,e){if(typeof t=="string")return wr(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let s=cs(r[n],e);if(s)return s}}return null}function Ua(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 Ka(t,e){let r=new Set,n=new Set,s=[...e];for(;s.length;){let o=s.shift();if(n.has(o))continue;n.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.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 p of l.exports)r.add(p.name);s.push(a.toPath)}else for(let l of a.symbols)r.add(l)}}}return r}function Er(t,e){let r=[],n=as.default.join(e,"package.json");if(Cr.default.existsSync(n))try{let s=JSON.parse(Cr.default.readFileSync(n,"utf8"));if(s.exports&&typeof s.exports=="object"&&!Array.isArray(s.exports))for(let o of Object.values(s.exports)){let i=cs(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof s.exports=="string"){let o=wr(s.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[s.main,s.module].filter(Boolean)){let i=wr(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let s of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(s)){r.push(s);break}}return r}function Ja(t,e){let r=new Set(e);for(let n of e)t.traverse(n,s=>(r.add(s.path),!0),{direction:"outgoing"});return r}function qa(t,e,r){let n=new Map;for(let s of e){if(r.includes(s))continue;let o=t.nodes.get(s);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let c=n.get(a.name),l=!!(a.signature||a.doc);(!c||l&&!i)&&n.set(a.name,{file:s,symbol:a})}}return n}function Va(t,e,r,n){let s=[];for(let o of t){let i=e.get(o),a=n.flatMap(u=>r.nodes.get(u)?.exports??[]).find(u=>u.name===o),c=i?.symbol??a,l=i?.file??n.find(u=>r.nodes.get(u)?.exports.some(m=>m.name===o))??n[0],p={name:o,definedIn:l,kind:Ua(c?.signature)};c?.doc&&(p.doc=c.doc),c?.signature&&(p.signature=c.signature),s.push(p)}return s.sort((o,i)=>o.name.localeCompare(i.name)),s}function Qa(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",s=[...e].filter(c=>!r.includes(c)&&!n(c)),o=[...t.nodes.keys()].filter(c=>!e.has(c)),i=o.filter(c=>!n(c)),a=o.filter(c=>n(c));return{internalFiles:s,unreachableFromEntry:i,testFiles:a}}function Tr(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 r=Ja(t,e),n=qa(t,r,e),s=Ka(t,e),o=Va(s,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Qa(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:c}}function Fr(t,e){let r=null,n=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from})}let s=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&s.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:s}}var Ya=d(require("fs")),Xa=d(require("path"));function ls(t){let e=[...t.nodes.entries()].sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${s.mtime}:${s.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function Pr(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,s=>(s.path!==r&&n.push(s.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:ls(t)}}function Ar(t,e){return t.impact.get(e)??[]}var ri=d(require("path"));var he=d(require("fs")),Nr=d(require("path"));var D=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let s=e.get(n.toPath)||[];s.push(r.path),e.set(n.toPath,s)}return this._incomingEdgesCache=e,e}dfs(e,r,n,s){let o=new Set,i=n.maxDepth??1/0,a=(c,l,p)=>{if(l>i||o.has(c))return;let u=this.nodes.get(c);if(u&&(o.add(c),r(u,l,p)!==!1))for(let m of s(c))a(m,l+1,c)};a(e,0,null)}traverse(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>s==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let s=e.get(n.toFile)??[];s.push(r.path),e.set(n.toFile,s)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let s=n.direction??"outgoing",o=s==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>s==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new de(this.nodes).findUnusedFiles(e)}findCycles(e){return new de(this.nodes).findCycles(e)}};function bt(t){return Nr.default.join(t,X,br)}function ps(t,e){return Nr.default.join(bt(t),`${e}.json`)}function us(t,e){let r=ps(t,e);if(!he.default.existsSync(r))return null;try{let n=he.default.readFileSync(r,"utf-8");return D.deserialize(JSON.parse(n))}catch{return null}}function ms(t,e,r){let n=bt(t);he.default.existsSync(n)||he.default.mkdirSync(n,{recursive:!0}),he.default.writeFileSync(ps(t,e),JSON.stringify(r.serialize()))}var Te=d(require("fs")),P=d(require("path")),Io=d(require("piscina"));var St=require("child_process"),kt=class{getChangedFiles(e,r){try{let s=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...r?[["diff","--name-only","--end-of-options",`${r}...HEAD`]]:[]].flatMap(o=>{try{return(0,St.execFileSync)("git",o,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
4
+ `).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(s))}catch(n){return console.error("Error getting git diff:",n),[]}}},fs="%x00%H%x09%ae%x09%at",gs=256*1024*1024;function ds(t,e){let r="",n=0;for(let s of t.split(`
5
+ `)){if(s.startsWith("\0")){let[,c,l]=s.slice(1).split(" ");r=c??"",n=l?Number(l)*1e3:0;continue}if(s==="")continue;let o=s.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,n)}}function hs(t){let e=new Map;try{let r=(0,St.execFileSync)("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${fs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:gs});ds(r,(n,s,o)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:s||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=(0,St.execFileSync)("git",["-C",t,"log","--name-status","-M",`--format=${fs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:gs});ds(r,(n,s,o)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var ze=d(require("fs")),ys=d(require("path")),Rr=require("js-yaml");var We=["package-lock.json","yarn.lock","pnpm-lock.yaml"];function xs(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Za(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),xs(r)}).filter(Boolean)}function ec(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function tc(t){try{let e=(0,Rr.load)(t),r={dependencies:{}};for(let[n,s]of Object.entries(e))if(!(n==="__metadata"||!s?.version))for(let o of n.split(", ")){let i=xs(o);i&&(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}return r}catch{return null}}function rc(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
6
+ `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let s=n[0];if(!s||s.startsWith(" "))continue;let o=Za(s);if(o.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of o)e.dependencies[c]={version:a}}return e}function bs(t){let e=ze.default.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[s,o]of Object.entries(r.packages)){if(!s.startsWith("node_modules/"))continue;let i=s.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[s,o]of Object.entries(r.dependencies))n.dependencies[s]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return n}function Ss(t){let e=ze.default.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=tc(e);if(r!==null)return r}return rc(e)}function ks(t){let e=ze.default.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=(0,Rr.load)(e);if(n.packages)for(let[s,o]of Object.entries(n.packages)){let{name:i,version:a}=ec(s,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(n.dependencies)for(let[s,o]of Object.entries(n.dependencies)){if(r.dependencies[s])continue;let i=typeof o=="string"?o:o.version;r.dependencies[s]={version:i||""}}}catch{}return r}var nc={"package-lock.json":bs,"yarn.lock":Ss,"pnpm-lock.yaml":ks};function Dr(t){for(let e of We){let r=ys.default.join(t,e);if(ze.default.existsSync(r))return nc[e](r)}return null}var He=d(require("fs")),Be=d(require("path"));function vs(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 sc(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=vs(e).split(":");return a.length>=3&&a[0]&&a[2]?{group:a[0],version:a[2]}:null}if(!e.startsWith("{"))return null;let r=e.match(/module\s*=\s*["']([^"']+)["']/),n=e.match(/group\s*=\s*["']([^"']+)["']/),s=r?r[1].split(":")[0]:n?.[1];if(!s)return null;let o=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:s,...i?.[1]!==void 0&&{version:i[1]},...o?.[1]!==void 0&&{versionRef:o[1]}}}function Ir(t){let e=t.split(/\r?\n/).map(o=>o.replace(/#.*$/,"").trim()),r={},n="";for(let o of e){let i=o.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="versions"||!o)continue;let a=o.indexOf("=");if(a===-1)continue;let c=o.slice(0,a).trim(),l=vs(o.slice(a+1));c&&l&&(r[c]=l)}let s={};n="";for(let o of e){let i=o.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="libraries"||!o)continue;let a=o.indexOf("=");if(a===-1)continue;let c=sc(o.slice(a+1));if(!c)continue;let l=c.versionRef?r[c.versionRef]:c.version;l&&(s[c.group]=l)}return s}function Mr(t){let e={};for(let r of t.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#")||n.startsWith("empty="))continue;let o=n.split("=")[0].split(":");o.length>=3&&o[0]&&o[2]&&(e[o[0]]=o[2])}return e}function _r(t){let e={},r=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let s=r.exec(t);s;s=r.exec(t)){let[,o,,i]=s;o&&i&&/\d/.test(i)&&(e[o]=i)}let n=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let s=n.exec(t);s;s=n.exec(t))s[1]&&s[2]&&/\d/.test(s[2])&&(e[s[1]]=s[2]);return e}function vt(t){let e={},r=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let n=r.exec(t);n;n=r.exec(t)){let[,s,,o]=n;s&&o&&(e[s]=o)}return e}var oc=new Set(["node_modules","build",".gradle","target",".git","dist"]),ic=2;function $e(t){try{return He.default.existsSync(t)?He.default.readFileSync(t,"utf-8"):null}catch{return null}}function Lr(t){let e={},r=p=>{for(let[u,m]of Object.entries(p))!e[u]&&m&&(e[u]=m)},n=$e(Be.default.join(t,"gradle","libs.versions.toml"));n&&r(Ir(n));let s=[],o=[],i=[],a=(p,u)=>{let m;try{m=He.default.readdirSync(p,{withFileTypes:!0})}catch{return}for(let g of m){let y=Be.default.join(p,g.name);if(g.isDirectory()){u<ic&&!g.name.startsWith(".")&&!oc.has(g.name)&&a(y,u+1);continue}g.isFile()&&(g.name==="gradle.lockfile"?s.push(y):g.name==="build.gradle"||g.name==="build.gradle.kts"?o.push(y):g.name==="build.sbt"&&i.push(y))}};a(t,0);for(let p of s){let u=$e(p);u&&r(Mr(u))}for(let p of o){let u=$e(p);u&&r(_r(u))}for(let p of i){let u=$e(p);u&&r(vt(u))}try{let p=Be.default.join(t,"project");for(let u of He.default.readdirSync(p,{withFileTypes:!0}))if(u.isFile()&&u.name.endsWith(".scala")){let m=$e(Be.default.join(p,u.name));m&&r(vt(m))}}catch{}let c=Object.keys(e);if(c.length===0)return null;let l={};for(let p of c)l[p]={version:e[p]};return l}function Cs(t){let e=Dr(t),r=Lr(t);return r?{...e??{dependencies:{}},jvmDependencies:r}:e}var Gr=d(require("path"));function O(t){switch(Gr.default.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 I(t){let e=Gr.default.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var Es=d(require("coffeescript"));function J(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function ye(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function xe(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Ts(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return J(t.value)}}function Z(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function ac(t,e){let r=Ts(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:I(r),type:"static"}:null}function cc(t,e){let r=e.variable?.base?.value==="require",n=Ts(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:I(n),type:"require"}}function ws(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let s=Z(r.variable);return s?[{name:s}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(s=>Z(s.variable)??Z(s)).filter(s=>!!s).map(s=>({name:s}));let n=Z(r);return n?[{name:n}]:[]}function lc(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=Z(t.variable)??Z(t.variable?.base);return e?[{name:e}]:[]}function pc(t,e,r,n){let s=e.constructor?.name;if(s==="ImportDeclaration"){let o=ac(t,e);o&&r.push(o)}else if(s==="Call"){let o=cc(t,e);o&&r.push(o)}else if(s==="Assign"){let o=Z(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;o==="module"&&i==="exports"?n.push(...ws(e,void 0)):o==="exports"&&typeof i=="string"&&n.push(...ws(e,i))}else s==="ExportNamedDeclaration"&&e.clause?n.push(...lc(e.clause)):s==="ExportDefaultDeclaration"&&n.push({name:"default"})}function Or(t,e,r,n){if(!(!e||typeof e!="object")){pc(t,e,r,n);for(let s in e){if(s==="locationData")continue;let o=e[s];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)Or(t,i,r,n);else Or(t,o,r,n)}}}function Fs(t,e){let r=ye(e),n=xe(t,r),s=[],o=[];try{Or(t,Es.default.nodes(e),s,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Se=require("@cucumber/gherkin"),Ns=require("@cucumber/messages");var Ps=new Map;function be(t,e){Ps.set(t,e)}function As(t){return Ps.get(t)}var uc=Ns.IdGenerator.uuid();function jr(t,e){let r=new Set,n=s=>{for(let o of s)r.add(o.name.startsWith("@")?o.name.slice(1):o.name)};try{let s=new Se.AstBuilder(uc),o=new Se.GherkinClassicTokenMatcher,a=new Se.Parser(s,o).parse(e);if(a.feature){n(a.feature.tags);for(let c of a.feature.children){if(c.scenario){n(c.scenario.tags);for(let l of c.scenario.examples)n(l.tags)}if(c.rule)for(let l of c.rule.children)l.scenario&&n(l.scenario.tags)}}}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}be("gherkin",jr);var _s=d(require("path")),Ls=require("@lezer/go");function ee(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function te(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
7
+ `&&r++;return r}function mc(t,e){let r=1;function n(s){switch(s.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{s.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(s.from,s.to);(i==="&&"||i==="||")&&r++;break}}let o=s.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),r}function Ds(t,e,r,n){let s=r?1:1+e,o=ee(t),i=r?e:e+1,a=o[1];a&&a.type.name!=="Block"&&(s+=ke(a,i,!1,n));let c=o.find(p=>p.type.name==="Block");c&&(s+=ke(c,i,!1,n));let l=o.findIndex(p=>p.type.name==="else");if(l>=0){let p=o[l+1];p?.type.name==="IfStatement"?s+=Ds(p,e,!0,n):p&&(s+=1+ke(p,e+1,!1,n))}return s}function Rs(t,e,r){let n=1+e,s=t.firstChild;for(;s;)n+=ke(s,e+1,!1,r),s=s.nextSibling;return n}function fc(t,e,r){let n=0,s=t.firstChild;for(;s;)n+=ke(s,e,!1,r),s=s.nextSibling;return n}function gc(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function ke(t,e,r,n){let s=t.type.name;if(s==="IfStatement")return Ds(t,e,r,n);if(s==="ForStatement"||s==="SwitchStatement"||s==="SelectStatement")return Rs(t,e,n);let o=s==="LogicOp"&&gc(t,n)?1:0;return e>0&&s==="FunctionLiteral"?o+Rs(t,e,n):o+fc(t,e,n)}function dc(t,e){return ke(t,0,!1,e)}function Ct(t,e){return{complexity:mc(t,e),cognitiveComplexity:dc(t,e)}}function Wr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),s=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return s?e.slice(s.from,s.to):void 0}function Is(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let s=n.node.getChild("DefName");if(s){let o=e.slice(s.from,s.to),{complexity:i,cognitiveComplexity:a}=Ct(n.node,e);r.push({name:o,line:te(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let s=n.node.getChild("FieldName");if(s){let o=e.slice(s.from,s.to),i=Wr(n.node,e),a=i?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:l}=Ct(n.node,e);r.push({name:a,line:te(e,n.from),complexity:c,cognitiveComplexity:l})}}while(n.next());return r}var hc=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,yc=/^\/\/go:build\s+(.+)$/,xc=/^\/\/\s*\+build\s+(.+)$/;function Gs(t,e){let r=[],n=new Map,s=new Set,o=new Set,i=new Map,a=Ls.parser.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let x=e.slice(c.from,c.to),C=x.match(hc);C?.[1]&&s.add(C[1]);let A=x.match(yc);A&&Ms(A[1],o);let S=x.match(xc);S&&Ms(S[1],o);break}case"ImportSpec":{let x=c.node.getChild("String");if(x){let A=e.slice(x.from,x.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:A,isExternal:!0,isStyle:!1,type:"static"});let S=c.node.getChild("DefName"),E=S?e.slice(S.from,S.to):A.split("/").pop();E&&E!=="_"&&E!=="."&&i.set(E,A)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let x=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(x){let C=e.slice(x.from,x.to);C!=="_"&&/^[A-Z]/.test(C)&&!n.has(C)&&n.set(C,{name:C})}break}}while(c.next());let l=r.some(x=>x.rawSpecifier==="testing"),p=_s.default.basename(t).endsWith("_test.go")||s.has("test")||l?"test":"logic",u=new Set([...s,...o]),{complexity:m,cognitiveComplexity:g}=Ct(a.topNode,e),y=Is(a,e),v=p==="test"?[]:bc(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(u).map(x=>({name:x,kind:"comment-marker"})),category:p,rawCallEdges:v,complexity:m,cognitiveComplexity:g,...y.length>0?{functions:y}:{}}}function bc(t,e,r){let n=[];function s(i,a){if(i.type.name==="CallExpr"){let l=i.firstChild;if(l?.type.name==="SelectorExpr"){let p=l.firstChild,u=l.getChild("FieldName");if(p?.type.name==="VariableName"&&u){let m=e.slice(p.from,p.to),g=r.get(m);if(g){let y=e.slice(u.from,u.to);n.push({from:a,to:y,toSpecifier:g})}}}}let c=i.firstChild;for(;c;)s(c,a),c=c.nextSibling}let o=t.cursor();do if(o.name==="FunctionDecl"){let i=o.node.getChild("DefName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&s(a,c)}}else if(o.name==="MethodDecl"){let i=o.node.getChild("FieldName"),a=o.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),l=Wr(o.node,e);s(a,l?`${l}.${c}`:c)}}while(o.next());return n}function Ms(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var Sc=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,kc=["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"],vc=new RegExp(`/src/(${zr.join("|")})/`),Cc=/(?:Test|Tests|Spec|IT|ITCase)$/;function $r(t){let e=t.replace(/\.\w+$/,"");return Cc.test(e)}function ve(t){let e=new Set;for(let r of t.matchAll(Sc))r[1]&&e.add(r[1]);return e}function q(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,r=>r.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,r=>" ".repeat(r.length)),e}function Ce(t){let e=q(t),r=new Set;for(let s of e.matchAll(/@([A-Z]\w*)/g))s[1]&&r.add(s[1]);let n=new Set;for(let s of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))s[1]&&n.add(s[1]);return{annotations:[...r],typeNames:[...n]}}function we(t,e){return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static"}}function V(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect",isSamePackage:!0}}function M(t,e){let r=[];for(let n of q(t).split(`
8
+ `)){let s=n.trim();if(!s||s.startsWith("@")||s.startsWith("*"))continue;let o=s.match(/^package\s+(?:object\s+)?([\w.]+)/);if(o?.[1]){if(r.push(o[1]),!e)break;continue}if(!(e&&/^import\s/.test(s)))break}return r.length>0?r.join("."):null}var wc=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Ec=new Set(["Composable","Preview"]),Tc=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Fc=["Activity","Fragment","ViewModel","Screen","Composable"];function j(t,e,r={}){let n=t.replace(/\\/g,"/"),s=n.split("/").pop()??"";if(s.endsWith(".gradle")||s==="build.gradle.kts"||s==="settings.gradle.kts")return"config";if(vc.test(n)||e.some(i=>kc.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let o=r.annotations??[];return o.some(i=>wc.has(i))?"config":o.some(i=>Ec.has(i))||(r.typeNames??[]).some(i=>Fc.some(a=>i.endsWith(a)))?"ui":o.some(i=>Tc.has(i))?"logic":$r(s)?"test":"logic"}var Pc=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Ac=/^(?:@\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 Nc(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function Os(t,e){let r=ve(e),s=q(e).split(`
9
+ `),o=[],i=new Set;for(let l of s){let p=l.match(Pc);if(p?.[2]){let m=Nc(!!p[1],p[2]);m&&o.push(we(t,m));continue}let u=l.match(Ac);u?.[2]&&i.add(u[2])}let a=M(e,!1);a&&o.push(V(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:j(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ce(e).annotations})}}var $s=require("@lezer/java");var js=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Rc=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"]);function Dc(t,e){let r=1;function n(s){let o=s.type.name;if(o==="IfStatement"||o==="CatchClause"||o==="TernaryExpression")r++;else if(js.has(o))r++;else if(o==="SwitchLabel")s.firstChild?.type.name==="case"&&r++;else if(o==="LogicOp"){let a=e.slice(s.from,s.to);(a==="&&"||a==="||")&&r++}let i=s.firstChild;for(;i;)n(i),i=i.nextSibling}return n(t),r}function Ws(t,e,r,n){let s=r?1:1+e,o=[];for(let p=t.firstChild;p;p=p.nextSibling)o.push(p);let i=r?e:e+1,a=o[1];a&&a.type.name!=="Block"&&(s+=Ee(a,i,!1,n));let c=o.find(p=>p.type.name==="Block");c&&(s+=Ee(c,i,!1,n));let l=o.findIndex(p=>p.type.name==="else");if(l>=0){let p=o[l+1];p?.type.name==="IfStatement"?s+=Ws(p,e,!0,n):p&&(s+=1+Ee(p,e+1,!1,n))}return s}function Br(t,e,r){let n=1+e,s=t.firstChild;for(;s;)n+=Ee(s,e+1,!1,r),s=s.nextSibling;return n}function Ic(t,e,r){let n=0,s=t.firstChild;for(;s;)n+=Ee(s,e,!1,r),s=s.nextSibling;return n}function Mc(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function Ee(t,e,r,n){let s=t.type.name;if(s==="IfStatement")return Ws(t,e,r,n);if(js.has(s)||s==="SwitchStatement"||s==="CatchClause"||s==="TernaryExpression")return Br(t,e,n);let o=s==="LogicOp"&&Mc(t,n)?1:0;return e>0&&s==="LambdaExpression"?o+Br(t,e,n):o+Ic(t,e,n)}function _c(t,e){return Ee(t,0,!1,e)}function Hr(t,e){return{complexity:Dc(t,e),cognitiveComplexity:_c(t,e)}}function Ur(t,e){for(let r=t.parent;r;r=r.parent)if(Rc.has(r.type.name)){let n=r.getChild("Definition");if(n)return e.slice(n.from,n.to)}}function zs(t,e){let r=[],n=t.cursor();do if(n.name==="MethodDeclaration"||n.name==="ConstructorDeclaration"){let s=n.node.getChild("Definition");if(s){let o=e.slice(s.from,s.to),i=Ur(n.node,e),a=i&&n.name==="MethodDeclaration"?`${i}.${o}`:o,{complexity:c,cognitiveComplexity:l}=Hr(n.node,e);r.push({name:a,line:te(e,n.from),complexity:c,cognitiveComplexity:l})}}while(n.next());return r}var Lc=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/;function Gc(t,e){let r=t.getChild("ScopedIdentifier");if(!r)return null;let n=t.getChild("static")!=null,s=t.getChild("Asterisk")!=null,o=e.slice(r.from,r.to);return n?(s||(o=o.split(".").slice(0,-1).join(".")),o?{specifier:o,wildcard:!1}:null):s?{specifier:`${o}.*`,wildcard:!0}:{specifier:o,wildcard:!1}}function Oc(t){let e=new Map;for(let r of t){if(r.type==="side-effect")continue;let n=r.rawSpecifier;if(n.endsWith(".*"))continue;let s=n.split(".").pop();s&&e.set(s,n)}return e}function jc(t,e){let r=t;if(r.name==="GenericType"&&(r=r.firstChild),!r)return null;if(r.name==="TypeName")return e.slice(r.from,r.to);if(r.name==="ScopedTypeName"){let n=null;for(let s=r.firstChild;s;s=s.nextSibling)s.name==="TypeName"&&(n=s);return n?e.slice(n.from,n.to):null}return null}function Wc(t,e,r){let n=[];function s(i,a){let c=i.type.name;if(c==="MethodInvocation"){let p=i.firstChild;if(p?.type.name==="Identifier"){let u=r.get(e.slice(p.from,p.to)),m=i.getChild("MethodName");u&&m&&n.push({from:a,to:e.slice(m.from,m.to),toSpecifier:u})}}else if(c==="ObjectCreationExpression"){let p=i.getChild("TypeName")??i.getChild("GenericType")??i.getChild("ScopedTypeName"),u=p&&jc(p,e);if(u){let m=r.get(u);m&&n.push({from:a,to:"new",toSpecifier:m})}}let l=i.firstChild;for(;l;)s(l,a),l=l.nextSibling}let o=t.cursor();do if(o.name==="MethodDeclaration"||o.name==="ConstructorDeclaration"){let i=o.node.getChild("Definition"),a=o.node.getChild("Block")??o.node.getChild("ConstructorBody");if(i&&a){let c=e.slice(i.from,i.to),l=Ur(o.node,e),p=l&&o.name==="MethodDeclaration"?`${l}.${c}`:c;s(a,p)}}while(o.next());return n}function Bs(t,e){let r=[],n=new Map,s=new Set,o=new Set,i;try{i=$s.parser.parse(e)}catch{return{imports:[],exports:[],tags:[],category:j(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let y=e.slice(a.from,a.to).match(Lc);y?.[1]&&s.add(y[1]);break}case"MarkerAnnotation":case"Annotation":{let y=a.node.getChild("Identifier");y&&o.add(e.slice(y.from,y.to));break}case"ImportDeclaration":{let y=Gc(a.node,e);y&&r.push({fromPath:t,toPath:"",rawSpecifier:y.specifier,isExternal:!0,isStyle:!1,type:"static"});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let y=a.node.getChild("Definition");if(y){let v=e.slice(y.from,y.to);n.has(v)||n.set(v,{name:v})}}break}}while(a.next());let c=M(e,!1);c&&r.push(V(t,c));let l=j(t,r.map(y=>y.rawSpecifier),{typeNames:[...n.keys()],annotations:[...o]}),{complexity:p,cognitiveComplexity:u}=Hr(i.topNode,e),m=zs(i,e),g=l==="test"?[]:Wc(i,e,Oc(r));return{imports:r,exports:Array.from(n.values()),tags:Array.from(s).map(y=>({name:y,kind:"comment-marker"})),category:l,rawCallEdges:g,complexity:p,cognitiveComplexity:u,...m.length>0?{functions:m}:{}}}var zc=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Kr="(?: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+)*",$c=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Kr}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),Bc=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Kr}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Hc=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${Kr}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`);function Hs(t,e){let r=ve(e),s=q(e).split(`
10
+ `),o=[],i=new Set;for(let l of s){let p=l.match(zc);if(p?.[1]){o.push(we(t,p[1]));continue}let u=l.match($c);if(u?.[2]){i.add(u[2]);continue}let m=l.match(Bc);if(m?.[1]){i.add(m[1]);continue}let g=l.match(Hc);g?.[1]&&i.add(g[1])}let a=M(e,!1);a&&o.push(V(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:j(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ce(e).annotations})}}var Us=d(require("livescript"));function re(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Uc(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=re(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>re(r.key)??re(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=re(t);return e?[{name:e}]:[]}function Kc(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=re(r.head),o=r.tails?.[0]?.key?.name;if(n==="module"&&o==="exports")return Uc(t.right);if(n==="exports"&&typeof o=="string")return[{name:o}];if(r.head?.verb==="out"&&typeof o=="string")return[{name:o}]}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=>re(n.val)??re(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}var Jc=new Set(["first_line","first_column","last_line","last_column","line","column"]);function qc(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let s=J(n);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:I(s),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let s=n.args?.[0]?.value;if(typeof s=="string"){let o=J(s);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:I(o),type:"require"}}}}return null}function Jr(t,e,r){if(!t||typeof t!="object")return[];let n=[],s=qc(t,e);s&&n.push(s),r.push(...Kc(t));for(let o in t){if(Jc.has(o))continue;let i=t[o];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...Jr(a,e,r));else n.push(...Jr(i,e,r))}return n}function Ks(t,e){let r=ye(e),n=xe(t,r),s=[],o=[];try{s=Jr(Us.default.ast(e),t,o)}catch{}let i=new Set,a=o.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Js=d(require("luaparse"));function Vc(t,e){let r=[];function n(s){if(!(!s||typeof s!="object")){if((s.type==="CallExpression"||s.type==="StringCallExpression")&&s.base?.type==="Identifier"&&s.base?.name==="require"){let o;if(s.type==="CallExpression"){let i=s.arguments?.[0];i?.type==="StringLiteral"&&(o=J(i.raw))}else if(s.type==="StringCallExpression"){let i=s.argument;i?.type==="StringLiteral"&&(o=J(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:I(o),type:"require"})}for(let o in s){if(o==="loc")continue;let i=s[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Qc(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,s)=>{r.init[s]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Yc(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 s of r.fields)s.type==="TableKeyString"&&n.push({name:s.key.name});return n}function Xc(t){let e=t.body,r=Qc(e),n=Yc(e);for(let o of e)if(o.type==="FunctionDeclaration")o.identifier?.type==="MemberExpression"?o.identifier.base.type==="Identifier"&&r.has(o.identifier.base.name)&&n.push({name:o.identifier.identifier.name}):o.identifier?.type==="Identifier"&&!o.isLocal&&n.push({name:o.identifier.name});else if(o.type==="AssignmentStatement")for(let i of o.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let s=new Set;return n.filter(o=>s.has(o.name)?!1:(s.add(o.name),!0))}function qs(t,e){let r=ye(e),n=xe(t,r),s=[],o=[];try{let i=Js.default.parse(e);s=Vc(i,t),o=Xc(i)}catch{}return{imports:s,exports:o,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Zc=["http://","https://","mailto:","//"],el="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",tl=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${el})\\b`,"g"),Vs;async function rl(){return Vs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Vs}function nl(t){let e=t.trim();return e.length===0||e.startsWith("#")||Zc.some(r=>e.startsWith(r))}function sl(t,e){let r=t.match(tl);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static",isDocReference:!0})):[]}function Qs(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!nl(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static",isDocReference:!0}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...sl(t.value,e)),Array.isArray(t.children))for(let n of t.children)Qs(n,e,r)}async function Ys(t,e){let n=(await rl()).parse(e),s=[];Qs(n,t,s);let o=new Set;return{imports:s.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var eo=d(require("path")),to=require("@lezer/python");function ol(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=ee(n).filter(o=>o.type.name==="if"||o.type.name==="elif").length;break}case"TryStatement":{e+=ee(n).filter(o=>o.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let s=n.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),e}function il(t,e){let r=0,n=ee(t),s=0,o=0;for(;o<n.length;){let i=n[o];if(i?.type.name==="if"||i?.type.name==="elif"){let a=s>0;r+=a?1:1+e;let c=a?e:e+1,l=n[o+1],p=n[o+2];l&&(r+=W(l,c)),p&&(r+=W(p,c)),s++,o+=3}else if(i?.type.name==="else"){r+=1;let a=n[o+1];a&&(r+=W(a,e+1)),o+=2}else o++}return r}function al(t,e){let r=0,n=ee(t),s=0;for(;s<n.length;){let o=n[s];if(o?.type.name==="except"){for(r+=1+e,s++;s<n.length&&n[s]?.type.name!=="Body";)r+=W(n[s],e),s++;s<n.length&&(r+=W(n[s],e),s++)}else o?.type.name==="Body"&&(r+=W(o,e)),s++}return r}function Xs(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=W(n,e+1),n=n.nextSibling;return r}function cl(t,e){let r=0,n=t.firstChild;for(;n;)r+=W(n,e),n=n.nextSibling;return r}function W(t,e){let r=t.type.name;switch(r){case"IfStatement":return il(t,e);case"TryStatement":return al(t,e);case"ForStatement":case"WhileStatement":return Xs(t,e);default:{let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+Xs(t,e):n+cl(t,e)}}}function ll(t){return W(t,0)}function qr(t){return{complexity:ol(t),cognitiveComplexity:ll(t)}}function Zs(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:l}=qr(i);r.push({name:a,line:te(e,i.from),complexity:c,cognitiveComplexity:l})}function s(i){let a=i.firstChild;for(;a;)o(a),a=a.nextSibling}function o(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 p=l.firstChild;for(;p;){if(p.type.name==="FunctionDefinition"){let u=p.getChild("VariableName"),m=u?e.slice(u.from,u.to):void 0;m&&n(p,c?`${c}.${m}`:m),s(p)}else o(p);p=p.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),s(i);return}s(i)}return o(t.topNode),r}var pl=new Set(["pytest","unittest","nose","hypothesis"]);function ro(t,e){let r=[],n=[],s=new Set,o=eo.default.basename(t).toLowerCase(),i=to.parser.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let g=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);g?.[1]&&s.add(g[1]);break}case"ImportStatement":{for(let g of ul(a.node,e,t))r.push(g);break}case"FunctionDefinition":case"ClassDefinition":{let g=a.node.parent;if(g?.name==="Script"||g?.name==="DecoratedStatement"&&g.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&n.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let g=a.node.firstChild;g?.name==="VariableName"&&n.push({name:e.slice(g.from,g.to)})}break}}while(a.next());let c=yl(o,r,s);c==="test"&&s.add("test");let{complexity:l,cognitiveComplexity:p}=qr(i.topNode),u=Zs(i,e),m=c==="test"?[]:hl(i,e);return{imports:r,exports:n,tags:Array.from(s).map(g=>({name:g,kind:"comment-marker"})),category:c,rawCallEdges:m,complexity:l,cognitiveComplexity:p,...u.length>0?{functions:u}:{}}}function ul(t,e,r){let n=t.firstChild;return n?n.name==="from"?ml(t,e,r):fl(t,e,r):[]}function ml(t,e,r){let n=t.firstChild;if(!n)return[];let s=n.nextSibling;for(;s&&s.name!=="import";)s=s.nextSibling;if(!s)return[];let o=e.slice(n.to,s.from).trim(),i=gl(s.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let c=o.slice(a);if(a===0)return[Ue(r,o,i,!0)];let l=a===1?"./":"../".repeat(a-1);return c?[Ue(r,l+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Ue(r,l.slice(0,-1),["*"],!1)]:i.map(p=>Ue(r,l+p,[p],!1))}function fl(t,e,r){let n=[],s=t.firstChild?.nextSibling??null;for(;s;){if(s.name==="VariableName"){let o=e.slice(s.from,s.to);for(;s.nextSibling?.name==="."&&s.nextSibling.nextSibling?.name==="VariableName";)s=s.nextSibling.nextSibling,o+=`.${e.slice(s.from,s.to)}`;s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling),n.push(Ue(r,o,["*"],!0))}s=s.nextSibling}return n}function gl(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 dl(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let o=n.node.firstChild;if(o?.type.name!=="from")continue;let i=o.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(o.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let l=a.slice(c),p=c<=1?"./":"../".repeat(c-1),u=i.nextSibling;for(;u;){if(u.type.name==="VariableName"){let m=e.slice(u.from,u.to),g=m;if(u.nextSibling?.type.name==="as"){let v=u.nextSibling.nextSibling;v?.type.name==="VariableName"&&(g=e.slice(v.from,v.to),u=v)}let y=c===0?a:l?p+l.replace(/\./g,"/"):p+m;r.set(g,y)}u=u.nextSibling}}while(n.next());return r}function hl(t,e){let r=dl(t,e),n=[];function s(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let p=a.firstChild,u=e.slice(p.from,p.to),m=r.get(u);m&&n.push({from:c,to:u,toSpecifier:m})}let l=a.firstChild;for(;l;)s(l,c),l=l.nextSibling}function o(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,p=a.getChild("Body");if(p){let u=p.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let m=u.getChild("VariableName"),g=m?e.slice(m.from,m.to):void 0;g&&s(u,l?`${l}.${g}`:g)}else i(u);u=u.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&s(a,e.slice(c.from,c.to));return}o(a)}return i(t.topNode),n}function Ue(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function yl(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=>pl.has(n.rawSpecifier))?"test":"logic"}var xl=/^\s*import\s+(.+?)\s*$/,bl=/^(?:@\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_$]*)/;function Sl(t,e){let r=e.split("=>")[0]?.trim();return r?r==="_"||r==="*"||r==="given"?`${t}.*`:`${t}.${r}`:null}function kl(t){let e=t.indexOf("{");if(e!==-1){let n=t.indexOf("}",e),s=t.slice(0,e).trim().replace(/\.$/,""),o=t.slice(e+1,n===-1?void 0:n);return s?o.split(",").map(i=>Sl(s,i.trim())).filter(i=>i!=null):[]}let r=[];for(let n of t.split(",")){let s=n.trim().replace(/\s+as\s+\w+$/,"");if(s)if(s.endsWith("._")||s.endsWith(".*")||s.endsWith(".given")){let o=s.replace(/\.(_|\*|given)$/,"");o&&r.push(`${o}.*`)}else r.push(s)}return r}function no(t,e){let r=ve(e),s=q(e).split(`
11
+ `),o=[],i=new Set;for(let l of s){let p=l.match(xl);if(p?.[1]){for(let m of kl(p[1]))o.push(we(t,m));continue}let u=l.match(bl);u?.[2]&&i.add(u[2])}let a=M(e,!0);a&&o.push(V(t,a));let c=Array.from(i,l=>({name:l}));return{imports:o,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:j(t,o.map(l=>l.rawSpecifier),{typeNames:[...i],annotations:Ce(e).annotations})}}var Yr=d(require("path")),h=d(require("typescript"));var k=d(require("typescript"));function vl(t){let e=1;function r(n){switch(n.kind){case k.default.SyntaxKind.IfStatement:case k.default.SyntaxKind.ConditionalExpression:case k.default.SyntaxKind.ForStatement:case k.default.SyntaxKind.ForInStatement:case k.default.SyntaxKind.ForOfStatement:case k.default.SyntaxKind.WhileStatement:case k.default.SyntaxKind.DoStatement:case k.default.SyntaxKind.CatchClause:case k.default.SyntaxKind.CaseClause:e++;break;case k.default.SyntaxKind.BinaryExpression:{let s=n.operatorToken.kind;(s===k.default.SyntaxKind.AmpersandAmpersandToken||s===k.default.SyntaxKind.BarBarToken||s===k.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}k.default.forEachChild(n,r)}return r(t),e}function oo(t,e,r){let n=r?1:1+e,s=r?e:e+1;return n+=ne(t.expression,s,!1),n+=ne(t.thenStatement,s,!1),t.elseStatement&&(k.default.isIfStatement(t.elseStatement)?n+=oo(t.elseStatement,e,!0):n+=1+ne(t.elseStatement,e+1,!1)),n}function so(t,e){let r=1+e;return k.default.forEachChild(t,n=>{r+=ne(n,e+1,!1)}),r}function Cl(t,e){let r=1+e;return k.default.forEachChild(t,n=>{r+=ne(n,e,!1)}),r}function wl(t,e){let r=0;return k.default.forEachChild(t,n=>{r+=ne(n,e,!1)}),r}function El(t){let e=t.operatorToken.kind;return e===k.default.SyntaxKind.AmpersandAmpersandToken||e===k.default.SyntaxKind.BarBarToken||e===k.default.SyntaxKind.QuestionQuestionToken}function ne(t,e,r){if(k.default.isIfStatement(t))return oo(t,e,r);if(k.default.isForStatement(t)||k.default.isForInStatement(t)||k.default.isForOfStatement(t)||k.default.isWhileStatement(t)||k.default.isDoStatement(t)||k.default.isSwitchStatement(t))return so(t,e);if(k.default.isCatchClause(t))return Cl(t,e);let n=0;return k.default.isConditionalExpression(t)&&(n+=1),k.default.isBinaryExpression(t)&&El(t)&&(n+=1),e>0&&(k.default.isFunctionDeclaration(t)||k.default.isFunctionExpression(t)||k.default.isArrowFunction(t))?n+so(t,e):n+wl(t,e)}function Tl(t){return ne(t,0,!1)}function Vr(t){return{complexity:vl(t),cognitiveComplexity:Tl(t)}}var w=d(require("typescript")),Qr=new Set(["test","describe","it"]);function io(t,e){Fl(t,e),Al(t,e),Nl(t,e),Rl(t,e)}function Fl(t,e){if((w.default.isFunctionDeclaration(t)||w.default.isVariableDeclaration(t))&&t.name&&w.default.isIdentifier(t.name)&&Pl(t)){let r;if(w.default.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(w.default.isArrowFunction(n)||w.default.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Pl(t){if(w.default.isFunctionDeclaration(t))return w.default.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&w.default.isSourceFile(e.parent)}function Al(t,e){if(!w.default.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 Nl(t,e){if(!w.default.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),s=r.exec(n);for(;s!==null;)s[1]&&e.tags.add({name:s[1],kind:"comment-marker"}),s=r.exec(n)}function Rl(t,e){if(w.default.isCallExpression(t)&&Dl(t.expression))for(let r of t.arguments)w.default.isObjectLiteralExpression(r)&&Il(r,e)}function Dl(t){return w.default.isIdentifier(t)?Qr.has(t.text):!!(w.default.isPropertyAccessExpression(t)&&(Qr.has(t.name.text)||w.default.isIdentifier(t.expression)&&Qr.has(t.expression.text)))}function Il(t,e){for(let r of t.properties){if(!w.default.isPropertyAssignment(r)||!w.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,s=w.default.isArrayLiteralExpression(n)?n.elements.filter(w.default.isStringLiteral):r.name.text==="tag"&&w.default.isStringLiteral(n)?[n]:[];for(let o of s)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function Xr(t,e,r){let n=[],s=new Map,o=new Set,i=h.default.createSourceFile(t,e,h.default.ScriptTarget.Latest,!0,r==="typescript"?h.default.ScriptKind.TSX:h.default.ScriptKind.JSX),a={filePath:t,imports:n,exports:s,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{Gl(v,a),h.default.forEachChild(v,c)};c(i);let l=ql(t,a);(l==="test"||l==="barrel")&&o.add({name:l,kind:"comment-marker"}),l!=="test"&&Vl(a,i);let p=i.statements[0],u=p?co(p):void 0,{complexity:m,cognitiveComplexity:g}=Vr(i),y=Ml(i);return{imports:n,exports:Array.from(s.values()),tags:Array.from(o),category:l,rawCallEdges:a.rawCallEdges??[],complexity:m,cognitiveComplexity:g,...y.length>0?{functions:y}:{},...u!==void 0?{description:u}:{}}}function Ml(t){let e=[],r=(s,o)=>{let{complexity:i,cognitiveComplexity:a}=Vr(o),c=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:s,line:c,complexity:i,cognitiveComplexity:a})},n=(s,o)=>{if(h.default.isFunctionDeclaration(s)&&s.name&&s.body?r(s.name.text,s):h.default.isVariableDeclaration(s)&&h.default.isIdentifier(s.name)&&s.initializer&&(h.default.isArrowFunction(s.initializer)||h.default.isFunctionExpression(s.initializer))?r(s.name.text,s.initializer):o&&h.default.isMethodDeclaration(s)&&h.default.isIdentifier(s.name)&&s.body?r(`${o}.${s.name.text}`,s):o&&h.default.isConstructorDeclaration(s)&&s.body?r(`${o}.constructor`,s):o&&h.default.isGetAccessorDeclaration(s)&&h.default.isIdentifier(s.name)&&s.body?r(`${o}.get ${s.name.text}`,s):o&&h.default.isSetAccessorDeclaration(s)&&h.default.isIdentifier(s.name)&&s.body&&r(`${o}.set ${s.name.text}`,s),h.default.isClassDeclaration(s)&&s.name){let i=s.name.text;h.default.forEachChild(s,a=>n(a,i));return}h.default.forEachChild(s,i=>n(i,o))};return n(t,void 0),e}function ao(t,e,r,n){let s={name:t},o=co(r);o!==void 0&&(s.doc=o);let i=_l(e);i!==void 0&&(s.flags=i);let a=Ll(e,n);return a!==void 0&&(s.signature=a),s}function co(t){let e=h.default.getJSDocCommentsAndTags(t);for(let r of e)if(h.default.isJSDoc(r)&&r.comment)return h.default.getTextOfJSDocComment(r.comment)||void 0}function _l(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.default.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Ll(t,e){let r=h.default.createPrinter({removeComments:!0}),n=s=>r.printNode(h.default.EmitHint.Unspecified,s,e);if(h.default.isFunctionDeclaration(t)||h.default.isMethodDeclaration(t)){let s=t.parameters.map(n).join(", "),o=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${s}) => ${o}`}if(h.default.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.default.isArrowFunction(t.initializer)||h.default.isFunctionExpression(t.initializer))){let s=t.initializer,o=s.parameters.map(n).join(", "),i=s.type?n(s.type):"unknown";return`(${o}) => ${i}`}return}if(h.default.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.default.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.default.isTypeAliasDeclaration(t))return n(t.type);if(h.default.isEnumDeclaration(t))return`enum ${t.name.text}`}function Gl(t,e){Ol(t,e),jl(t,e),zl(t,e),$l(t,e),Jl(t,e),io(t,e)}function Ol(t,e){if(!h.default.isSourceFile(t))return;let r=t.statements.filter(n=>!h.default.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.default.isExportDeclaration(n)||h.default.isExportAssignment(n)||Zr(n)).length}function jl(t,e){if(h.default.isJsxElement(t)||h.default.isJsxSelfClosingElement(t)||h.default.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.default.isFunctionDeclaration(t)||h.default.isMethodDeclaration(t)||h.default.isArrowFunction(t)||h.default.isClassDeclaration(t)||h.default.isVariableStatement(t)||h.default.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.default.isExportDeclaration(t)&&!Wl(t)&&(e.hasTypesOnly=!1)}function Wl(t){return t.isTypeOnly?!0:!t.exportClause||!h.default.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function zl(t,e){if(!h.default.isImportDeclaration(t)||!t.moduleSpecifier||!h.default.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.default.isNamedImports(t.importClause.namedBindings))for(let s of t.importClause.namedBindings.elements)r.push(s.name.text);else h.default.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:I(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function $l(t,e){h.default.isExportDeclaration(t)?Bl(t,e):h.default.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Zr(t)&&Kl(t,e)}function Bl(t,e){if(t.moduleSpecifier&&h.default.isStringLiteral(t.moduleSpecifier))Hl(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.default.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function Hl(t,e,r){let n=Ul(t),s={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:I(e),type:"re-export"};n.length>0&&(s.symbols=n),r.imports.push(s)}function Ul(t){return t.exportClause?h.default.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Kl(t,e){if((h.default.isFunctionDeclaration(t)||h.default.isClassDeclaration(t)||h.default.isInterfaceDeclaration(t)||h.default.isTypeAliasDeclaration(t)||h.default.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,ao(n,t,t,e.sourceFile));return}if(h.default.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.default.isIdentifier(n.name)){let s=n.name.text;e.exports.set(s,ao(s,n,t,e.sourceFile))}}}function Jl(t,e){if(!h.default.isCallExpression(t))return;let r=t.arguments[0];!r||!h.default.isStringLiteral(r)||(t.expression.kind===h.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:I(r.text),type:"dynamic"}):h.default.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:I(r.text),type:"require"}))}function ql(t,e){let r=Yr.default.basename(t).toLowerCase(),n=Yr.default.extname(t).toLowerCase();return Ge().some(o=>r.includes(o))?"test":rs(r)?"config":e.imports.some(o=>ur().some(i=>o.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>gr()?"barrel":"logic"}function Zr(t){return h.default.canHaveModifiers(t)&&h.default.getModifiers(t)?.some(e=>e.kind===h.default.SyntaxKind.ExportKeyword)===!0}function Vl(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let s of e.statements){if(!h.default.isImportDeclaration(s)||!h.default.isStringLiteral(s.moduleSpecifier))continue;let o=s.moduleSpecifier.text,i=s.importClause;if(i&&(i.name&&n.set(i.name.text,o),i.namedBindings&&h.default.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,o)}if(n.size!==0)for(let s of e.statements){let o=Yl(s);if(o){let i=Xl(s);i&&wt(i,o,n,r);continue}h.default.isClassDeclaration(s)&&s.name&&Ql(s,s.name.text,n,r)}}function Ql(t,e,r,n){for(let s of t.members)h.default.isMethodDeclaration(s)&&s.body&&h.default.isIdentifier(s.name)?wt(s.body,`${e}.${s.name.text}`,r,n):h.default.isConstructorDeclaration(s)&&s.body&&wt(s.body,`${e}.constructor`,r,n)}function Yl(t){if(Zr(t)){if(h.default.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.default.isIdentifier(e.name)&&e.initializer&&(h.default.isArrowFunction(e.initializer)||h.default.isFunctionExpression(e.initializer)))return e.name.text}}}function Xl(t){if(h.default.isFunctionDeclaration(t))return t.body;if(h.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.default.isArrowFunction(e.initializer)||h.default.isFunctionExpression(e.initializer)))return e.initializer}}function wt(t,e,r,n){if(h.default.isCallExpression(t)&&h.default.isIdentifier(t.expression)){let s=t.expression.text,o=r.get(s);o&&!n.some(i=>i.from===e&&i.to===s&&i.toSpecifier===o)&&n.push({from:e,to:s,toSpecifier:o})}h.default.forEachChild(t,s=>wt(s,e,r,n))}function Et(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 en=d(require("postcss")),Zl=d(require("postcss-less")),ep=Zl,po=new Set(["reference","inline"]);function lo(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function tp(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function rp(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=po.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...lo(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),s=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return s?{fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static",...lo(s)?{isExternal:!0}:{}}:null}function np(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"";tp(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),s=n.exec(t)}return r}function uo(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let s=rp(n.params,e);s&&r.push(s)}n.type==="decl"&&r.push(...np(n.value,e))}),r}function sp(t){return t.replace(/(?<!:)\/\/.*/g,"")}function op(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let o=s[1]?.trim()??"",i=s[2]??"";if(i){let a=po.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}s=n.exec(t)}return r}function Tt(t,e){let r=en.default.parse(sp(t));return{imports:uo(r,e),root:r}}function ip(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:s}=n;if(s===void 0)continue;let o=n.name;o&&(e.push({name:o}),r.push({name:o,kind:"variable"}))}return{exports:e,tags:r}}function Ft(t,e){try{let r=ep.parse(t),{exports:n,tags:s}=ip(r);return{imports:uo(r,e),root:r,exports:n,tags:s}}catch{return{imports:op(t,e),root:en.default.parse(""),exports:[],tags:[]}}}var fo=require("postcss-scss");function mo(t){return t.startsWith("_")||t.startsWith("-")}function ap(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function cp(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],s=t.match(/\bas\s+(\S+)/)?.[1];return s!==void 0?{specifier:r,alias:s}:{specifier:r}}function lp(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let s=n.prop.slice(1);if(!s||mo(s))continue;e.push({name:s}),r.push({name:s,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let o=n.params.match(/^([\w-]+)/)?.[1];if(!o||mo(o))continue;let i=n.params.trim();e.push(i.includes("(")?{name:o,signature:i}:{name:o}),r.push({name:o,kind:"function"})}}return{exports:e,tags:r}}function Pt(t,e){let r=(0,fo.parse)(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:l,alias:p}=cp(c);if(!l)return;let u={fromPath:e,toPath:"",rawSpecifier:l,isStyle:!0,type:a==="forward"?"re-export":"static",...ap(l)?{isExternal:!0}:{}};p&&(u.symbols=[p]),n.push(u)});let{exports:s,tags:o}=lp(r);return{imports:n,root:r,exports:s,tags:o}}function go(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,s=n.exec(t);for(;s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),s=n.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(s=o.exec(t);s!==null;){let i=s[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),s=o.exec(t)}return r}function ho(t,e){if(e.length===0)return"ui";try{let r=require("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function Ke(t,e){let r=O(t);if(r==="stylus"){let o=go(e,t);return{imports:o,exports:[],tags:[],category:ho(e,o)}}if(r==="scss"){let{imports:o,root:i,exports:a,tags:c}=Pt(e,t);return{imports:o,exports:a,tags:c,category:Et(i,o)}}if(r==="less"){let{imports:o,root:i,exports:a,tags:c}=Ft(e,t);return{imports:o,exports:a,tags:c,category:Et(i,o)}}let{imports:n,root:s}=Tt(e,t);return{imports:n,exports:[],tags:[],category:Et(s,n)}}for(let[t,e]of[["javascript",(r,n)=>Xr(r,n,"javascript")],["typescript",(r,n)=>Xr(r,n,"typescript")],["css",Ke],["scss",Ke],["less",Ke],["stylus",Ke],["coffeescript",Fs],["livescript",Ks],["lua",qs],["python",ro],["go",Gs],["java",Bs],["kotlin",Hs],["scala",no],["groovy",Os],["gherkin",jr],["markdown",Ys]])be(t,e);async function yo(t,e){let r=O(t),n=As(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var tn=d(require("path"));function pp(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function bo(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(s=>s.name===n)&&e.push({name:n,kind:"library"})}}function up(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 mp(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 xo(t){return Math.round(t*1e4)/1e4}function fp(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let s=e.get(n.toPath);if(!s||s.exports.length===0)continue;let o;if(n.symbols===void 0){if(n.type==="side-effect")continue;o=1}else n.symbols.includes("*")?o=1:o=n.symbols.length/s.exports.length;n.exportUsageRatio=xo(Math.min(1,o)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=xo(r.reduce((n,s)=>n+s,0)/r.length),t.maxExportUsage=Math.max(...r))}function rn(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function gp(t,e){let r=e.toPath,n=tn.default.basename(r,tn.default.extname(r)).replace(/\.(test|spec)$/,"");rn(t.tags,n,"import")}function dp(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)rn(t.tags,r,"import")}function hp(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let s of n.tags)s.kind==="comment-marker"&&rn(t.tags,s.name,"comment-marker")}function yp(t,e,r){!e.toPath||e.isExternal||(gp(t,e),dp(t,e),hp(t,e,r))}function So(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(fp(r,t),e.size>0&&pp(r,e),r.category==="test")for(let n of r.imports)up(r,n,t),yp(r,n,t);mp(r,t)}}var ko=new Set(["java","kotlin","scala","groovy"]),vo=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),Co=new Set(["typescript","javascript","python"]),At=new Set(["typescript","javascript","go","python","java"]);function nn(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:vo.has(r),importSymbolsTracked:Co.has(r),callEdgesTracked:At.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var et=d(require("fs")),_=d(require("path"));var sn=d(require("fs")),se=d(require("path")),Je=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,s){let{mod:o,replaces:i}=this.readGoMod(n);if(!o)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return Eo(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let c=r.slice(o.length).replace(/^\//,"");return c?Eo(se.default.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let s=sn.default.readFileSync(se.default.join(e,"go.mod"),"utf-8"),o=xp(s,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[s,o]of r){if(e===s)return o;if(e.startsWith(`${s}/`)){let i=e.slice(s.length+1);return se.default.join(o,i)}}}};function xp(t,e){let r=t.split(`
12
+ `),n=null,s=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){wo(a,e,s);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&wo(a.replace(/^replace\s+/,""),e,s)}return{mod:n,replaces:s}}function wo(t,e,r){let[n,s]=t.split("=>").map(a=>a.trim());if(!n||!s)return;let o=n.split(/\s+/)[0];if(!s.startsWith(".")&&!s.startsWith("/"))return;let i=se.default.isAbsolute(s)?s:se.default.resolve(e,s);r.set(o,i)}function Eo(t){let e;try{e=sn.default.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:se.default.join(t,n.name),isExternal:!1})).sort((n,s)=>n.path.localeCompare(s.path));return r.length>0?r:null}var qe=d(require("fs")),Ve=d(require("path"));var bp=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Sp=12,To=4096,kp=new Set(zr);function Po(t){let e=t.replace(/\\/g,"/"),r=e.match(/^(.*)\/src\/([^/]+)(?:\/|$)/);if(!r?.[1]||!r[2]){let o=e.lastIndexOf("/");return{module:o===-1?e:e.slice(0,o),rootSegment:"",sourceRoot:"unknown"}}let n=r[2],s=n==="main"?"main":kp.has(n)?n:"unknown";return{module:r[1],rootSegment:n,sourceRoot:s}}var oe=class{constructor(e=[]){this.extraIgnoreDirs=e}extraIgnoreDirs;extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,r,n,s){let o=this.getIndex(n);if(o.size===0)return null;let i=r.endsWith(".*"),a=(i?r.slice(0,-2):r).split(".").filter(Boolean);if(a.length===0)return null;if(i){let c=o.get(a.join("."));if(!c)return null;let l=Po(e),p=c.filter(g=>g.module===l.module&&g.rootSegment===l.rootSegment),u=l.sourceRoot!=="main"&&l.sourceRoot!=="unknown",m=p.flatMap(g=>u?g.files:g.files.filter(y=>!$r(Fo(y))));return on(m)}for(let c=a.length-1;c>=1;c--){let l=Cp(o,a.slice(0,c).join("."));if(!l)continue;let p=a[c],u=l.filter(m=>Fo(m)===p);if(u.length>0)return on(u);if(c===a.length-1)return on(l)}return null}getIndex(e){let r=this.indexCache.get(e);if(r)return r;let n=vp(e,this.extraIgnoreDirs);return this.indexCache.set(e,n),n}};function vp(t,e=[]){let r=new Map,n=(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(a=>a.trim()).filter(Boolean),s=new Set([...R,...n,...e]),o=(a,c)=>{let{module:l,rootSegment:p,sourceRoot:u}=Po(c),m=r.get(a);if(!m){r.set(a,[{module:l,rootSegment:p,sourceRoot:u,files:[c]}]);return}let g=m.find(y=>y.module===l&&y.rootSegment===p);g?g.files.push(c):m.push({module:l,rootSegment:p,sourceRoot:u,files:[c]})},i=(a,c)=>{if(c>Sp)return;let l;try{l=qe.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let p of l){let u=Ve.default.join(a,p.name);if(p.isDirectory()){!p.name.startsWith(".")&&!s.has(p.name)&&i(u,c+1);continue}if(!p.isFile())continue;let m=Ve.default.extname(p.name);if(!bp.has(m))continue;let g=wp(u,m===".scala"||m===".sc");g&&o(g,u)}};i(t,0);for(let a of r.values())for(let c of a)c.files.sort();return r}function Cp(t,e){let r=t.get(e);if(!(!r||r.length===0))return r.length===1?r[0]?.files:r.flatMap(n=>n.files).sort()}function wp(t,e){let r;try{let n=qe.default.openSync(t,"r");try{let s=Buffer.alloc(To),o=qe.default.readSync(n,s,0,To,0);r=s.toString("utf8",0,o)}finally{qe.default.closeSync(n)}}catch{return null}return M(r,e)}function on(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function Fo(t){return Ve.default.basename(t,Ve.default.extname(t))}var Ao=d(require("fs")),Nt=d(require("path")),Qe=class{extensions=[".lua"];resolve(e,r,n,s){let o=r.replace(/\./g,Nt.default.sep),i=[n,Nt.default.join(n,"lib")];for(let a of i){if(!Ao.default.existsSync(a))continue;let c=s(Nt.default.join(a,"_dummy.lua"),o);if(c)return[c]}return null}};var No=d(require("path"));var Ep=new Set(R),Ye=class{extensions=[".md",".mdx"];resolve(e,r,n,s){let o=r.replace(/^\.\//,"").split("/")[0];if(o&&Ep.has(o))return null;let i=s(No.default.join(n,"_dummy"),`./${r}`);return i?[i]:null}};var Do=d(require("fs")),Rt=d(require("path")),Xe=class{extensions=[".py"];resolve(e,r,n,s){let o=r.replace(/\./g,Rt.default.sep),i=Rt.default.join(n,`${o}.py`);if(Ro(i))return[{path:i,isExternal:!1}];let a=Rt.default.join(n,o,"__init__.py");return Ro(a)?[{path:a,isExternal:!1}]:null}};function Ro(t){try{return Do.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var an=d(require("path")),Tp=["~","http://","https://","//","data:","sass:"],Ze=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,s){if(Tp.some(p=>r.startsWith(p)))return null;let o=s(e,r);if(o)return[o];let i=an.default.dirname(r),a=an.default.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,l=s(e,c);return l?[l]:null}};function Dt(t={}){return[new Xe,new Qe,new Je,t.jvm??new oe,new Ze,new Ye]}var z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??Dt()}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let r=0;r<this.langResolvers.length;r++)if(this.langResolvers[r]?.extensions.some(n=>e.endsWith(n)))return String(r);return"none"}cacheKey(e,r){return`${_.default.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),s=this.resolutionCache.get(n);if(s!==void 0)return s??[];let o=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,o.length>0?o:null),o}resolveAllUncached(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let s=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,s);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=_.default.dirname(e),s=r.startsWith("/")?r:_.default.resolve(n,r),o=!s.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=s.match(/\.(js|mjs|cjs)$/);if(a){let c=s.slice(0,-a[0].length);for(let l of[".ts",".tsx"]){let p=this.tryExtensions(c,l,o);if(p)return p}}for(let c of i){let l=this.tryExtensions(s,c,o);if(l)return l}return o?{path:s,isExternal:!0}:null}tryExtensions(e,r,n){let s=e+r;if(this.isFile(s))return{path:s,isExternal:n};let o=_.default.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:n};if(r===".py"){let i=_.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return et.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),s=this.pathAliases[r];if(n&&s){let o=this.tryAliasSubstitutions(s,n[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let n=_.default.join(r,"tsconfig.json");if(et.default.existsSync(n))try{let o=JSON.parse(et.default.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${s}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let s=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=_.default.resolve(n,i);for(let c of s){let l=this.tryExtensions(a,c,!1);if(l)return l}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let s=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!s){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=_.default.join(n,a);try{if(et.default.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...o,path:c}}catch{}}return{...o,path:n}}let i=this.resolveLocalPath(_.default.join(n,"_dummy"),s.slice(1));return i?{...o,path:i.path}:null}return null}};var Fp=["tests","test","__tests__","specs","spec"],Pp=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],Ap=600;function Np(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function Rp(t,e){if(t.length===0)return e;let r=t.map(i=>P.default.dirname(i).split(P.default.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let s=n.join(P.default.sep)||P.default.sep,o=P.default.relative(e,s);return o.startsWith("..")||P.default.isAbsolute(o)?e:s}var ie=class{constructor(e,r=null,n,s,o=!1,i=new Map,a=!0,c=[],l=null){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.docFiles=l;this.previousGraph=r,this.walkIgnoreDirs=new Set([...Pp,...c,...Np()]),this.resolver=n||new z(e),this.lockFile=Cs(e),s&&(this.progressCallback=s)}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 r=e.map(n=>P.default.isAbsolute(n)?n:P.default.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=hs(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(Rp(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
13
13
  Done. Total processed: ${this.visited.size} nodes.
14
- `),oo(this.graph.nodes,this.coverageMap),new A(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:{},r=e.minFiles??sp;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
14
+ `),So(this.graph.nodes,this.coverageMap),new D(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:{},r=e.minFiles??Ap;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
15
15
  Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
16
- `);try{let n=F.default.join(__dirname,"parse-worker.js");this.pool=new yo.default({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
16
+ `);try{let n=P.default.join(__dirname,"parse-worker.js");this.pool=new Io.default({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
17
17
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
18
- `),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,s=[e];for(;s.length>0;){let o=s.pop();if(o===void 0)continue;let i;try{i=xe.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||s.push(F.default.join(o,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=Ne(),n=o=>r.some(i=>o.name.includes(i));this.walkProject(e,n);let s=e;for(;s!==this.rootDir;){let o=F.default.dirname(s);if(o===s)break;for(let i of rp){let a=F.default.join(o,i);try{xe.default.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}s=o}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let n;try{n=xe.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of n){let o=F.default.join(e,s.name);s.isDirectory()?this.walkIgnoreDirs.has(s.name)||this.walkProject(o,r):s.isFile()&&r(s)&&this.enqueue(o)}}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(r=>this.finishFile(r)))}}async finishFile(e){let r=xe.default.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=F.default.relative(this.rootDir,e),s=await this.getNode(e,n,r);s.imports=await this.resolveImports(e,s.imports),so(s.imports,s.tags),this.graph.nodes.set(s.path,s)}async getNode(e,r,n){let s=this.previousGraph?.nodes.get(r);if(s&&s.mtime===n.mtimeMs&&s.size===n.size)return{...s};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,n,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=xe.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(s){return process.stderr.write(`
18
+ `),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,s=[e];for(;s.length>0;){let o=s.pop();if(o===void 0)continue;let i;try{i=Te.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||s.push(P.default.join(o,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=Ge(),n=o=>r.some(i=>o.name.includes(i));this.walkProject(e,n);let s=e;for(;s!==this.rootDir;){let o=P.default.dirname(s);if(o===s)break;for(let i of Fp){let a=P.default.join(o,i);try{Te.default.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}s=o}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,r){let n;try{n=Te.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of n){let o=P.default.join(e,s.name);s.isDirectory()?this.walkIgnoreDirs.has(s.name)||this.walkProject(o,r):s.isFile()&&r(s)&&this.enqueue(o)}}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(r=>this.finishFile(r)))}}async finishFile(e){let r=Te.default.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=P.default.relative(this.rootDir,e),s=await this.getNode(e,n,r);s.imports=await this.resolveImports(e,s.imports),bo(s.imports,s.tags),this.graph.nodes.set(s.path,s)}async getNode(e,r,n){let s=this.previousGraph?.nodes.get(r);if(s&&s.mtime===n.mtimeMs&&s.size===n.size)return{...s};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,n,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=Te.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(s){return process.stderr.write(`
19
19
  Warning: failed to parse ${r}: ${s}
20
- `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ro(e,r)}makeStubNode(e,r,n){return{path:r,type:G(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let s of r??[])try{let o=this.resolver.resolve(e,s.toSpecifier);o&&!o.isExternal&&n.push({from:s.from,to:s.to,toFile:F.default.relative(this.rootDir,o.path)})}catch{}return n}buildNode(e,r,n,s,o){let{imports:i,exports:a,tags:c,category:l,description:p,complexity:u,cognitiveComplexity:m,functions:h}=s;return{path:r,type:G(e),category:l,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...p!==void 0?{description:p}:{},...o.length>0?{callEdges:o}:{},...u!==void 0?{complexity:u}:{},...m!==void 0?{cognitiveComplexity:m}:{},...h!==void 0?{functions:h}:{}}}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 s of r){let o=this.resolver.resolveAll(e,s.rawSpecifier);if(!(o.length===0||s.type==="side-effect"&&s.rawSpecifier.endsWith(".*")&&o.every(a=>a.isExternal)))for(let a of o){if(!a.isExternal&&a.path===e)continue;let c={...s,toPath:a.isExternal?a.path:F.default.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&&io.has(G(e.fromPath))){let o=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(r))(o===a||o.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],s=n?this.lockFile.dependencies[n]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};var Yr=require("fs/promises"),ke=g(require("path")),Ao=g(require("piscina"));var ap=new Set(["css","scss","less","stylus"]);function xo(t){return ap.has(t)?"style":"code"}function cp(t){return t.trim().replace(/\s+/g," ")}function lp(t){try{return t.fileType==="scss"?vt(t.source,t.file).root:t.fileType==="less"?St(t.source,t.file).root:t.fileType==="css"?bt(t.source,t.file).root:void 0}catch{return}}function pp(t){let e=lp(t);if(!e)return[];let r=[];return e.walkRules(n=>{let s=n.nodes?.filter(p=>p.type==="decl")??[];if(s.length===0)return;let o=s[0],i=s[s.length-1],a=n.source?.start?.line??o?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let l=s.map(p=>`${p.prop.trim().toLowerCase()}:${cp(p.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:l,declCount:s.length})}),r}function bo(t,e,r=2){let n=new Map;for(let o of t)for(let i of pp(o)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let s=[];for(let o of n.values())for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){let c=o[i],l=o[a];if(c.file===l.file&&c.startLine===l.startLine&&c.endLine===l.endLine)continue;let p={file:c.file,startLine:c.startLine,endLine:c.endLine},u={file:l.file,startLine:l.startLine,endLine:l.endLine};s.push({occurrences:[p,u],lines:Math.min(c.lines,l.lines),tokens:c.declCount,family:"style"})}return s.sort((o,i)=>i.lines-o.lines)}function So(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let s=1;s<e;s++){let o=s-1;for(;t[s]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:s-1}),o=i.low}t[s]>n[n.length-1].lcpLength&&n.push({lcpLength:t[s],low:o})}for(;n.length>1;){let s=n.pop();r.push({lcpLength:s.lcpLength,low:s.low,high:e-1})}return r}var up=new Set(["{","}",":",",","[","]"]);function vo(t,e,r){let n=0;for(let s=e;s<e+r;s++)up.has(t[s].text)&&n++;return n/r}function ko(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(o,i)=>i),n=new Array(e);{let o=[...new Set(t)].sort(),i=new Map(o.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let s=new Array(e).fill(0);for(let o=1;o<e;o*=2){let i=a=>a+o<e?n[a+o]:-1;r.sort((a,c)=>{let l=n[a]-n[c];return l!==0?l:i(a)-i(c)}),s[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],l=r[a],p=n[c]===n[l],u=i(c)===i(l);s[l]=s[c]+(p&&u?0:1)}if([n,s]=[s,n],n[r[e-1]]===e-1)break}return r}function Co(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let s=new Array(r);for(let i=0;i<r;i++)s[e[i]]=i;let o=0;for(let i=0;i<r;i++){let a=s[i];if(a>0){let c=e[a-1];for(;i+o<r&&c+o<r&&t[i+o]===t[c+o];)o++;n[a]=o,o>0&&o--}else o=0}return n}function wo(t,e,r,n=.5){let s=[],o=[],i=new Map;for(let{file:u,tokens:m}of t)if(m.length!==0){i.set(u,m);for(let h=0;h<m.length;h++)s.push(m[h].text),o.push({file:u,localIndex:h});s.push(` ${u}`),o.push({file:u,localIndex:-1})}if(s.length===0)return[];let a=ko(s),c=Co(s,a),l=So(c),p=[];for(let u of l){let m=fp(u,a,o,i,e,r,n);m&&p.push(m)}return p.sort((u,m)=>m.lines-u.lines)}function fp(t,e,r,n,s,o,i){if(t.lcpLength<s)return;let a=[];for(let h=t.low;h<=t.high;h++){let y=r[e[h]];y.localIndex!==-1&&a.push(y)}if(a.length<2||!mp(a,n))return;let c=gp(a,t.lcpLength);if(c.length<2)return;let l=c[0],p=n.get(l.file);if(vo(p,l.localIndex,t.lcpLength)>i)return;let u=c.map(({file:h,localIndex:y})=>{let v=n.get(h);return{file:h,startLine:v[y].line,endLine:v[y+t.lcpLength-1].line}}),m=Math.min(...u.map(h=>h.endLine-h.startLine+1));if(!(m<o))return{occurrences:u,lines:m,tokens:t.lcpLength}}function mp(t,e){let r=null;for(let{file:n,localIndex:s}of t){if(s===0)return!0;let i=e.get(n)[s-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function gp(t,e){let r=new Map;for(let{file:s,localIndex:o}of t){let i=r.get(s);i?i.push(o):r.set(s,[o])}let n=[];for(let[s,o]of r){o.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of o)a>=i&&(n.push({file:s,localIndex:a}),i=a+e)}return n}var dp={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:[["<!--","-->"]]}};function Eo(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function hp(t,e){if(!e)return t;let r=t;for(let[n,s]of e.block??[]){let o=0;for(;;){let i=r.indexOf(n,o);if(i===-1)break;let a=r.indexOf(s,i+n.length),c=a===-1?r.length:a+s.length;r=Eo(r,i,c),o=c}}for(let n of e.line??[]){let s=0;for(;;){let o=r.indexOf(n,s);if(o===-1)break;let i=r.indexOf(`
21
- `,o),a=i===-1?r.length:i;r=Eo(r,o,a),s=a}}return r}var yp=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Qr=new RegExp(`${yp.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),xp=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Fo=/^\d+(?:\.\d+)?$/,bp=/^(".*"|'.*'|`.*`)$/s,Sp=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"]);function To(t,e,r=!0){let n=hp(t,dp[e]),s=[],o=1,i=0;Qr.lastIndex=0;let a=Qr.exec(n);for(;a!==null;){for(let p=i;p<a.index;p++)n[p]===`
22
- `&&o++;i=a.index;let c=a[0],l=c;xp.test(c)&&!Sp.has(c)?l="ID":r&&(Fo.test(c)||bp.test(c))&&(l=Fo.test(c)?"NUM":"STR"),s.push({text:l,line:o});for(let p=i;p<a.index+c.length;p++)n[p]===`
23
- `&&o++;i=a.index+c.length,a=Qr.exec(n)}return s}var be=g(require("fs")),Po=g(require("path"));function vp(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&Array.isArray(e.tokens)}function Se(t){try{if(!be.default.existsSync(t))return new Map;let e=be.default.readFileSync(t,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r))return new Map;let n=r.filter(s=>Array.isArray(s)&&s.length===2&&typeof s[0]=="string"&&vp(s[1]));return new Map(n)}catch{return new Map}}function ve(t,e){let r=Po.default.dirname(e);be.default.existsSync(r)||be.default.mkdirSync(r,{recursive:!0}),be.default.writeFileSync(e,JSON.stringify([...t.entries()]))}var kp=20,Cp=new Set(["css","scss","less"]);function wp(t){return Me.includes(ke.default.basename(t))}function Ep(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(ke.default.sep).some(n=>r.has(n))}async function Ce(t,e,r={}){let{minLines:n=6,windowSize:s=15,ignoreLiterals:o=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=P,parallelTokenizing:l=!0,tokenCache:p}=r,u=[...t.nodes.values()].filter(h=>!wp(h.path)&&!Ep(h.path,c)),m=Fp(l,u.length);try{let h=[],y=new Map;if(await Promise.all(u.map(async x=>{if(Cp.has(x.type)){let ie;try{ie=await(0,Yr.readFile)(ke.default.join(e,x.path),"utf8")}catch{return}h.push({file:x.path,source:ie,fileType:x.type});return}let k=p?.get(x.path),R=k&&k.mtime===x.mtime&&k.size===x.size&&k.ignoreLiterals===o,D;if(R)D=k.tokens;else{let ie;try{ie=await(0,Yr.readFile)(ke.default.join(e,x.path),"utf8")}catch{return}D=m?await m.run({source:ie,fileType:x.type,ignoreLiterals:o}):To(ie,x.type,o),p?.set(x.path,{mtime:x.mtime,size:x.size,ignoreLiterals:o,tokens:D})}let U=xo(x.type),jn={file:x.path,tokens:D},zn=y.get(U);zn?zn.push(jn):y.set(U,[jn])})),p){let x=new Set(u.map(k=>k.path));for(let k of p.keys())x.has(k)||p.delete(k)}let v=bo(h,n);for(let[x,k]of y)for(let R of wo(k,s,n,i))v.push({...R,family:x});return{groups:v.sort((x,k)=>k.lines-x.lines).slice(0,a)}}finally{m&&await m.destroy()}}function Fp(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??kp;if(e<n)return null;r.maxThreads!==void 0&&r.maxThreads<1&&process.stderr.write(`
20
+ `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):yo(e,r)}makeStubNode(e,r,n){return{path:r,type:O(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let s of r??[])try{let o=this.resolver.resolve(e,s.toSpecifier);o&&!o.isExternal&&n.push({from:s.from,to:s.to,toFile:P.default.relative(this.rootDir,o.path)})}catch{}return n}buildNode(e,r,n,s,o){let{imports:i,exports:a,tags:c,category:l,description:p,complexity:u,cognitiveComplexity:m,functions:g}=s;return{path:r,type:O(e),category:l,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...p!==void 0?{description:p}:{},...o.length>0?{callEdges:o}:{},...u!==void 0?{complexity:u}:{},...m!==void 0?{cognitiveComplexity:m}:{},...g!==void 0?{functions:g}:{}}}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 s of r){let o=this.resolver.resolveAll(e,s.rawSpecifier);if(!(o.length===0||s.type==="side-effect"&&s.rawSpecifier.endsWith(".*")&&o.every(a=>a.isExternal)))for(let a of o){if(!a.isExternal&&a.path===e)continue;let c={...s,toPath:a.isExternal?a.path:P.default.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&&ko.has(O(e.fromPath))){let o=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(r))(o===a||o.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],s=n?this.lockFile.dependencies[n]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};var pn=require("fs/promises"),Ne=d(require("path")),Ko=d(require("piscina"));var Dp=new Set(["css","scss","less","stylus"]);function Mo(t){return Dp.has(t)?"style":"code"}var cn=d(require("path")),Ip=new Set(["generated","__generated__","__generated","gen","__snapshots__"]),Mp=[".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"],_p=["@generated","do not edit","code generated by","autogenerated","auto-generated","this file was automatically generated","this is a generated file","jest snapshot v1"],Lp=500;function Gp(t,e){let r=t.split(/[\\/]/),n=/^\*\*\/(.+?)\/\*\*$/.exec(e);return n?r.includes(n[1]):e.startsWith("*.")?cn.default.basename(t).endsWith(e.slice(1)):r.includes(e)}function It(t,e=[]){if(t.split(/[\\/]/).some(s=>Ip.has(s)))return!0;let n=cn.default.basename(t);return Mp.some(s=>n.endsWith(s))?!0:e.some(s=>Gp(t,s))}function tt(t){let e=t.slice(0,Lp).toLowerCase();return _p.some(r=>e.includes(r))}function Op(t){return t.trim().replace(/\s+/g," ")}function jp(t){try{return t.fileType==="scss"?Pt(t.source,t.file).root:t.fileType==="less"?Ft(t.source,t.file).root:t.fileType==="css"?Tt(t.source,t.file).root:void 0}catch{return}}function Wp(t){let e=jp(t);if(!e)return[];let r=[];return e.walkRules(n=>{let s=n.nodes?.filter(p=>p.type==="decl")??[];if(s.length===0)return;let o=s[0],i=s[s.length-1],a=n.source?.start?.line??o?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let l=s.map(p=>`${p.prop.trim().toLowerCase()}:${Op(p.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:l,declCount:s.length})}),r}function _o(t,e,r=2){let n=new Map;for(let o of t)for(let i of Wp(o)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let s=[];for(let o of n.values())for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){let c=o[i],l=o[a];if(c.file===l.file&&c.startLine===l.startLine&&c.endLine===l.endLine)continue;let p={file:c.file,startLine:c.startLine,endLine:c.endLine},u={file:l.file,startLine:l.startLine,endLine:l.endLine};s.push({occurrences:[p,u],lines:Math.min(c.lines,l.lines),tokens:c.declCount,family:"style"})}return s.sort((o,i)=>i.lines-o.lines)}function Lo(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let s=1;s<e;s++){let o=s-1;for(;t[s]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:s-1}),o=i.low}t[s]>n[n.length-1].lcpLength&&n.push({lcpLength:t[s],low:o})}for(;n.length>1;){let s=n.pop();r.push({lcpLength:s.lcpLength,low:s.low,high:e-1})}return r}var zp=new Set(["{","}",":",",","[","]"]);function Go(t,e,r){let n=0;for(let s=e;s<e+r;s++)zp.has(t[s].text)&&n++;return n/r}function Oo(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(o,i)=>i),n=new Array(e);{let o=[...new Set(t)].sort(),i=new Map(o.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let s=new Array(e).fill(0);for(let o=1;o<e;o*=2){let i=a=>a+o<e?n[a+o]:-1;r.sort((a,c)=>{let l=n[a]-n[c];return l!==0?l:i(a)-i(c)}),s[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],l=r[a],p=n[c]===n[l],u=i(c)===i(l);s[l]=s[c]+(p&&u?0:1)}if([n,s]=[s,n],n[r[e-1]]===e-1)break}return r}function jo(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let s=new Array(r);for(let i=0;i<r;i++)s[e[i]]=i;let o=0;for(let i=0;i<r;i++){let a=s[i];if(a>0){let c=e[a-1];for(;i+o<r&&c+o<r&&t[i+o]===t[c+o];)o++;n[a]=o,o>0&&o--}else o=0}return n}function Wo(t,e,r,n=.5){let s=[],o=[],i=new Map;for(let{file:u,tokens:m}of t)if(m.length!==0){i.set(u,m);for(let g=0;g<m.length;g++)s.push(m[g].text),o.push({file:u,localIndex:g});s.push(` ${u}`),o.push({file:u,localIndex:-1})}if(s.length===0)return[];let a=Oo(s),c=jo(s,a),l=Lo(c),p=[];for(let u of l){let m=$p(u,a,o,i,e,r,n);m&&p.push(m)}return p.sort((u,m)=>m.lines-u.lines)}function $p(t,e,r,n,s,o,i){if(t.lcpLength<s)return;let a=[];for(let g=t.low;g<=t.high;g++){let y=r[e[g]];y.localIndex!==-1&&a.push(y)}if(a.length<2||!Bp(a,n))return;let c=Hp(a,t.lcpLength);if(c.length<2)return;let l=c[0],p=n.get(l.file);if(Go(p,l.localIndex,t.lcpLength)>i)return;let u=c.map(({file:g,localIndex:y})=>{let v=n.get(g);return{file:g,startLine:v[y].line,endLine:v[y+t.lcpLength-1].line}}),m=Math.min(...u.map(g=>g.endLine-g.startLine+1));if(!(m<o))return{occurrences:u,lines:m,tokens:t.lcpLength}}function Bp(t,e){let r=null;for(let{file:n,localIndex:s}of t){if(s===0)return!0;let i=e.get(n)[s-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function Hp(t,e){let r=new Map;for(let{file:s,localIndex:o}of t){let i=r.get(s);i?i.push(o):r.set(s,[o])}let n=[];for(let[s,o]of r){o.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of o)a>=i&&(n.push({file:s,localIndex:a}),i=a+e)}return n}var Up={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:[["<!--","-->"]]}};function zo(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function Kp(t,e){if(!e)return t;let r=t;for(let[n,s]of e.block??[]){let o=0;for(;;){let i=r.indexOf(n,o);if(i===-1)break;let a=r.indexOf(s,i+n.length),c=a===-1?r.length:a+s.length;r=zo(r,i,c),o=c}}for(let n of e.line??[]){let s=0;for(;;){let o=r.indexOf(n,s);if(o===-1)break;let i=r.indexOf(`
21
+ `,o),a=i===-1?r.length:i;r=zo(r,o,a),s=a}}return r}var Jp={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+/]};function qp(t,e){let r=Jp[e];if(!r)return t;let n=t.split(`
22
+ `),s=e==="go",o=!1,i=!1;for(let a=0;a<n.length;a++){let c=n[a],l=()=>{n[a]=c.replace(/[^\r]/g," ")};if(o){l(),c.includes(")")&&(o=!1);continue}if(i){l(),(/}\s*from\s/.test(c)||c.includes("}"))&&(i=!1);continue}r.some(p=>p.test(c))&&(l(),s&&/^\s*import\s+\(/.test(c)&&!c.includes(")")?o=!0:(e==="typescript"||e==="javascript")&&/^\s*import\b/.test(c)&&c.includes("{")&&!c.includes("}")&&(i=!0))}return n.join(`
23
+ `)}var Vp=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],ln=new RegExp(`${Vp.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Qp=/^[A-Za-z_$][A-Za-z0-9_$]*$/,$o=/^\d+(?:\.\d+)?$/,Yp=/^(".*"|'.*'|`.*`)$/s,Xp=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"]);function Bo(t,e,r=!0){let n=qp(Kp(t,Up[e]),e),s=[],o=1,i=0;ln.lastIndex=0;let a=ln.exec(n);for(;a!==null;){for(let p=i;p<a.index;p++)n[p]===`
24
+ `&&o++;i=a.index;let c=a[0],l=c;Qp.test(c)&&!Xp.has(c)?l="ID":r&&($o.test(c)||Yp.test(c))&&(l=$o.test(c)?"NUM":"STR"),s.push({text:l,line:o});for(let p=i;p<a.index+c.length;p++)n[p]===`
25
+ `&&o++;i=a.index+c.length,a=ln.exec(n)}return s}var Fe=d(require("fs")),Ho=d(require("path"));function Zp(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 Pe(t){try{if(!Fe.default.existsSync(t))return new Map;let e=Fe.default.readFileSync(t,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r))return new Map;let n=r.filter(s=>Array.isArray(s)&&s.length===2&&typeof s[0]=="string"&&Zp(s[1]));return new Map(n)}catch{return new Map}}function Ae(t,e){let r=Ho.default.dirname(e);Fe.default.existsSync(r)||Fe.default.mkdirSync(r,{recursive:!0}),Fe.default.writeFileSync(e,JSON.stringify([...t.entries()]))}var eu=20,tu=new Set(["css","scss","less"]);function ru(t){return We.includes(Ne.default.basename(t))}function nu(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(Ne.default.sep).some(n=>r.has(n))}function Uo(t,e){let r=[];return new Set(t.occurrences.map(n=>n.file)).size===1&&r.push("same-file"),t.occurrences.some(n=>e.has(n.file))&&r.push("generated"),r.length>0?{...t,signals:r}:t}async function Re(t,e,r={}){let{minLines:n=6,windowSize:s=15,ignoreLiterals:o=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=R,includeGenerated:l=!1,ignoreGlobs:p=[],parallelTokenizing:u=!0,tokenCache:m}=r,g=[...t.nodes.values()].filter(x=>!ru(x.path)&&!nu(x.path,c)),y=new Set,v=su(u,g.length);try{let x=[],C=new Map;if(await Promise.all(g.map(async S=>{let E=It(S.path,p);if(E&&!l)return;if(tu.has(S.type)){let U;try{U=await(0,pn.readFile)(Ne.default.join(e,S.path),"utf8")}catch{return}let es=E||tt(U);if(es&&!l)return;es&&y.add(S.path),x.push({file:S.path,source:U,fileType:S.type});return}let H=m?.get(S.path),Da=H&&H.mtime===S.mtime&&H.size===S.size&&H.ignoreLiterals===o,ut,ge;if(Da)ut=H.tokens,ge=H.generated;else{let U;try{U=await(0,pn.readFile)(Ne.default.join(e,S.path),"utf8")}catch{return}if(ge=E||tt(U),ge&&!l)return;ut=v?await v.run({source:U,fileType:S.type,ignoreLiterals:o}):Bo(U,S.type,o),m?.set(S.path,{mtime:S.mtime,size:S.size,ignoreLiterals:o,generated:ge,tokens:ut})}if(ge&&!l)return;ge&&y.add(S.path);let Yn=Mo(S.type),Xn={file:S.path,tokens:ut},Zn=C.get(Yn);Zn?Zn.push(Xn):C.set(Yn,[Xn])})),m){let S=new Set(g.map(E=>E.path));for(let E of m.keys())S.has(E)||m.delete(E)}let A=_o(x,n).map(S=>Uo(S,y));for(let[S,E]of C)for(let H of Wo(E,s,n,i))A.push(Uo({...H,family:S},y));return{groups:A.sort((S,E)=>E.lines-S.lines).slice(0,a)}}finally{v&&await v.destroy()}}function su(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??eu;if(e<n)return null;r.maxThreads!==void 0&&r.maxThreads<1&&process.stderr.write(`
24
26
  Warning: parallelTokenizing.maxThreads (${r.maxThreads}) must be at least 1; using 1.
25
- `);try{return new Ao.default({filename:ke.default.join(__dirname,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:Math.max(1,r.maxThreads)}:{}})}catch(s){return process.stderr.write(`
27
+ `);try{return new Ko.default({filename:Ne.default.join(__dirname,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:Math.max(1,r.maxThreads)}:{}})}catch(s){return process.stderr.write(`
26
28
  Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${s}
27
- `),null}}var ee=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,s=e.imports.find(c=>c.toPath===r);if(!s)return!1;let o=s.symbols||["*"],i=new Set;for(let c of o)(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 Qe(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function Zr(t,e,r=1){let n=[];return t.traverse(e,(s,o,i)=>{if(s.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===s.path):void 0;return n.push({path:s.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function Ye(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let s=n.imports.find(o=>o.toPath===e);return r.push({path:n.path,...s?.symbols?{symbols:s.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function Xr(t,e,r={}){let{testsOnly:n=!1,changedSymbols:s}=r,o=s?new ee(e,s):null,i=[];return t.traverse(e,(a,c,l)=>{if(a.path===e)return!0;if(o&&l&&!o.updateAffectedSymbols(a,l))return!1;let p=a.category==="test"||a.tags.some(u=>u.name==="test");return(!n||p)&&i.push(a.path),!0},{direction:"incoming"}),i}function en(t,e,r={}){let{depth:n=1,withEdgeDetail:s=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return s&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),o.push(a),!0},{direction:"incoming",maxDepth:n}),o}function we(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:s=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=n).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,s)}function tn(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 rn(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:s})=>({name:s.name,relativeRoot:s.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(s.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function te(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function No(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ee(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:s=50,minChurn:o=0,limit:i=20}=e,a=No(t),c=[...t.nodes.values()].filter(l=>l.coveragePct!==void 0&&l.coveragePct<=s&&(!a||(l.commitCount90d??0)>=o)).flatMap(l=>(l.functions??[]).filter(p=>p[r]>=n).map(p=>({file:l.path,name:p.name,line:p.line,complexity:p.complexity,cognitiveComplexity:p.cognitiveComplexity,coveragePct:l.coveragePct,...l.commitCount90d!==void 0&&{commitCount90d:l.commitCount90d}}))).sort((l,p)=>p[r]-l[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Ft=require("child_process"),Et=g(require("fs")),Do=g(require("os")),Ro=g(require("path"));function nn(t,e){try{return(0,Ft.execFileSync)("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 Io(t,e,r){let n=Et.default.mkdtempSync(Ro.default.join(Do.default.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));Et.default.rmdirSync(n);try{return(0,Ft.execFileSync)("git",["worktree","add","--detach",n,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await r(n)}finally{try{(0,Ft.execFileSync)("git",["worktree","remove","--force",n],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{Et.default.rmSync(n,{recursive:!0,force:!0})}}}async function zo(t,e,r,n={}){let s=nn(t,e),o=Yn(t,s);if(o)return{sha:s,graph:o};let i=await Io(t,s,async a=>{let c=n.pathAliases?new z(a,{pathAliases:n.pathAliases}):void 0;return new X(a,null,c,void 0,n.gitStats??!1,new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(r)});return Zn(t,s,i),{sha:s,graph:i}}var Mo=t=>Math.round(t*100)/100,Lo=t=>t.length>8?t.slice(0,8):t;function Tp(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function Pp(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function Ap(t,e=4){let r=t.occurrences.slice(0,e).map(o=>`${o.file}:${o.startLine}-${o.endLine}`),n=t.occurrences.length-r.length,s=n>0?`, +${n} more`:"";return`${t.lines}L x${t.occurrences.length}: ${r.join(", ")}${s}`}var re=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function Np(t,e){let{files:r,staleReferences:n,duplication:s,complexity:o,docDrift:i,coverage:a}=t,c=[],l=[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(l.length?`Files: ${l.join(", ")}`:"No file changes"),n.length>0&&c.push(`\u26A0 ${re(n.length,"stale reference")} \u2014 removed export still imported`);let p=o.newHotspots[0];return p?c.push(`+${re(o.newHotspots.length,"complexity hotspot")} (max ${e} ${p[e]} in ${p.file})`):o.resolvedHotspots.length>0&&c.push(`${re(o.resolvedHotspots.length,"complexity hotspot")} resolved`),s.newGroups.length>0?c.push(`+${re(s.newGroups.length,"duplication group")}`):s.resolvedGroups.length>0&&c.push(`${re(s.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${re(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${re(a.newHotspots.length,"risk hotspot")}`),c}function Dp(t){let{staleReferences:e,duplication:r,complexity:n,docDrift:s,coverage:o}=t;return e.length>0||(o?.newHotspots.length??0)>0?"attention":n.newHotspots.length>0||r.newGroups.length>0||s.newlyStale.length>0?"review-worthy":"clean"}function sn(t,e={}){let r=e.metric??"cognitiveComplexity",n=e.maxItems??8,s=e.maxPathList??100,{files:o,staleReferences:i,duplication:a,complexity:c,docDrift:l,coverage:p}=t,u=Mo(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),m=o.added.length+o.changed.length+o.removed.length,h={base:`${t.base.ref}@${Lo(t.base.sha)}`,head:`${t.head.ref}@${Lo(t.head.sha)}`,verdict:Dp(t),headline:Np(t,r),files:{added:o.added.length,changed:o.changed.length,removed:o.removed.length,...m<=s?{paths:{added:o.added,changed:o.changed,removed:o.removed}}:{}}};return i.length>0&&(h.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(h.complexity={avgDelta:u,newHotspots:c.newHotspots.slice(0,n).map(y=>Tp(y,r)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(h.duplication={newGroups:a.newGroups.slice(0,n).map(y=>Ap(y)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(l.newlyStale.length>0||l.resolved.length>0)&&(h.docDrift={newlyStale:l.newlyStale.slice(0,n).map(y=>y.replace("::"," \u2192 ")),newlyStaleCount:l.newlyStale.length,resolvedCount:l.resolved.length}),p&&(p.newHotspots.length>0||p.resolvedHotspots.length>0)&&(h.coverage={avgDelta:Mo(p.head.avgCoveragePct-p.base.avgCoveragePct),newHotspots:p.newHotspots.slice(0,n).map(y=>Pp(y,r)),newHotspotCount:p.newHotspots.length,resolvedCount:p.resolvedHotspots.length}),h}function Rp(t,e){let r=[],n=[];for(let[o,i]of e.nodes){let a=t.nodes.get(o);if(!a){r.push(o);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(p=>p.name).sort(),imports:a.imports.map(p=>p.toPath).sort()}),l=JSON.stringify({category:i.category,exports:i.exports.map(p=>p.name).sort(),imports:i.imports.map(p=>p.toPath).sort()});c!==l&&n.push(o)}let s=[...t.nodes.keys()].filter(o=>!e.nodes.has(o));return{added:r,removed:s,changed:n}}function Ip(t,e){let r=[];for(let[n,s]of t.nodes){let o=e.nodes.get(n);if(!o)continue;let i=new Set(o.exports.map(c=>c.name)),a=s.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(p=>p.imports.some(u=>u.toPath===n&&u.symbols?.includes(c))).map(p=>p.path);l.length>0&&r.push({file:n,symbol:c,stillReferencedBy:l})}}return r}function Tt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function Mp(t,e,r,n,s){let o=jo.default.join(ft(t),`${n}-${Re}`),i=Se(o),[{groups:a},{groups:c}]=await Promise.all([Ce(e,t,{minLines:s,tokenCache:i}),Ce(r,t,{minLines:s})]);ve(i,o);let l=new Set(a.map(Tt)),p=new Set(c.map(Tt));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(u=>!l.has(Tt(u))),resolvedGroups:a.filter(u=>!p.has(Tt(u)))}}function _o(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 Lp(t,e,r,n){let s=we(t,{metric:r,threshold:n,limit:1/0}),o=we(e,{metric:r,threshold:n,limit:1/0}),i=l=>`${l.file}:${l.name}`,a=new Set(s.map(i)),c=new Set(o.map(i));return{base:{avgCognitiveComplexity:_o(t)},head:{avgCognitiveComplexity:_o(e)},newHotspots:o.filter(l=>!a.has(i(l))),resolvedHotspots:s.filter(l=>!c.has(i(l)))}}function Go(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 _p(t,e){let r=Go(t),n=Go(e);return{base:{staleCount:r.size},head:{staleCount:n.size},newlyStale:[...n].filter(s=>!r.has(s)),resolved:[...r].filter(s=>!n.has(s))}}function Oo(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 Gp(t,e,r){if(!te(t)||!te(e))return null;let n=Ee(t,{maxCoveragePct:r,limit:1/0}).hotspots,s=Ee(e,{maxCoveragePct:r,limit:1/0}).hotspots,o=c=>`${c.file}:${c.name}`,i=new Set(n.map(o)),a=new Set(s.map(o));return{base:{avgCoveragePct:Oo(t)},head:{avgCoveragePct:Oo(e)},newHotspots:s.filter(c=>!i.has(o(c))),resolvedHotspots:n.filter(c=>!a.has(o(c)))}}async function on(t,e,r,n={}){let{sha:s,graph:o}=await zo(t,e,n.entryPoints??[],n),i=nn(t,n.headRef??"HEAD"),[a,c]=await Promise.all([Mp(t,o,r,s,n.minDuplicateLines),Promise.resolve(Gp(o,r,n.maxCoveragePct))]);return{base:{ref:e,sha:s},head:{ref:n.headRef??"HEAD",sha:i},files:Rp(o,r),staleReferences:Ip(o,r),duplication:a,complexity:Lp(o,r,n.complexityMetric,n.complexityThreshold),docDrift:_p(o,r),coverage:c}}var Ze=g(require("path"));function Op(t){let e=new Map;for(let[r,n]of t){let s=n.imports.filter(o=>o.toPath&&!o.isExternal).length;s>0&&e.set(r,s)}return e}function jp(t,e,r){let n=new Map;for(let[s,o]of e){if(o<r)continue;let i=t.get(s);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Ze.default.extname(s),c=Ze.default.basename(s,a),l=c==="index"?Ze.default.basename(Ze.default.dirname(s)):c;n.set(s,{path:s,outDegree:o,tag:`feature:${l}`})}return n}function ne(t,e){let r=e?.minOutDegree??5;return jp(t,Op(t),r)}var zp=(t,e)=>t.outDegree-e.outDegree;function Wp(t,e){let r=new Map;for(let n of e.values()){let s=new Set;t.traverse(n.path,o=>(o.path!==n.path&&s.add(o.path),!0),{direction:"outgoing"}),r.set(n.path,s)}return r}function $p(t,e,r,n){let s=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||n(a,i)<0)&&(i=a);i&&s.set(o,i.path)}return s}function Bp(t,e){let r=new Map;for(let n of t.values()){let s=n.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===n.path&&o.push(i);r.set(s,{hub:n.path,outDegree:n.outDegree,files:o})}return r}function Hp(t,e,r){let n=[];for(let s of t.keys())!e.has(s)&&!r.has(s)&&n.push(s);return n}function Xe(t,e){let r=e?.detectFn??ne,n=e?.hubComparator??zp,s=r(t.nodes,e),o=Wp(t,s),i=$p(t.nodes,s,o,n);return{features:Bp(s,i),unassigned:Hp(t.nodes,s,i)}}var Up=[{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 Wo(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=Kp(e);for(let n of Up)if(n.segments?.some(s=>Jp(e,s))||n.basenames?.includes(r))return n.role;return"other"}function Jp(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Kp(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function an(t,e){let r=Xe(t,e),n=new Map;for(let[o,i]of r.features){for(let a of i.files)n.set(a,o);n.set(i.hub,o)}let s=new Map;for(let o of t.nodes.values()){let i=n.get(o.path);s.set(o.path,{path:o.path,role:Wo(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return s}function cn(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(s=>s.name===e))if(kt.has(n.type)){let s=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:s})}else{let s=Ye(t,n.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:s})}return r}function qp(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Vp(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function ln(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let s of n.exports){if(!Vp(s,n.category))continue;let o=`${n.path}::${s.name}`;e.set(o,{name:s.name,file:n.path,kind:qp(s.signature),...s.doc?{doc:s.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let s of n.imports)if(!(!s.toPath||s.isExternal||!s.symbols?.length))for(let o of s.symbols)e.has(`${s.toPath}::${o}`)&&r.push({fromFile:n.path,toType:o,toFile:s.toPath})}return{types:e,edges:r}}function pn(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,s=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&n.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&s.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(s.values())}}var oi=g(require("path"));var fn=g(require("fs")),mn=g(require("path"));var $o=g(require("fs")),Nt=g(require("path"));var un=g(require("fs")),Qp=g(require("path"));function Pt(t){try{return un.default.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function At(t){try{return un.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Yp=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),Zp=new Set(P);function Bo(t,e=[]){let r;try{r=$o.default.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let n of r){let s=Nt.default.join(t,n.name);n.isDirectory()?!Zp.has(n.name)&&!n.name.startsWith(".")&&Bo(s,e):n.isFile()&&Yp.has(Nt.default.extname(n.name).toLowerCase())&&e.push(s)}return e}function Dt(t,e,r){if(!Pt(e))return null;let n=Bo(e);return n.length===0?null:{name:r,root:e,relativeRoot:Nt.default.relative(t,e),entryPoints:n}}function Xp(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function eu(t){let e=Xp(t),r=new Set;for(let n of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let s=n[1].replace(/^:/,"").replace(/:$/,"");s&&r.add(s)}return[...r]}var Ho={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(o=>mn.default.join(t,o)).find(o=>fn.default.existsSync(o));if(!e)return null;let r;try{r=fn.default.readFileSync(e,"utf-8")}catch{return null}let n=eu(r);if(n.length===0)return null;let s=[];for(let o of n){let i=mn.default.join(t,...o.split(":")),a=Dt(t,i,o);a&&s.push(a)}return s.length>0?s:null}};var Rt=g(require("fs")),dn=g(require("path"));var Fe=g(require("fs")),T=g(require("path"));function gn(t,e){let r=T.default.join(e,"package.json");if(!Fe.default.existsSync(r))return null;let n={};try{n=JSON.parse(Fe.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name;return s?{name:s,root:e,relativeRoot:T.default.relative(t,e),entryPoints:tu(e,n)}:null}function tu(t,e){let r=[];if(e.exports){let s=e.exports;if(typeof s=="string")r.push(T.default.join(t,s));else if(typeof s=="object"&&s!==null){let o=s["."];if(typeof o=="string")r.push(T.default.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(T.default.join(t,i))}}}e.main&&r.push(T.default.join(t,e.main));for(let s of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(T.default.join(t,s));let n=r.filter(At);return n.length>0?n.slice(0,1):r.slice(0,1)}function Te(t,e){let r=[],n=new Set;for(let s of e){let o=s.replace(/\/$/,"").replace(/^\.\//,"");ru(t,o,n,r)}return r}function ru(t,e,r,n){if(!e.includes("*")){nu(t,e,r,n);return}let s=e.split("/");s.includes("**")?su(t,s,r,n):ou(t,s,r,n)}function nu(t,e,r,n){let s=T.default.join(t,e);if(r.has(s)||!Pt(s))return;r.add(s);let o=gn(t,s);o&&n.push(o)}function su(t,e,r,n){let s=T.default.join(t,e[0]==="**"?"":e[0]??"");Uo(t,s,r,n)}function ou(t,e,r,n){let s=e.findIndex(a=>a.includes("*")),o=T.default.join(t,...e.slice(0,s)),i;try{i=Fe.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=T.default.join(o,a.name);if(r.has(c))continue;r.add(c);let l=gn(t,c);l&&n.push(l)}}function Uo(t,e,r,n){let s;try{s=Fe.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of s){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=T.default.join(e,o.name);if(Fe.default.existsSync(T.default.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=gn(t,i);a&&n.push(a)}else Uo(t,i,r,n)}}var Jo={type:"npm",detect(t){let e=dn.default.join(t,"package.json");if(!Rt.default.existsSync(e))return null;let r;try{r=JSON.parse(Rt.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||Rt.default.existsSync(dn.default.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:Te(t,n)}};var se=g(require("fs")),E=g(require("path"));var Ko={type:"nx",detect(t){return se.default.existsSync(E.default.join(t,"nx.json"))?qo(t,t,new Set,0).map(r=>iu(t,r,E.default.join(r,"project.json"))).filter(r=>r!==null):null}};function qo(t,e,r,n){if(n>4)return[];let s;try{s=se.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of s){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=E.default.join(e,a);se.default.existsSync(E.default.join(c,"project.json"))&&!r.has(c)?(r.add(c),o.push(c)):o.push(...qo(t,c,r,n+1))}return o}function iu(t,e,r){let n={};try{n=JSON.parse(se.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name,o,i,a=E.default.join(e,"package.json");if(se.default.existsSync(a))try{let c=JSON.parse(se.default.readFileSync(a,"utf-8"));s=c.name??s,o=c.main,i=c.exports}catch{}return s?{name:s,root:e,relativeRoot:E.default.relative(t,e),entryPoints:au(e,n,o,i)}:null}function au(t,e,r,n){let s=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=E.default.resolve(t,"../..");s.push(E.default.resolve(a,o)),s.push(E.default.resolve(t,o))}if(n){let a=n;if(typeof a=="string")s.push(E.default.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&s.push(E.default.join(t,c))}}if(r&&s.push(E.default.join(t,r)),e.sourceRoot){let a=E.default.resolve(t,"../.."),c=E.default.resolve(a,e.sourceRoot);s.push(E.default.join(c,"index.ts"),E.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])s.push(E.default.join(t,a));let i=s.filter(At);return i.length>0?i.slice(0,1):s.slice(0,1)}var hn=g(require("fs")),Vo=g(require("path")),Qo=require("js-yaml");var Yo={type:"pnpm",detect(t){let e=Vo.default.join(t,"pnpm-workspace.yaml");if(!hn.default.existsSync(e))return null;let r=[];try{r=(0,Qo.load)(hn.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return Te(t,r)}};var Pe=g(require("fs")),et=g(require("path"));function cu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function lu(t){let e=cu(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 s=n[1],i=n[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:s;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");r.has(c)||r.set(c,{name:s,dir:c})}return[...r.values()]}var Zo={type:"sbt",detect(t){let e=et.default.join(t,"build.sbt"),r=et.default.join(t,"project");if(!Pe.default.existsSync(e)||!Pe.default.existsSync(r))return null;let n=[];try{n.push(Pe.default.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of Pe.default.readdirSync(r))a.endsWith(".scala")&&n.push(Pe.default.readFileSync(et.default.join(r,a),"utf-8"))}catch{}let s=new Set,o=[];for(let a of n)for(let c of lu(a))s.has(c.dir)||(s.add(c.dir),o.push(c));if(o.length===0)return null;let i=[];for(let a of o){let c=et.default.join(t,...a.dir.split("/")),l=Dt(t,c,a.name);l&&i.push(l)}return i.length>0?i:null}};var Xo=g(require("fs")),ei=g(require("path")),ti={type:"turborepo",detect(t){return Xo.default.existsSync(ei.default.join(t,"turbo.json"))?[]:null}};var It=g(require("fs")),yn=g(require("path"));var ri={type:"yarn",detect(t){if(!It.default.existsSync(yn.default.join(t,"yarn.lock")))return null;let e=yn.default.join(t,"package.json");if(!It.default.existsSync(e))return null;let r;try{r=JSON.parse(It.default.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:Te(t,n)}};var ni=[];function L(t){ni.push(t)}function si(){return ni}L(ti);L(Ko);L(Yo);L(ri);L(Jo);L(Ho);L(Zo);function tt(t,e=si()){let r=oi.default.resolve(t),n=new Map,s=[];for(let i of e){let a=i.detect(r);if(a!==null){s.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(s.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(n.values());return{root:r,type:s[0],types:s,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var rt=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 s of r.imports){if(s.isExternal||s.isWorkspace)continue;let o=this.getPackageForFile(s.toPath);o&&o.name!==n.name&&(s.isWorkspace=!0,s.workspacePackage=o.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 s=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&s.add(i.workspacePackage);e.set(n.name,[...s])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let s=[];n.graph.traverse(e,o=>(o.path!==e&&s.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(l=>l.isWorkspace&&l.workspacePackage===r.name)&&s.push({file:a.path,package:i.name});return s}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:s}of e.packages){let o=new Map(s.map(a=>[a.path,a])),i=new A(o);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}};function ii(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function pu(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var uu=(t,e)=>!e.category||ii(t.category,e.category),fu=(t,e)=>!e.type||ii(t.type,e.type),mu=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,gu=(t,e)=>!e.path||pu(t.path,e.path),du=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,hu=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(s=>!s.startsWith("!")),n=e.tags.filter(s=>s.startsWith("!")).map(s=>s.slice(1));return!(r.length>0&&!r.some(s=>t.tags.some(o=>o.name===s))||n.some(s=>t.tags.some(o=>o.name===s)))},yu=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),xu=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),bu=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(s=>s.includes(e.importedBy)),Su=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,vu=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,ku=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Cu=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,wu=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Eu=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Fu=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Tu=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Pu=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Au=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Nu=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Du=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Ru=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Iu=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Mu=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Lu=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,_u=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Gu=(t,e,r)=>!e.any?.length||e.any.some(n=>nt(t,n,r)),Ou=[uu,fu,mu,gu,du,hu,yu,xu,bu,Su,vu,ku,Cu,wu,Eu,Fu,Tu,Pu,Au,Nu,Du,Ru,Iu,Mu,Lu,_u,Gu];function nt(t,e,r){return Ou.every(n=>n(t,e,r))}function Mt(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=>nt(i,e,r)),s=new Set(n.map(i=>i.path)),o=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||s.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,c)=>{let l=0;switch(e.sort){case"size":l=c.size-a.size;break;case"imports":l=c.imports.length-a.imports.length;break;case"commitCount90d":l=(c.commitCount90d??0)-(a.commitCount90d??0);break;case"exportUsage":l=(c.avgExportUsage??0)-(a.avgExportUsage??0);break;case"complexity":l=(c.complexity??0)-(a.complexity??0);break;case"cognitiveComplexity":l=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0);break}return l*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>s.has(a)))??void 0}}var ju={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"}};function zu(t,e,r,n){let s=t;switch(r){case"string":s[e]=n;break;case"int":s[e]=parseInt(n,10);break;case"float":s[e]=parseFloat(n);break;case"boolNotFalse":s[e]=n.toLowerCase()!=="false";break;case"boolIsTrue":s[e]=n.toLowerCase()==="true";break}}function ci(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),s=e.slice(r+1).trim();if(!n||!s)return;if(n==="tag"||n==="tags"){s.includes("+")?t.allTags=[...t.allTags??[],...s.split("+")]:t.tags=[...t.tags??[],s];return}if(n==="sort"){t.sort=s;return}if(n==="sortdir"){t.sortDir=s.toLowerCase()==="asc"?"asc":"desc";return}let o=ju[n];o&&zu(t,o.field,o.kind,s)}function Wu(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let s={};ci(s,n),Object.keys(s).length>0&&e.push(s)}return e}var ai="any(";function Lt(t){let e={},r=t.split(",");for(let n of r){let s=n.trim();if(s.toLowerCase().startsWith(ai)&&s.endsWith(")")){let o=s.slice(ai.length,-1),i=Wu(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}ci(e,n)}return e}var Ln=g(require("fs/promises")),Ei=g(require("path"));var Jt=g(require("path")),st=g(require("typescript"));var ui=g(require("path"));var pi=g(require("path")),w=g(require("typescript")),li=new Set(["describe","test","it"]);function oe(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function xn(t){let e=[];for(let r of t.statements){if(!w.default.isExpressionStatement(r))continue;let n=r.expression;if(!w.default.isCallExpression(n))continue;let s=n.expression;w.default.isIdentifier(s)&&li.has(s.text)&&e.push(n),w.default.isPropertyAccessExpression(s)&&w.default.isIdentifier(s.expression)&&li.has(s.expression.text)&&e.push(n)}return e}function bn(t,e,r){for(let n of t.arguments){if(!w.default.isObjectLiteralExpression(n))continue;let s=n.properties.find(o=>w.default.isPropertyAssignment(o)&&w.default.isIdentifier(o.name)&&o.name.text===e);if(!(!s||!w.default.isArrayLiteralExpression(s.initializer)))return s.initializer.elements.filter(w.default.isStringLiteral).map(o=>o.text)}return null}function Sn(t,e,r,n){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=oe(t.arguments,o);if(!w.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(l=>w.default.isPropertyAssignment(l)&&w.default.isIdentifier(l.name)&&l.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 s=oe(t.arguments,t.arguments.length-1);return{start:s.getStart(n),end:s.getStart(n),text:`{ ${e}: ${r} }, `}}function vn(t,e,r){let n=t.arguments;for(let s=1;s<n.length;s++){let o=oe(n,s);if(!w.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(c=>w.default.isPropertyAssignment(c)&&w.default.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:oe(n,s-1).getEnd(),end:o.getEnd(),text:""};let a=oe(o.properties,i);return i===o.properties.length-1?{start:oe(o.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:oe(o.properties,i+1).getStart(r),text:""}}return null}function kn(t,e){let r=[...e].sort((s,o)=>o.start-s.start),n=t;for(let s of r)n=n.slice(0,s.start)+s.text+n.slice(s.end);return n}function Cn(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var _=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function $u(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function _t(t,e,r,n){let s=w.default.createSourceFile(pi.default.basename(t),e,w.default.ScriptTarget.Latest,!0),o=xn(s),[i]=o;if(!i)return e;let a=bn(i,n,s),c=[...r].sort();if(a!==null&&JSON.stringify($u(a).sort())===JSON.stringify(c))return e;let l=Cn(c.map(u=>`@${u}`)),p=o.flatMap(u=>{let m=r.length===0?vn(u,n,s):Sn(u,n,l,s);return m?[m]:[]});return p.length>0?kn(e,p):e}var Gt=class{name="cypress";canHandle(e){return _.has(ui.default.extname(e).toLowerCase())}apply(e,r,n){return _t(e,r,n,"tags")}};var fi=g(require("path")),wn=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,En=/^@([a-zA-Z0-9_-]+)/gm;function Bu(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
29
+ `),null}}var ae=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,s=e.imports.find(c=>c.toPath===r);if(!s)return!1;let o=s.symbols||["*"],i=new Set;for(let c of o)(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 rt(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function un(t,e,r=1){let n=[];return t.traverse(e,(s,o,i)=>{if(s.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===s.path):void 0;return n.push({path:s.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function nt(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let s=n.imports.find(o=>o.toPath===e);return r.push({path:n.path,...s?.symbols?{symbols:s.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function mn(t,e,r={}){let{testsOnly:n=!1,changedSymbols:s}=r,o=s?new ae(e,s):null,i=[];return t.traverse(e,(a,c,l)=>{if(a.path===e)return!0;if(o&&l&&!o.updateAffectedSymbols(a,l))return!1;let p=a.category==="test"||a.tags.some(u=>u.name==="test");return(!n||p)&&i.push(a.path),!0},{direction:"incoming"}),i}function fn(t,e,r={}){let{depth:n=1,withEdgeDetail:s=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return s&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),o.push(a),!0},{direction:"incoming",maxDepth:n}),o}function De(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:s=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=n).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,s)}function gn(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 ce(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function Jo(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ie(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:s=50,minChurn:o=0,limit:i=20}=e,a=Jo(t),c=[...t.nodes.values()].filter(l=>l.coveragePct!==void 0&&l.coveragePct<=s&&(!a||(l.commitCount90d??0)>=o)).flatMap(l=>(l.functions??[]).filter(p=>p[r]>=n).map(p=>({file:l.path,name:p.name,line:p.line,complexity:p.complexity,cognitiveComplexity:p.cognitiveComplexity,coveragePct:l.coveragePct,...l.commitCount90d!==void 0&&{commitCount90d:l.commitCount90d}}))).sort((l,p)=>p[r]-l[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var _t=require("child_process"),Mt=d(require("fs")),qo=d(require("os")),Vo=d(require("path"));function dn(t,e){try{return(0,_t.execFileSync)("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 Qo(t,e,r){let n=Mt.default.mkdtempSync(Vo.default.join(qo.default.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));Mt.default.rmdirSync(n);try{return(0,_t.execFileSync)("git",["worktree","add","--detach",n,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await r(n)}finally{try{(0,_t.execFileSync)("git",["worktree","remove","--force",n],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{Mt.default.rmSync(n,{recursive:!0,force:!0})}}}async function ni(t,e,r,n={}){let s=dn(t,e),o=us(t,s);if(o)return{sha:s,graph:o};let i=await Qo(t,s,async a=>{let c=n.pathAliases?new z(a,{pathAliases:n.pathAliases}):void 0;return new ie(a,null,c,void 0,n.gitStats??!1,new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(r)});return ms(t,s,i),{sha:s,graph:i}}var Yo=t=>Math.round(t*100)/100,Xo=t=>t.length>8?t.slice(0,8):t;function ou(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function iu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function au(t,e=4){let r=t.occurrences.slice(0,e).map(o=>`${o.file}:${o.startLine}-${o.endLine}`),n=t.occurrences.length-r.length,s=n>0?`, +${n} more`:"";return`${t.lines}L x${t.occurrences.length}: ${r.join(", ")}${s}`}var le=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function cu(t,e){let{files:r,staleReferences:n,duplication:s,complexity:o,docDrift:i,coverage:a}=t,c=[],l=[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(l.length?`Files: ${l.join(", ")}`:"No file changes"),n.length>0&&c.push(`\u26A0 ${le(n.length,"stale reference")} \u2014 removed export still imported`);let p=o.newHotspots[0];return p?c.push(`+${le(o.newHotspots.length,"complexity hotspot")} (max ${e} ${p[e]} in ${p.file})`):o.resolvedHotspots.length>0&&c.push(`${le(o.resolvedHotspots.length,"complexity hotspot")} resolved`),s.newGroups.length>0?c.push(`+${le(s.newGroups.length,"duplication group")}`):s.resolvedGroups.length>0&&c.push(`${le(s.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${le(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${le(a.newHotspots.length,"risk hotspot")}`),c}function lu(t){let{staleReferences:e,duplication:r,complexity:n,docDrift:s,coverage:o}=t;return e.length>0||(o?.newHotspots.length??0)>0?"attention":n.newHotspots.length>0||r.newGroups.length>0||s.newlyStale.length>0?"review-worthy":"clean"}function hn(t,e={}){let r=e.metric??"cognitiveComplexity",n=e.maxItems??8,s=e.maxPathList??100,{files:o,staleReferences:i,duplication:a,complexity:c,docDrift:l,coverage:p}=t,u=Yo(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),m=o.added.length+o.changed.length+o.removed.length,g={base:`${t.base.ref}@${Xo(t.base.sha)}`,head:`${t.head.ref}@${Xo(t.head.sha)}`,verdict:lu(t),headline:cu(t,r),files:{added:o.added.length,changed:o.changed.length,removed:o.removed.length,...m<=s?{paths:{added:o.added,changed:o.changed,removed:o.removed}}:{}}};return i.length>0&&(g.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(g.complexity={avgDelta:u,newHotspots:c.newHotspots.slice(0,n).map(y=>ou(y,r)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(g.duplication={newGroups:a.newGroups.slice(0,n).map(y=>au(y)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(l.newlyStale.length>0||l.resolved.length>0)&&(g.docDrift={newlyStale:l.newlyStale.slice(0,n).map(y=>y.replace("::"," \u2192 ")),newlyStaleCount:l.newlyStale.length,resolvedCount:l.resolved.length}),p&&(p.newHotspots.length>0||p.resolvedHotspots.length>0)&&(g.coverage={avgDelta:Yo(p.head.avgCoveragePct-p.base.avgCoveragePct),newHotspots:p.newHotspots.slice(0,n).map(y=>iu(y,r)),newHotspotCount:p.newHotspots.length,resolvedCount:p.resolvedHotspots.length}),g}function pu(t,e){let r=[],n=[];for(let[o,i]of e.nodes){let a=t.nodes.get(o);if(!a){r.push(o);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(p=>p.name).sort(),imports:a.imports.map(p=>p.toPath).sort()}),l=JSON.stringify({category:i.category,exports:i.exports.map(p=>p.name).sort(),imports:i.imports.map(p=>p.toPath).sort()});c!==l&&n.push(o)}let s=[...t.nodes.keys()].filter(o=>!e.nodes.has(o));return{added:r,removed:s,changed:n}}function uu(t,e){let r=[];for(let[n,s]of t.nodes){let o=e.nodes.get(n);if(!o)continue;let i=new Set(o.exports.map(c=>c.name)),a=s.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(p=>p.imports.some(u=>u.toPath===n&&u.symbols?.includes(c))).map(p=>p.path);l.length>0&&r.push({file:n,symbol:c,stillReferencedBy:l})}}return r}function Lt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function mu(t,e,r,n,s){let o=ri.default.join(bt(t),`${n}-${je}`),i=Pe(o),[{groups:a},{groups:c}]=await Promise.all([Re(e,t,{minLines:s,tokenCache:i}),Re(r,t,{minLines:s})]);Ae(i,o);let l=new Set(a.map(Lt)),p=new Set(c.map(Lt));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(u=>!l.has(Lt(u))),resolvedGroups:a.filter(u=>!p.has(Lt(u)))}}function Zo(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 fu(t,e,r,n){let s=De(t,{metric:r,threshold:n,limit:1/0}),o=De(e,{metric:r,threshold:n,limit:1/0}),i=l=>`${l.file}:${l.name}`,a=new Set(s.map(i)),c=new Set(o.map(i));return{base:{avgCognitiveComplexity:Zo(t)},head:{avgCognitiveComplexity:Zo(e)},newHotspots:o.filter(l=>!a.has(i(l))),resolvedHotspots:s.filter(l=>!c.has(i(l)))}}function ei(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 gu(t,e){let r=ei(t),n=ei(e);return{base:{staleCount:r.size},head:{staleCount:n.size},newlyStale:[...n].filter(s=>!r.has(s)),resolved:[...r].filter(s=>!n.has(s))}}function ti(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 du(t,e,r){if(!ce(t)||!ce(e))return null;let n=Ie(t,{maxCoveragePct:r,limit:1/0}).hotspots,s=Ie(e,{maxCoveragePct:r,limit:1/0}).hotspots,o=c=>`${c.file}:${c.name}`,i=new Set(n.map(o)),a=new Set(s.map(o));return{base:{avgCoveragePct:ti(t)},head:{avgCoveragePct:ti(e)},newHotspots:s.filter(c=>!i.has(o(c))),resolvedHotspots:n.filter(c=>!a.has(o(c)))}}async function yn(t,e,r,n={}){let{sha:s,graph:o}=await ni(t,e,n.entryPoints??[],n),i=dn(t,n.headRef??"HEAD"),[a,c]=await Promise.all([mu(t,o,r,s,n.minDuplicateLines),Promise.resolve(du(o,r,n.maxCoveragePct))]);return{base:{ref:e,sha:s},head:{ref:n.headRef??"HEAD",sha:i},files:pu(o,r),staleReferences:uu(o,r),duplication:a,complexity:fu(o,r,n.complexityMetric,n.complexityThreshold),docDrift:gu(o,r),coverage:c}}var st=d(require("path"));function hu(t){let e=new Map;for(let[r,n]of t){let s=n.imports.filter(o=>o.toPath&&!o.isExternal).length;s>0&&e.set(r,s)}return e}function yu(t,e,r){let n=new Map;for(let[s,o]of e){if(o<r)continue;let i=t.get(s);if(!i||i.category==="test"||i.category==="barrel")continue;let a=st.default.extname(s),c=st.default.basename(s,a),l=c==="index"?st.default.basename(st.default.dirname(s)):c;n.set(s,{path:s,outDegree:o,tag:`feature:${l}`})}return n}function pe(t,e){let r=e?.minOutDegree??5;return yu(t,hu(t),r)}var xu=(t,e)=>t.outDegree-e.outDegree;function bu(t,e){let r=new Map;for(let n of e.values()){let s=new Set;t.traverse(n.path,o=>(o.path!==n.path&&s.add(o.path),!0),{direction:"outgoing"}),r.set(n.path,s)}return r}function Su(t,e,r,n){let s=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||n(a,i)<0)&&(i=a);i&&s.set(o,i.path)}return s}function ku(t,e){let r=new Map;for(let n of t.values()){let s=n.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===n.path&&o.push(i);r.set(s,{hub:n.path,outDegree:n.outDegree,files:o})}return r}function vu(t,e,r){let n=[];for(let s of t.keys())!e.has(s)&&!r.has(s)&&n.push(s);return n}function ot(t,e){let r=e?.detectFn??pe,n=e?.hubComparator??xu,s=r(t.nodes,e),o=bu(t,s),i=Su(t.nodes,s,o,n);return{features:ku(s,i),unassigned:vu(t.nodes,s,i)}}var Cu=[{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 si(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=Eu(e);for(let n of Cu)if(n.segments?.some(s=>wu(e,s))||n.basenames?.includes(r))return n.role;return"other"}function wu(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Eu(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function xn(t,e){let r=ot(t,e),n=new Map;for(let[o,i]of r.features){for(let a of i.files)n.set(a,o);n.set(i.hub,o)}let s=new Map;for(let o of t.nodes.values()){let i=n.get(o.path);s.set(o.path,{path:o.path,role:si(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return s}function bn(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(s=>s.name===e))if(At.has(n.type)){let s=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:s})}else{let s=nt(t,n.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:s})}return r}function Tu(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Fu(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Sn(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let s of n.exports){if(!Fu(s,n.category))continue;let o=`${n.path}::${s.name}`;e.set(o,{name:s.name,file:n.path,kind:Tu(s.signature),...s.doc?{doc:s.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let s of n.imports)if(!(!s.toPath||s.isExternal||!s.symbols?.length))for(let o of s.symbols)e.has(`${s.toPath}::${o}`)&&r.push({fromFile:n.path,toType:o,toFile:s.toPath})}return{types:e,edges:r}}function kn(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,s=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&n.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&s.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(s.values())}}var wi=d(require("path"));var Cn=d(require("fs")),wn=d(require("path"));var oi=d(require("fs")),jt=d(require("path"));var vn=d(require("fs")),Pu=d(require("path"));function Gt(t){try{return vn.default.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ot(t){try{return vn.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Au=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),Nu=new Set(R);function ii(t,e=[]){let r;try{r=oi.default.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let n of r){let s=jt.default.join(t,n.name);n.isDirectory()?!Nu.has(n.name)&&!n.name.startsWith(".")&&ii(s,e):n.isFile()&&Au.has(jt.default.extname(n.name).toLowerCase())&&e.push(s)}return e}function Wt(t,e,r){if(!Gt(e))return null;let n=ii(e);return n.length===0?null:{name:r,root:e,relativeRoot:jt.default.relative(t,e),entryPoints:n}}function Ru(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function Du(t){let e=Ru(t),r=new Set;for(let n of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let s=n[1].replace(/^:/,"").replace(/:$/,"");s&&r.add(s)}return[...r]}var ai={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(o=>wn.default.join(t,o)).find(o=>Cn.default.existsSync(o));if(!e)return null;let r;try{r=Cn.default.readFileSync(e,"utf-8")}catch{return null}let n=Du(r);if(n.length===0)return null;let s=[];for(let o of n){let i=wn.default.join(t,...o.split(":")),a=Wt(t,i,o);a&&s.push(a)}return s.length>0?s:null}};var zt=d(require("fs")),Tn=d(require("path"));var Me=d(require("fs")),N=d(require("path"));function En(t,e){let r=N.default.join(e,"package.json");if(!Me.default.existsSync(r))return null;let n={};try{n=JSON.parse(Me.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name;return s?{name:s,root:e,relativeRoot:N.default.relative(t,e),entryPoints:Iu(e,n)}:null}function Iu(t,e){let r=[];if(e.exports){let s=e.exports;if(typeof s=="string")r.push(N.default.join(t,s));else if(typeof s=="object"&&s!==null){let o=s["."];if(typeof o=="string")r.push(N.default.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(N.default.join(t,i))}}}e.main&&r.push(N.default.join(t,e.main));for(let s of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(N.default.join(t,s));let n=r.filter(Ot);return n.length>0?n.slice(0,1):r.slice(0,1)}function _e(t,e){let r=[],n=new Set;for(let s of e){let o=s.replace(/\/$/,"").replace(/^\.\//,"");Mu(t,o,n,r)}return r}function Mu(t,e,r,n){if(!e.includes("*")){_u(t,e,r,n);return}let s=e.split("/");s.includes("**")?Lu(t,s,r,n):Gu(t,s,r,n)}function _u(t,e,r,n){let s=N.default.join(t,e);if(r.has(s)||!Gt(s))return;r.add(s);let o=En(t,s);o&&n.push(o)}function Lu(t,e,r,n){let s=N.default.join(t,e[0]==="**"?"":e[0]??"");ci(t,s,r,n)}function Gu(t,e,r,n){let s=e.findIndex(a=>a.includes("*")),o=N.default.join(t,...e.slice(0,s)),i;try{i=Me.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=N.default.join(o,a.name);if(r.has(c))continue;r.add(c);let l=En(t,c);l&&n.push(l)}}function ci(t,e,r,n){let s;try{s=Me.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of s){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=N.default.join(e,o.name);if(Me.default.existsSync(N.default.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=En(t,i);a&&n.push(a)}else ci(t,i,r,n)}}var li={type:"npm",detect(t){let e=Tn.default.join(t,"package.json");if(!zt.default.existsSync(e))return null;let r;try{r=JSON.parse(zt.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||zt.default.existsSync(Tn.default.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:_e(t,n)}};var ue=d(require("fs")),F=d(require("path"));var pi={type:"nx",detect(t){return ue.default.existsSync(F.default.join(t,"nx.json"))?ui(t,t,new Set,0).map(r=>Ou(t,r,F.default.join(r,"project.json"))).filter(r=>r!==null):null}};function ui(t,e,r,n){if(n>4)return[];let s;try{s=ue.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of s){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=F.default.join(e,a);ue.default.existsSync(F.default.join(c,"project.json"))&&!r.has(c)?(r.add(c),o.push(c)):o.push(...ui(t,c,r,n+1))}return o}function Ou(t,e,r){let n={};try{n=JSON.parse(ue.default.readFileSync(r,"utf-8"))}catch{return null}let s=n.name,o,i,a=F.default.join(e,"package.json");if(ue.default.existsSync(a))try{let c=JSON.parse(ue.default.readFileSync(a,"utf-8"));s=c.name??s,o=c.main,i=c.exports}catch{}return s?{name:s,root:e,relativeRoot:F.default.relative(t,e),entryPoints:ju(e,n,o,i)}:null}function ju(t,e,r,n){let s=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=F.default.resolve(t,"../..");s.push(F.default.resolve(a,o)),s.push(F.default.resolve(t,o))}if(n){let a=n;if(typeof a=="string")s.push(F.default.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&s.push(F.default.join(t,c))}}if(r&&s.push(F.default.join(t,r)),e.sourceRoot){let a=F.default.resolve(t,"../.."),c=F.default.resolve(a,e.sourceRoot);s.push(F.default.join(c,"index.ts"),F.default.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])s.push(F.default.join(t,a));let i=s.filter(Ot);return i.length>0?i.slice(0,1):s.slice(0,1)}var Fn=d(require("fs")),mi=d(require("path")),fi=require("js-yaml");var gi={type:"pnpm",detect(t){let e=mi.default.join(t,"pnpm-workspace.yaml");if(!Fn.default.existsSync(e))return null;let r=[];try{r=(0,fi.load)(Fn.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return _e(t,r)}};var Le=d(require("fs")),it=d(require("path"));function Wu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function zu(t){let e=Wu(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 s=n[1],i=n[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:s;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");r.has(c)||r.set(c,{name:s,dir:c})}return[...r.values()]}var di={type:"sbt",detect(t){let e=it.default.join(t,"build.sbt"),r=it.default.join(t,"project");if(!Le.default.existsSync(e)||!Le.default.existsSync(r))return null;let n=[];try{n.push(Le.default.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of Le.default.readdirSync(r))a.endsWith(".scala")&&n.push(Le.default.readFileSync(it.default.join(r,a),"utf-8"))}catch{}let s=new Set,o=[];for(let a of n)for(let c of zu(a))s.has(c.dir)||(s.add(c.dir),o.push(c));if(o.length===0)return null;let i=[];for(let a of o){let c=it.default.join(t,...a.dir.split("/")),l=Wt(t,c,a.name);l&&i.push(l)}return i.length>0?i:null}};var hi=d(require("fs")),yi=d(require("path")),xi={type:"turborepo",detect(t){return hi.default.existsSync(yi.default.join(t,"turbo.json"))?[]:null}};var $t=d(require("fs")),Pn=d(require("path"));var bi={type:"yarn",detect(t){if(!$t.default.existsSync(Pn.default.join(t,"yarn.lock")))return null;let e=Pn.default.join(t,"package.json");if(!$t.default.existsSync(e))return null;let r;try{r=JSON.parse($t.default.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:_e(t,n)}};var Si=[];function L(t){Si.push(t)}function ki(){return Si}var vi=d(require("fs")),Ci=d(require("path")),$u=["dependencies","devDependencies","peerDependencies","optionalDependencies"];function Bu(t){try{let e=vi.default.readFileSync(Ci.default.join(t,"package.json"),"utf-8"),r=JSON.parse(e),n=new Set;for(let s of $u){let o=r[s];if(o&&typeof o=="object")for(let i of Object.keys(o))n.add(i)}return n}catch{return null}}function at(t,e){if(e){let o=e.getPackageDependencies(),i=Array.from(e.packages.values()).map(({graph:a,pkg:c})=>({name:c.name,relativeRoot:c.relativeRoot,dependsOn:o.get(c.name)??[],nodeCount:a.nodes.size}));return{monorepoType:t.type,monorepoTypes:t.types,packageCount:i.length,packages:i,dependsOnResolved:!0,nodeCountsResolved:!0}}let r=new Set(t.packages.map(o=>o.name)),n=!0,s=t.packages.map(o=>{let i=Bu(o.root);if(i===null)return n=!1,{name:o.name,relativeRoot:o.relativeRoot,dependsOn:[]};let a=[...i].filter(c=>c!==o.name&&r.has(c)).sort();return{name:o.name,relativeRoot:o.relativeRoot,dependsOn:a}});return{monorepoType:t.type,monorepoTypes:t.types,packageCount:s.length,packages:s,dependsOnResolved:n,nodeCountsResolved:!1,note:"Layout only \u2014 per-package node counts and (for build-system monorepos without package.json) dependency edges require a full graph. Call analyze with empty entryPoints, then get_workspace_packages again."}}L(xi);L(pi);L(gi);L(bi);L(li);L(ai);L(di);function ct(t,e=ki()){let r=wi.default.resolve(t),n=new Map,s=[];for(let i of e){let a=i.detect(r);if(a!==null){s.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(s.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(n.values());return{root:r,type:s[0],types:s,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var me=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 s of r.imports){if(s.isExternal||s.isWorkspace)continue;let o=this.getPackageForFile(s.toPath);o&&o.name!==n.name&&(s.isWorkspace=!0,s.workspacePackage=o.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 s=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&s.add(i.workspacePackage);e.set(n.name,[...s])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let s=[];n.graph.traverse(e,o=>(o.path!==e&&s.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(l=>l.isWorkspace&&l.workspacePackage===r.name)&&s.push({file:a.path,package:i.name});return s}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:s}of e.packages){let o=new Map(s.map(a=>[a.path,a])),i=new D(o);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}};function Ei(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Hu(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var Uu=(t,e)=>!e.category||Ei(t.category,e.category),Ku=(t,e)=>!e.type||Ei(t.type,e.type),Ju=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,qu=(t,e)=>!e.path||Hu(t.path,e.path),Vu=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,Qu=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(s=>!s.startsWith("!")),n=e.tags.filter(s=>s.startsWith("!")).map(s=>s.slice(1));return!(r.length>0&&!r.some(s=>t.tags.some(o=>o.name===s))||n.some(s=>t.tags.some(o=>o.name===s)))},Yu=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),Xu=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),Zu=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(s=>s.includes(e.importedBy)),em=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,tm=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,rm=(t,e)=>e.minSize===void 0||t.size>=e.minSize,nm=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,sm=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,om=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,im=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,am=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,cm=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,lm=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,pm=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,um=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,mm=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,fm=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,gm=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,dm=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,hm=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,ym=(t,e,r)=>!e.any?.length||e.any.some(n=>lt(t,n,r)),xm=[Uu,Ku,Ju,qu,Vu,Qu,Yu,Xu,Zu,em,tm,rm,nm,sm,om,im,am,cm,lm,pm,um,mm,fm,gm,dm,hm,ym];function lt(t,e,r){return xm.every(n=>n(t,e,r))}function Bt(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=>lt(i,e,r)),s=new Set(n.map(i=>i.path)),o=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||s.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,c)=>{let l=0;switch(e.sort){case"size":l=c.size-a.size;break;case"imports":l=c.imports.length-a.imports.length;break;case"commitCount90d":l=(c.commitCount90d??0)-(a.commitCount90d??0);break;case"exportUsage":l=(c.avgExportUsage??0)-(a.avgExportUsage??0);break;case"complexity":l=(c.complexity??0)-(a.complexity??0);break;case"cognitiveComplexity":l=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0);break}return l*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>s.has(a)))??void 0}}var bm={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"}};function Sm(t,e,r,n){let s=t;switch(r){case"string":s[e]=n;break;case"int":s[e]=parseInt(n,10);break;case"float":s[e]=parseFloat(n);break;case"boolNotFalse":s[e]=n.toLowerCase()!=="false";break;case"boolIsTrue":s[e]=n.toLowerCase()==="true";break}}function Fi(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),s=e.slice(r+1).trim();if(!n||!s)return;if(n==="tag"||n==="tags"){s.includes("+")?t.allTags=[...t.allTags??[],...s.split("+")]:t.tags=[...t.tags??[],s];return}if(n==="sort"){t.sort=s;return}if(n==="sortdir"){t.sortDir=s.toLowerCase()==="asc"?"asc":"desc";return}let o=bm[n];o&&Sm(t,o.field,o.kind,s)}function km(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let s={};Fi(s,n),Object.keys(s).length>0&&e.push(s)}return e}var Ti="any(";function Ht(t){let e={},r=t.split(",");for(let n of r){let s=n.trim();if(s.toLowerCase().startsWith(Ti)&&s.endsWith(")")){let o=s.slice(Ti.length,-1),i=km(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Fi(e,n)}return e}var Kn=d(require("fs/promises")),Hi=d(require("path"));var tr=d(require("path")),pt=d(require("typescript"));var Ni=d(require("path"));var Ai=d(require("path")),T=d(require("typescript")),Pi=new Set(["describe","test","it"]);function fe(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function An(t){let e=[];for(let r of t.statements){if(!T.default.isExpressionStatement(r))continue;let n=r.expression;if(!T.default.isCallExpression(n))continue;let s=n.expression;T.default.isIdentifier(s)&&Pi.has(s.text)&&e.push(n),T.default.isPropertyAccessExpression(s)&&T.default.isIdentifier(s.expression)&&Pi.has(s.expression.text)&&e.push(n)}return e}function Nn(t,e,r){for(let n of t.arguments){if(!T.default.isObjectLiteralExpression(n))continue;let s=n.properties.find(o=>T.default.isPropertyAssignment(o)&&T.default.isIdentifier(o.name)&&o.name.text===e);if(!(!s||!T.default.isArrayLiteralExpression(s.initializer)))return s.initializer.elements.filter(T.default.isStringLiteral).map(o=>o.text)}return null}function Rn(t,e,r,n){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=fe(t.arguments,o);if(!T.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(l=>T.default.isPropertyAssignment(l)&&T.default.isIdentifier(l.name)&&l.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 s=fe(t.arguments,t.arguments.length-1);return{start:s.getStart(n),end:s.getStart(n),text:`{ ${e}: ${r} }, `}}function Dn(t,e,r){let n=t.arguments;for(let s=1;s<n.length;s++){let o=fe(n,s);if(!T.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(c=>T.default.isPropertyAssignment(c)&&T.default.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:fe(n,s-1).getEnd(),end:o.getEnd(),text:""};let a=fe(o.properties,i);return i===o.properties.length-1?{start:fe(o.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:fe(o.properties,i+1).getStart(r),text:""}}return null}function In(t,e){let r=[...e].sort((s,o)=>o.start-s.start),n=t;for(let s of r)n=n.slice(0,s.start)+s.text+n.slice(s.end);return n}function Mn(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var G=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function vm(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Ut(t,e,r,n){let s=T.default.createSourceFile(Ai.default.basename(t),e,T.default.ScriptTarget.Latest,!0),o=An(s),[i]=o;if(!i)return e;let a=Nn(i,n,s),c=[...r].sort();if(a!==null&&JSON.stringify(vm(a).sort())===JSON.stringify(c))return e;let l=Mn(c.map(u=>`@${u}`)),p=o.flatMap(u=>{let m=r.length===0?Dn(u,n,s):Rn(u,n,l,s);return m?[m]:[]});return p.length>0?In(e,p):e}var Kt=class{name="cypress";canHandle(e){return G.has(Ni.default.extname(e).toLowerCase())}apply(e,r,n){return Ut(e,r,n,"tags")}};var Ri=d(require("path")),_n=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Ln=/^@([a-zA-Z0-9_-]+)/gm;function Cm(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
28
30
  `)}
29
31
 
30
- `}function Hu(t){let e=new Set;En.lastIndex=0;let r=En.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=En.exec(t);return e}var Ot=class{name="gherkin";canHandle(e){return fi.default.extname(e).toLowerCase()===".feature"}apply(e,r,n){let s=r.replace(wn,""),o=Hu(s),i=n.filter(c=>!o.has(c)),a=i.length>0?Bu(i):"";return wn.test(r)?r.replace(wn,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function mi(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),s="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(s+=".*",o++):s+="[^/]*":i==="?"?s+="[^/]":i!==void 0&&(s+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${s}$`).test(n)}var gi=g(require("path")),Fn=/^\/\/go:build mokosh_[^\n]+\n/m,Uu=/^package\s+\S+/m;function Ju(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
31
- `}function Ku(t){let e=Fn.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,s=[],o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}var jt=class{name="go";canHandle(e){return gi.default.basename(e).endsWith("_test.go")}apply(e,r,n){let s=Ku(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(Fn,"");let i=Ju(o);if(s!==null)return r.replace(Fn,i);let a=Uu.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
32
- ${r.slice(c)}`}};var di=g(require("path"));var qu=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Tn=/^ \* @group (.+)$/gm;function Vu(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
32
+ `}function wm(t){let e=new Set;Ln.lastIndex=0;let r=Ln.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Ln.exec(t);return e}var Jt=class{name="gherkin";canHandle(e){return Ri.default.extname(e).toLowerCase()===".feature"}apply(e,r,n){let s=r.replace(_n,""),o=wm(s),i=n.filter(c=>!o.has(c)),a=i.length>0?Cm(i):"";return _n.test(r)?r.replace(_n,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function Di(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),s="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(s+=".*",o++):s+="[^/]*":i==="?"?s+="[^/]":i!==void 0&&(s+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${s}$`).test(n)}var Ii=d(require("path")),Gn=/^\/\/go:build mokosh_[^\n]+\n/m,Em=/^package\s+\S+/m;function Tm(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
33
+ `}function Fm(t){let e=Gn.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,s=[],o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}var qt=class{name="go";canHandle(e){return Ii.default.basename(e).endsWith("_test.go")}apply(e,r,n){let s=Fm(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(Gn,"");let i=Tm(o);if(s!==null)return r.replace(Gn,i);let a=Em.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
34
+ ${r.slice(c)}`}};var Mi=d(require("path"));var Pm=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,On=/^ \* @group (.+)$/gm;function Am(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
33
35
  `)}
34
36
 
35
- `}function Qu(t){let e=[];Tn.lastIndex=0;let r=Tn.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Tn.exec(t);return e}var zt=class{name="jest";canHandle(e){return _.has(di.default.extname(e).toLowerCase())}apply(e,r,n){let s=qu.exec(r),o=s?Qu(s[0]):null,i=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=s?r.slice(s[0].length):r;return n.length===0?a:Vu(i)+a}};var yi=g(require("path")),Yu="// mokosh:tags",An=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,Pn="import org.junit.jupiter.api.Tag;",xi=/^import org\.junit\.jupiter\.api\.Tag;\n/m,Zu=/^(?:public\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+|strictfp\s+)*(?:class|interface|enum|record|@interface)\s+\w+/m,Xu=/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,ef=/^package\s+[^\n]+;\n/m,tf=/\/src\/(test|androidTest|integrationTest|it)\//,rf=/(Test|Tests|Spec|IT)\.(java|groovy)$/;function nf(t){let e=An.exec(t);if(!e)return null;let r=[],n=/@Tag\("([^"]*)"\)/g,s=n.exec(e[0]);for(;s!==null;)s[1]&&r.push(s[1]),s=n.exec(e[0]);return r}function sf(t){return`${Yu}
37
+ `}function Nm(t){let e=[];On.lastIndex=0;let r=On.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=On.exec(t);return e}var Vt=class{name="jest";canHandle(e){return G.has(Mi.default.extname(e).toLowerCase())}apply(e,r,n){let s=Pm.exec(r),o=s?Nm(s[0]):null,i=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=s?r.slice(s[0].length):r;return n.length===0?a:Am(i)+a}};var Li=d(require("path")),Rm="// mokosh:tags",Wn=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,jn="import org.junit.jupiter.api.Tag;",Gi=/^import org\.junit\.jupiter\.api\.Tag;\n/m,Dm=/^(?:public\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+|strictfp\s+)*(?:class|interface|enum|record|@interface)\s+\w+/m,Im=/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,Mm=/^package\s+[^\n]+;\n/m,_m=/\/src\/(test|androidTest|integrationTest|it)\//,Lm=/(Test|Tests|Spec|IT)\.(java|groovy)$/;function Gm(t){let e=Wn.exec(t);if(!e)return null;let r=[],n=/@Tag\("([^"]*)"\)/g,s=n.exec(e[0]);for(;s!==null;)s[1]&&r.push(s[1]),s=n.exec(e[0]);return r}function Om(t){return`${Rm}
36
38
  ${t.map(e=>`@Tag("${e}")`).join(`
37
39
  `)}
38
- `}function hi(t){if(xi.test(t))return t;let e=Xu.exec(t);if(e){let n=e.index+e[0].length;return t.slice(0,n)+Pn+`
39
- `+t.slice(n)}let r=ef.exec(t);if(r){let n=r.index+r[0].length;return t.slice(0,n)+`
40
- `+Pn+`
41
- `+t.slice(n)}return Pn+`
42
- `+t}function of(t){return/@Tag\b/.test(t)?t:t.replace(xi,"")}var Wt=class{name="junit";canHandle(e){let r=e.replace(/\\/g,"/"),n=yi.default.extname(r).toLowerCase();return n!==".java"&&n!==".groovy"?!1:tf.test(r)||rf.test(r)}apply(e,r,n){let s=nf(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return s===null?r:of(r.replace(An,""));let i=sf(o);if(s!==null)return hi(r.replace(An,i));let a=Zu.exec(r);if(!a)return r;let c=r.slice(0,a.index)+i+r.slice(a.index);return hi(c)}};var bi=g(require("path"));var $t=class{name="playwright";canHandle(e){return _.has(bi.default.extname(e).toLowerCase())}apply(e,r,n){return _t(e,r,n,"tag")}};var Si=g(require("path")),Nn=/^pytestmark\s*=\s*.+$/m,af=/^import pytest\s*$/m;function cf(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function lf(t){let e=Nn.exec(t);if(!e)return null;let r=e[0],n=[],s=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Bt=class{name="pytest";canHandle(e){return Si.default.extname(e).toLowerCase()===".py"}apply(e,r,n){let s=lf(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(Nn,"").replace(/\n{3,}/g,`
40
+ `}function _i(t){if(Gi.test(t))return t;let e=Im.exec(t);if(e){let n=e.index+e[0].length;return t.slice(0,n)+jn+`
41
+ `+t.slice(n)}let r=Mm.exec(t);if(r){let n=r.index+r[0].length;return t.slice(0,n)+`
42
+ `+jn+`
43
+ `+t.slice(n)}return jn+`
44
+ `+t}function jm(t){return/@Tag\b/.test(t)?t:t.replace(Gi,"")}var Qt=class{name="junit";canHandle(e){let r=e.replace(/\\/g,"/"),n=Li.default.extname(r).toLowerCase();return n!==".java"&&n!==".groovy"?!1:_m.test(r)||Lm.test(r)}apply(e,r,n){let s=Gm(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return s===null?r:jm(r.replace(Wn,""));let i=Om(o);if(s!==null)return _i(r.replace(Wn,i));let a=Dm.exec(r);if(!a)return r;let c=r.slice(0,a.index)+i+r.slice(a.index);return _i(c)}};var Oi=d(require("path"));var Yt=class{name="playwright";canHandle(e){return G.has(Oi.default.extname(e).toLowerCase())}apply(e,r,n){return Ut(e,r,n,"tag")}};var ji=d(require("path")),zn=/^pytestmark\s*=\s*.+$/m,Wm=/^import pytest\s*$/m;function zm(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function $m(t){let e=zn.exec(t);if(!e)return null;let r=e[0],n=[],s=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Xt=class{name="pytest";canHandle(e){return ji.default.extname(e).toLowerCase()===".py"}apply(e,r,n){let s=$m(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return r.replace(zn,"").replace(/\n{3,}/g,`
43
45
 
44
- `);let i=cf(o);if(s!==null)return r.replace(Nn,i);let a=af.test(r),c=pf(r),l=r.slice(0,c),p=r.slice(c),u=a?"":`import pytest
46
+ `);let i=zm(o);if(s!==null)return r.replace(zn,i);let a=Wm.test(r),c=Bm(r),l=r.slice(0,c),p=r.slice(c),u=a?"":`import pytest
45
47
  `,m=l.endsWith(`
46
48
 
47
49
  `)?"":`
48
50
  `;return`${l+m+u+i}
49
- ${p}`}};function pf(t){let e=t.split(`
50
- `),r=-1;return e.forEach((s,o)=>{(s.trimStart().startsWith("import ")||s.trimStart().startsWith("from "))&&(r=o)}),r<0?0:e.slice(0,r+1).reduce((s,o)=>s+o.length+1,0)}var vi=g(require("path")),Dn=/^\/\/ mokosh:tags .*\n/m,uf=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,ff=/\/src\/(test|it)\//,mf=/(Spec|Suite|Test|Props)\.scala$/;function gf(t){let e=Dn.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var Ht=class{name="scalatest";canHandle(e){let r=e.replace(/\\/g,"/");return vi.default.extname(r).toLowerCase()!==".scala"?!1:ff.test(r)||mf.test(r)}apply(e,r,n){let s=gf(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return s===null?r:r.replace(Dn,"");let i=`// mokosh:tags ${o.join(", ")}
51
- `;if(s!==null)return r.replace(Dn,i);let a=uf.exec(r);return a?r.slice(0,a.index)+i+r.slice(a.index):r}};var Rn=g(require("path")),In=g(require("typescript"));var df=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Ut=class{name="vitest";canHandle(e){return _.has(Rn.default.extname(e).toLowerCase())}apply(e,r,n){let s=r.replace(df,""),o=In.default.createSourceFile(Rn.default.basename(e),s,In.default.ScriptTarget.Latest,!0),i=xn(o),[a]=i;if(!a)return s;let c=bn(a,"tags",o),l=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(l))return s;let p=i.flatMap(u=>{let m=n.length===0?vn(u,"tags",o):Sn(u,"tags",Cn(l),o);return m?[m]:[]});return p.length>0?kn(s,p):s}};var ki={vitest:()=>new Ut,playwright:()=>new $t,cypress:()=>new Gt,jest:()=>new zt},hf={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function yf(t){let e=st.default.createSourceFile("detect.ts",t,st.default.ScriptTarget.Latest,!0);for(let r of e.statements){if(!st.default.isImportDeclaration(r)||!st.default.isStringLiteral(r.moduleSpecifier))continue;let n=hf[r.moduleSpecifier.text];if(n)return n}return null}var Mn=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return _.has(Jt.default.extname(e).toLowerCase())}apply(e,r,n){let s=yf(r)??this.matchOverride(e)??this.defaultFramework;return(ki[s]??ki.vitest)().apply(e,r,n)}matchOverride(e){let r=Jt.default.relative(this.rootDir,e).split(Jt.default.sep).join("/");for(let[n,s]of this.frameworkOverrides)if(mi(n,r))return s;return null}};function Ci(t="vitest",e={},r=process.cwd()){return[new Ot,new Bt,new jt,new Wt,new Ht,new Mn(r,t,Object.entries(e))]}function wi(t,e){return e.find(r=>r.canHandle(t))??null}var xf=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,bf=new Set(["import"]),Sf=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function vf(t,e,r,n){let s;try{s=await Ln.default.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=wi(t,n);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,s,e);return i===s?{path:t,status:"unchanged"}:(r||await Ln.default.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function _n(t,e,r){let n=De(e),s=n.tagApplier?.framework??"vitest",o=n.tagApplier?.frameworkOverrides??{},i=Ci(s,o,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,p=[];for(let h of c.tags)bf.has(h.kind)&&xf.test(h.name)&&(Sf.has(h.name.toLowerCase())||l.has(h.name)||(l.add(h.name),p.push(h.name)));p.sort();let u=Ei.default.resolve(e,c.path),m=await vf(u,p,r.dryRun,i);m.path=c.path,a.files.push(m),m.status==="updated"?a.updated++:m.status==="unchanged"?a.unchanged++:a.errors++}return a}var Kt=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}};function Fi(t,e){return{identifier:e?.identifier??new Kt,featureMap:e?.featureDetection===!1?new Map:ne(t.nodes,e?.featureDetection??void 0)}}function Ti(t,e,r,n,s){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new ee(o,["*",...i.exports.map(c=>c.name)]);t.traverse(o,(c,l,p)=>{if(!p)return!0;if(!a.updateAffectedSymbols(c,p))return!1;if(l>0){let u=r.get(c.path);if(u)return n(u),!1}return s(c),!0},{direction:"incoming"})}}function Gn(t,e,r){let{identifier:n,featureMap:s}=Fi(t,r),o=new Set;for(let i of e){let a=s.get(i);a&&o.add(a.tag)}return Ti(t,e,s,i=>o.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function On(t,e,r){let{identifier:n,featureMap:s}=Fi(t,r),o=new Set;return Ti(t,e,s,()=>{},i=>{n.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Pi=g(require("fs")),Ae=g(require("path"));async function Ai(t,e,r=null,n={}){let s=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=Ae.default.resolve(t);return await new X(o,r,n.pathAliases?new z(o,{pathAliases:n.pathAliases}):void 0,s,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(e)}async function Ni(t,e={}){let r=Ae.default.resolve(t),n=tt(r),s=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,o=new Map(n.packages.map(a=>[a.name,a.root])),i=new rt(r,n.type);for(let a of s){let c=e.silent?void 0:u=>{process.stderr.write(`[${a.name}] Processed ${u} files...\r`)},p=await new X(r,null,new z(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,p)}return i.annotateCrossPackageEdges(),i}function Di(t,e={}){let r=[],n=new Set([...e.ignoreDirs??P,...e.additionalIgnoreDirs??[]]),s=new Set([...e.extensions??ur,...e.additionalExtensions??[]]);function o(i){try{let a=Pi.default.readdirSync(i,{withFileTypes:!0});for(let c of a){let l=Ae.default.join(i,c.name);c.isDirectory()?n.has(c.name)||o(l):c.isFile()&&s.has(Ae.default.extname(c.name).toLowerCase())&&r.push(Ae.default.relative(t,l))}}catch{}}return o(t),r}var Ri=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;function Ii(t){return Vt.default.join(t,ae,Re)}function kf(t,e){return e?.cachePath?Vt.default.resolve(t,e.cachePath):Vt.default.join(t,ae,lr)}function Cf(t){try{if(!qt.default.existsSync(t))return null;let e=qt.default.readFileSync(t,"utf-8");return A.deserialize(JSON.parse(e))}catch{return null}}var Qt=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;duplicationTokenCaches=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,r){this.configs.set(e,r)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,r,n=new Map){let s=this.configs.get(e),o=this.graphs.get(e)??Cf(kf(e,s)),i=await Ai(e,r,o,{...J(s),coverageMap:n});return this.graphs.set(e,i),i}require(e){let r=this.graphs.get(e);if(!r)throw new Error('No graph cached for this root. Call "analyze" first.');return r}async getOrBuildWorkspace(e,r={}){let n=this.workspaceGraphs.get(e);if(n)return n;let s=await Ni(e,r);return this.workspaceGraphs.set(e,s),s}requireWorkspace(e){let r=this.workspaceGraphs.get(e);if(!r)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return r}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let r=this.changeImpactCaches.get(e);if(r)return r;let n=this.require(e),s=br(n);return this.changeImpactCaches.set(e,s),s}storeLastAnalyze(e,r){this.lastAnalyze.set(e,r)}getLastEntryPoints(e){let r=this.lastAnalyze.get(e);return r?.kind==="single"?r.entryPoints:void 0}startWatching(e){if(!this.watchers.has(e))try{let r=qt.default.watch(e,{recursive:!0},(n,s)=>{!s||Ri.test(s)||this.dirtyRoots.add(e)});r.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,r)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.lastAnalyze.get(e);return r?.kind==="single"?this.getOrBuild(e,r.entryPoints,r.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e))return this.requireWorkspace(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e),this.workspaceGraphs.delete(e);let r=this.configs.get(e);return this.getOrBuildWorkspace(e,J(r))}async getDuplicationTokenCache(e){let r=this.duplicationTokenCaches.get(e);return r||(r=Se(Ii(e)),this.duplicationTokenCaches.set(e,r)),r}flushDuplicationTokenCache(e){let r=this.duplicationTokenCaches.get(e);if(r)try{ve(r,Ii(e))}catch(n){process.stderr.write(`Warning: failed to persist duplication token cache: ${n}
52
- `)}}invalidate(e){let r=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),this.duplicationTokenCaches.delete(e),this.configs.delete(e),r}};var H=g(require("path"));var Mi=g(require("fs")),Li=g(require("os")),Yt=g(require("path"));function b(t){return{content:[{type:"text",text:JSON.stringify(t)}]}}function _i(t){if(!Yt.default.isAbsolute(t))throw new Error("root must be an absolute path");let e=Yt.default.resolve(t),r=Li.default.homedir();if(e!==r&&!e.startsWith(r+Yt.default.sep))throw new Error("root must be within the user home directory");let n;try{n=Mi.default.statSync(e)}catch{throw new Error("root does not exist")}if(!n.isDirectory())throw new Error("root is not a directory")}async function Gi(t,e){let{root:r,entryPoints:n}=e;if(!t.isConfigured(r)){let m=De(r,{allowJs:!1});cr(m),t.storeConfig(r,m)}if(n.length===0){let m=tt(r);if(m.type!=="none"){let h=t.getConfig(r),y=await t.getOrBuildWorkspace(r,J(h));t.storeLastAnalyze(r,{kind:"workspace"}),t.startWatching(r);let v=Array.from(y.packages.values()).map(({graph:x,pkg:k})=>({package:k.name,relativeRoot:k.relativeRoot,nodeCount:x.nodes.size}));return b({monorepoType:m.type,packageCount:y.packages.size,packages:v})}}let s=n.map(m=>H.default.resolve(r,m)),o=t.getConfig(r),i=o?.coverageReportPath?mr(r,o.coverageReportPath):new Map,a=await t.getOrBuild(r,s,i);t.storeLastAnalyze(r,{kind:"single",entryPoints:s,coverageMap:i}),t.startWatching(r);let c=a.serialize(),l=c.nodes.reduce((m,h)=>(m[h.category]=(m[h.category]??0)+1,m),{}),p=a.findCycles(),u=Jr(a);return b({nodeCount:c.nodes.length,categories:l,cycles:p,languageCoverage:u})}async function Oi(t,e){let{root:r,file:n,depth:s=1,withMeta:o=!1}=e,i=await t.ensureFresh(r),a=Zr(i,n,s),c=o?a.map(l=>({...l,...Qe(i,l.path)})):a;return b({file:n,dependencies:c})}async function ji(t,e){let{root:r,file:n,withMeta:s=!1}=e,o=await t.ensureFresh(r),i=Ye(o,n),a=s?i.map(c=>({...c,...Qe(o,c.path)})):i;return b({file:n,dependents:a})}async function zi(t,e){let{root:r,file:n,testsOnly:s=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,c=await t.ensureFresh(r),l=m=>a?m.map(h=>({path:h,...Qe(c,h)})):m;if(o){let m=t.getOrBuildChangeImpact(r),h=Sr(m,n),y=s?h.filter(x=>c.nodes.get(x)?.category==="test"):h,v=l(y);return b({file:n,affected:v,count:v.length})}let p=Xr(c,n,{testsOnly:s,changedSymbols:i}),u=l(p);return b({file:n,affected:u,count:u.length})}async function Wi(t,e){let{root:r,baseRef:n,headRef:s,minDuplicateLines:o,complexityMetric:i,complexityThreshold:a}=e,c=await t.ensureFresh(r),l=e.entryPoints??t.getLastEntryPoints(r)?.map(u=>H.default.relative(r,u))??[],p=await on(r,n,c,{headRef:s,entryPoints:l,minDuplicateLines:o,complexityMetric:i,complexityThreshold:a,maxCoveragePct:e.maxCoveragePct,...J(t.getConfig(r))});return e.detail==="full"?b(p):b(sn(p,{metric:i,maxItems:e.maxItems}))}async function $i(t,e){let{root:r,file:n,depth:s=1,withEdgeDetail:o=!1}=e,i=await t.ensureFresh(r),a=en(i,n,{depth:s,withEdgeDetail:o});return b({file:n,callers:a,count:a.length})}async function Bi(t,e){let{root:r,entryPoints:n}=e,s=n?await t.getOrBuild(r,n.map(c=>H.default.resolve(r,c))):await t.ensureFresh(r),o=t.getConfig(r),i=Di(r,{additionalIgnoreDirs:o?.ignoreDirs??[],additionalExtensions:o?.extensions??[]}),a=s.findUnusedFiles(i);return b({unusedFiles:a,count:a.length})}async function Hi(t,e){let{root:r}=e,n=await t.ensureFresh(r),s=new Map;for(let i of n.nodes.values())for(let a of i.tags)s.set(a.name,(s.get(a.name)??0)+1);let o=[...s.entries()].map(([i,a])=>({name:i,count:a})).sort((i,a)=>a.count-i.count);return b({tags:o,count:o.length})}async function Ui(t,e){let{root:r,coverageThreshold:n}=e,s=await t.ensureFresh(r),o=t.getConfig(r),i=n??o?.coverageThreshold??80;if(!te(s))return b({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...s.nodes.values()].filter(c=>c.category!=="test"&&c.category!=="config").filter(c=>c.coveragePct!==void 0&&c.coveragePct<i).map(c=>({file:c.path,coveragePct:c.coveragePct}));return b({threshold:i,uncovered:a,count:a.length})}async function Ji(t,e){let{root:r}=e,s=[...(await t.ensureFresh(r)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return b({staleDocs:s,count:s.length})}async function Ki(t,e){let{root:r,metric:n="cognitiveComplexity",threshold:s=10,limit:o=20}=e,i=await t.ensureFresh(r),a=we(i,{metric:n,threshold:s,limit:o});return b({metric:n,threshold:s,functions:a,count:a.length})}async function qi(t,e){let{root:r,metric:n="cognitiveComplexity",minComplexity:s=10,maxCoveragePct:o=50,minChurn:i=0,limit:a=20}=e,c=await t.ensureFresh(r);if(!te(c))return b({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let{hotspots:l,count:p,churnDataAvailable:u}=Ee(c,{metric:n,minComplexity:s,maxCoveragePct:o,minChurn:i,limit:a});return b({metric:n,minComplexity:s,maxCoveragePct:o,minChurn:i,churnDataAvailable:u,hotspots:l,count:p})}async function Vi(t,e){let{root:r,minLines:n=6,ignoreLiterals:s=!0,maxPunctuationRatio:o=.5,limit:i=50}=e,a=await t.ensureFresh(r),c=e.ignoreDirs??[...P,...t.getConfig(r)?.ignoreDirs??[]],{groups:l}=await Ce(a,r,{minLines:n,ignoreLiterals:s,maxPunctuationRatio:o,limit:i,ignoreDirs:c,tokenCache:await t.getDuplicationTokenCache(r)});return t.flushDuplicationTokenCache(r),b({minLines:n,groups:l,count:l.length})}async function Qi(t,e){let{root:r,changedFiles:n,base:s,featureThreshold:o,format:i="tags"}=e,a=await t.ensureFresh(r),c=n??new gt().getChangedFiles(r,s).map(u=>H.default.relative(r,H.default.resolve(r,u))),l=o!==void 0?{featureDetection:{minOutDegree:o}}:void 0;if(i==="paths"){let u=On(a,c,l);return b({changedFiles:c,affectedTests:u,count:u.length})}let p=Gn(a,c,l);return b({changedFiles:c,proposedTags:p})}async function Yi(t,e){let{root:r,entryPoints:n,featureThreshold:s}=e,o=n?await t.getOrBuild(r,n.map(c=>H.default.resolve(r,c))):await t.ensureFresh(r),i=ne(o.nodes,s!==void 0?{minOutDegree:s}:void 0),a=Array.from(i.values()).sort((c,l)=>l.outDegree-c.outDegree);return b({features:a,count:a.length})}async function Zi(t,e){let{root:r,entryPoints:n,filter:s,mermaid:o=!1,slim:i=!0}=e,a=n?await t.getOrBuild(r,n.map(l=>H.default.resolve(r,l))):await t.ensureFresh(r),c=Mt(a.serialize(),Lt(s));return o?b(ut.serialize(A.deserialize(c))):i?b(tn(c)):b(c)}async function Xi(t,e){let{root:r}=e,n=await t.ensureFreshWorkspace(r);return b(rn(n))}async function ea(t,e){let{root:r,file:n}=e,o=(await t.ensureFreshWorkspace(r)).getAffectedAcrossPackages(n);return b({file:n,affected:o,count:o.length})}function ta(t,e){let{root:r}=e,n=t.invalidate(r);return b({root:r,cleared:n,message:n?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function ra(t,e){let{root:r,type:n}=e,s=await t.ensureFresh(r),o=ln(s);if(n)return b(pn(o,n));let i=Array.from(o.types.values());return b({count:i.length,types:i})}async function na(t,e){let{root:r,paths:n,minOutDegree:s}=e,o=await t.ensureFresh(r),i=an(o,s!==void 0?{minOutDegree:s}:void 0);if(n?.length){let c=n.map(l=>i.get(l)).filter(Boolean);return b({count:c.length,modules:c})}let a=Array.from(i.values());return b({count:a.length,modules:a})}async function sa(t,e){let{root:r,minOutDegree:n}=e,s=await t.ensureFresh(r),o=Xe(s,n!==void 0?{minOutDegree:n}:void 0),i=Object.fromEntries(o.features);return b({features:i,unassigned:o.unassigned})}async function oa(t,e){let{root:r,function:n}=e,s=await t.ensureFresh(r);return b(xr(s,n))}async function ia(t,e){let{root:r,name:n}=e,s=await t.ensureFresh(r),o=cn(s,n);return b({name:n,matches:o,count:o.length})}async function aa(t,e){let{root:r,entryPoints:n}=e,s=await t.ensureFresh(r),o=n?.length?n:hr(s,r);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return b(yr(s,o))}async function ca(t,e){let r=await t.ensureFresh(e.root),n=await _n(r,e.root,{dryRun:e.dryRun??!1});return b(n)}var la=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo) and build per-package graphs \u2014 use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. See docs/mcp.md for details on the testsOnly, cached, changedSymbols, and withMeta options.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"compare_branches",description:"Compare the current graph (root) against baseRef, for reviewing a PR/branch: file diff, stale post-rename references, and deltas for duplication, complexity, doc drift, and coverage/risk hotspots. Returns a compact summary by default (verdict + headline + capped delta lists); pass detail:'full' for every entry. See docs/mcp.md for details. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},baseRef:{type:"string",description:"Git ref to compare against, e.g. 'main', 'origin/main', or a commit sha"},headRef:{type:"string",description:"Git ref to label the head side of the comparison (default: 'HEAD'). The graph itself always comes from the already-analyzed root, not a checkout of this ref."},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the base-ref graph from, relative to root. Defaults to the entry points from the last analyze() call for this root."},minDuplicateLines:{type:"number",description:"Minimum duplicated block size, in source lines, for the duplication delta (default: 6)"},complexityMetric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which per-function score drives the complexity delta (default: cognitiveComplexity)"},complexityThreshold:{type:"number",description:"Minimum per-function score to count as a complexity hotspot (default: 10)"},maxCoveragePct:{type:"number",description:"Maximum containing-file coverage % to count as a risk hotspot (default: 50)"},detail:{type:"string",enum:["summary","full"],description:"'summary' (default): verdict, headline, and each delta list capped at maxItems with true counts; empty sections omitted. 'full': the complete BranchComparison with every entry."},maxItems:{type:"number",description:"In summary mode, max entries kept per delta list (complexity/duplication/doc-drift/coverage); the true count is always reported alongside (default: 8). Stale references are never truncated."}},required:["root","baseRef"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes. Omit entryPoints to reuse the cached graph from a prior analyze() call instead of rebuilding.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to reuse the cached graph from a prior analyze() call."}},required:["root"]}},{name:"list_tags",description:"List every distinct tag name present in the graph, with how many nodes carry each one. Call this before querying with tag:<name> to avoid a speculative filter silently returning zero results. Includes all tag kinds \u2014 a superset of what query's slim mode keeps (slim only retains comment-marker and import tags).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. Populated for TypeScript/JavaScript, Go, and Python.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"find_risk_hotspots",description:"Find functions that are complex, in a poorly-covered file, and \u2014 when gitStats is enabled in mokosh.config \u2014 in a frequently-changed file. Requires a prior analyze() call and coverageReportPath set in mokosh.config; errors if no coverage data was loaded. Churn filtering is skipped (churnDataAvailable: false) when gitStats wasn't enabled, since complexity + low coverage alone is still a meaningful signal.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which per-function score to filter/sort on (default: cognitiveComplexity)"},minComplexity:{type:"number",description:"Minimum per-function complexity score to include (default: 10)"},maxCoveragePct:{type:"number",description:"Maximum containing-file coverage % to include (default: 50)"},minChurn:{type:"number",description:"Minimum containing-file 90-day commit count to include (default: 0). Ignored when gitStats wasn't enabled at analyze time."},limit:{type:"number",description:"Max results to return, worst-first by metric (default: 20)"}},required:["root"]}},{name:"find_duplicates",description:"Find duplicated code blocks across the project, largest-first. CSS/SCSS/Less are matched structurally by rule body; every other parsed language is tokenized and matched via suffix array. Lock files and ignored directories are always excluded. Requires a prior analyze() call. See docs/mcp.md for matching-strategy, normalization, and caching details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minLines:{type:"number",description:"Minimum duplicated block size in lines to report (default: 6)"},ignoreLiterals:{type:"boolean",description:"Normalize string/number literals too, not just identifiers, so only structural shape drives a match (default: true). Set false for stricter, exact-text-only matching."},maxPunctuationRatio:{type:"number",description:"Maximum fraction of a token-shingled block's window that may be object/array-literal structural punctuation ({ } : , [ ]) (default: 0.5). Filters out blocks that are mostly schema/object-literal shape instead of substantive shared logic. Does not apply to the CSS/Less/SCSS structural comparator. Set 1 to disable."},ignoreDirs:{type:"array",items:{type:"string"},description:"Directory names to exclude, matched against any path segment (default: DEFAULT_IGNORE_DIRS merged with this root's configured ignoreDirs, if any). Pass [] to disable."},limit:{type:"number",description:"Max duplicate blocks to return, largest-first (default: 50)"}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},base:{type:"string",description:"Diff against this ref (e.g. 'origin/main') instead of only local working-tree/staged/untracked changes. Ignored when changedFiles is given. Needed in CI, where the checkout is already clean."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, path, or other node metadata. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used. See docs/mcp.md for the full query DSL reference.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Tags are filtered to kinds comment-marker and import only; function/class/variable/type/library tags are dropped in slim output. Use list_tags to see the full tag inventory, or pass slim: false to get every tag kind on matching nodes."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo, with their node counts and inter-package dependencies. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 it returns only paths grouped by hub, so it's substantially smaller than a full graph query for the same question; compare output sizes yourself if you need an exact figure for your repo.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language \u2014 check each match's `precision` field ('call' | 'file-level') before trusting caller/importer results as symbol-exact. See docs/mcp.md for per-language coverage details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project: every exported symbol resolved to its defining file and kind, partitioned into internalFiles, unreachableFromEntry, and testFiles. Requires a prior analyze() call. When entryPoints is omitted, auto-detects from package.json exports/main/module. See docs/mcp.md for the export* expansion and partition semantics.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph and loaded mokosh.config.json for a project root, forcing the next analyze() call to rebuild from disk and re-read config. Call this after editing source files OR mokosh.config.json mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data (or a stale config).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph, as an idempotent block \u2014 re-running is safe, the existing block is replaced in place. Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call. See docs/mcp.md for tag-kind and per-language block syntax details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function Xt(){let t=new Qt,e=new pa.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(Zt.ListToolsRequestSchema,async()=>({tools:la})),e.setRequestHandler(Zt.CallToolRequestSchema,async r=>{let{name:n,arguments:s}=r.params,o=s,a={analyze:c=>Gi(t,c),get_dependencies:c=>Oi(t,c),get_dependents:c=>ji(t,c),get_affected:c=>zi(t,c),compare_branches:c=>Wi(t,c),get_callers:c=>$i(t,c),find_symbol:c=>ia(t,c),find_unused:c=>Bi(t,c),find_uncovered:c=>Ui(t,c),list_tags:c=>Hi(t,c),check_doc_drift:c=>Ji(t,c),find_complex_functions:c=>Ki(t,c),find_risk_hotspots:c=>qi(t,c),find_duplicates:c=>Vi(t,c),propose_tags:c=>Qi(t,c),detect_features:c=>Yi(t,c),get_type_graph:c=>ra(t,c),get_module_responsibility:c=>na(t,c),get_feature_graph:c=>sa(t,c),get_call_graph:c=>oa(t,c),get_api_surface:c=>aa(t,c),query:c=>Zi(t,c),get_workspace_packages:c=>Xi(t,c),get_workspace_affected:c=>ea(t,c),clear_cache:c=>ta(t,c),apply_tags:c=>ca(t,c)}[n];if(!a)throw new Error(`Unknown tool: ${n}`);try{return _i(o.root),await a(o)}catch(c){return{content:[{type:"text",text:`Error: ${c instanceof Error?c.message:String(c)}`}],isError:!0}}}),e}async function wf(){let t=Xt(),e=new ua.StdioServerTransport;await t.connect(e)}wf().catch(console.error);0&&(module.exports={createMcpServer});
51
+ ${p}`}};function Bm(t){let e=t.split(`
52
+ `),r=-1;return e.forEach((s,o)=>{(s.trimStart().startsWith("import ")||s.trimStart().startsWith("from "))&&(r=o)}),r<0?0:e.slice(0,r+1).reduce((s,o)=>s+o.length+1,0)}var Wi=d(require("path")),$n=/^\/\/ mokosh:tags .*\n/m,Hm=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,Um=/\/src\/(test|it)\//,Km=/(Spec|Suite|Test|Props)\.scala$/;function Jm(t){let e=$n.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var Zt=class{name="scalatest";canHandle(e){let r=e.replace(/\\/g,"/");return Wi.default.extname(r).toLowerCase()!==".scala"?!1:Um.test(r)||Km.test(r)}apply(e,r,n){let s=Jm(r),o=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(o))return r;if(n.length===0)return s===null?r:r.replace($n,"");let i=`// mokosh:tags ${o.join(", ")}
53
+ `;if(s!==null)return r.replace($n,i);let a=Hm.exec(r);return a?r.slice(0,a.index)+i+r.slice(a.index):r}};var Bn=d(require("path")),Hn=d(require("typescript"));var qm=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,er=class{name="vitest";canHandle(e){return G.has(Bn.default.extname(e).toLowerCase())}apply(e,r,n){let s=r.replace(qm,""),o=Hn.default.createSourceFile(Bn.default.basename(e),s,Hn.default.ScriptTarget.Latest,!0),i=An(o),[a]=i;if(!a)return s;let c=Nn(a,"tags",o),l=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(l))return s;let p=i.flatMap(u=>{let m=n.length===0?Dn(u,"tags",o):Rn(u,"tags",Mn(l),o);return m?[m]:[]});return p.length>0?In(s,p):s}};var zi={vitest:()=>new er,playwright:()=>new Yt,cypress:()=>new Kt,jest:()=>new Vt},Vm={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function Qm(t){let e=pt.default.createSourceFile("detect.ts",t,pt.default.ScriptTarget.Latest,!0);for(let r of e.statements){if(!pt.default.isImportDeclaration(r)||!pt.default.isStringLiteral(r.moduleSpecifier))continue;let n=Vm[r.moduleSpecifier.text];if(n)return n}return null}var Un=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return G.has(tr.default.extname(e).toLowerCase())}apply(e,r,n){let s=Qm(r)??this.matchOverride(e)??this.defaultFramework;return(zi[s]??zi.vitest)().apply(e,r,n)}matchOverride(e){let r=tr.default.relative(this.rootDir,e).split(tr.default.sep).join("/");for(let[n,s]of this.frameworkOverrides)if(Di(n,r))return s;return null}};function $i(t="vitest",e={},r=process.cwd()){return[new Jt,new Xt,new qt,new Qt,new Zt,new Un(r,t,Object.entries(e))]}function Bi(t,e){return e.find(r=>r.canHandle(t))??null}var Ym=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Xm=new Set(["import"]),Zm=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function ef(t,e,r,n){let s;try{s=await Kn.default.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=Bi(t,n);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,s,e);return i===s?{path:t,status:"unchanged"}:(r||await Kn.default.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Jn(t,e,r){let n=Oe(e),s=n.tagApplier?.framework??"vitest",o=n.tagApplier?.frameworkOverrides??{},i=$i(s,o,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,p=[];for(let g of c.tags)Xm.has(g.kind)&&Ym.test(g.name)&&(Zm.has(g.name.toLowerCase())||l.has(g.name)||(l.add(g.name),p.push(g.name)));p.sort();let u=Hi.default.resolve(e,c.path),m=await ef(u,p,r.dryRun,i);m.path=c.path,a.files.push(m),m.status==="updated"?a.updated++:m.status==="unchanged"?a.unchanged++:a.errors++}return a}var rr=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}};function Ui(t,e){return{identifier:e?.identifier??new rr,featureMap:e?.featureDetection===!1?new Map:pe(t.nodes,e?.featureDetection??void 0)}}function Ki(t,e,r,n,s){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new ae(o,["*",...i.exports.map(c=>c.name)]);t.traverse(o,(c,l,p)=>{if(!p)return!0;if(!a.updateAffectedSymbols(c,p))return!1;if(l>0){let u=r.get(c.path);if(u)return n(u),!1}return s(c),!0},{direction:"incoming"})}}function qn(t,e,r){let{identifier:n,featureMap:s}=Ui(t,r),o=new Set;for(let i of e){let a=s.get(i);a&&o.add(a.tag)}return Ki(t,e,s,i=>o.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function Vn(t,e,r){let{identifier:n,featureMap:s}=Ui(t,r),o=new Set;return Ki(t,e,s,()=>{},i=>{n.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Ji=d(require("crypto")),Qn=d(require("fs")),qi=d(require("os")),$=d(require("path"));async function Vi(t,e,r=null,n={}){let s=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=$.default.resolve(t);return await new ie(o,r,n.pathAliases?new z(o,{pathAliases:n.pathAliases}):void 0,s,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[],n.docFiles??null).build(e)}function tf(t){let e=Number.parseInt(process.env.MOKOSH_WORKSPACE_CONCURRENCY??"",10),r=Number.isFinite(e)&&e>0?e:qi.default.cpus().length||1;return Math.max(1,Math.min(r,Math.max(1,t)))}function rf(t,e,r){let n=new Map(e.map(o=>[o.name,[]])),s=[...e].sort((o,i)=>i.root.length-o.root.length);for(let o of r){if(!o.endsWith(".md")&&!o.endsWith(".mdx"))continue;let i=$.default.join(t,o),a=s.find(c=>i===c.root||i.startsWith(`${c.root}${$.default.sep}`));a&&n.get(a.name)?.push(i)}return n}function Qi(t){let e=nr(t),r=Ji.default.createHash("sha256");for(let n of[...e].sort()){let s=`${n}\0?\0?`;try{let o=Qn.default.statSync($.default.join(t,n));s=`${n}\0${o.mtimeMs}\0${o.size}`}catch{}r.update(`${s}
54
+ `)}return{digest:r.digest("hex"),files:e}}async function Yi(t,e={}){let r=$.default.resolve(t),n=e.layout??ct(r),s=e.projectFiles??nr(r),o=e.additionalIgnoreDirs??[],i=e.packages?n.packages.filter(x=>e.packages?.includes(x.name)||e.packages?.includes(x.relativeRoot)):n.packages,a=new Map(n.packages.map(x=>[x.name,x.root])),c=new me(r,n.type),l=new oe(o),p=rf(r,i,s),u=tf(i.length),m=u>1?!1:e.parallelParsing??!0,g=new Array(i.length),y=0,v=async()=>{for(let x=y++;x<i.length;x=y++){let C=i[x],A=e.silent?void 0:E=>{process.stderr.write(`[${C.name}] Processed ${E} files...\r`)},S=new ie(r,e.previousWorkspace?.packages.get(C.name)?.graph??null,new z(r,{workspaceMap:a,tsconfigSearchPaths:[C.root,r],pathAliases:e.pathAliases,langResolvers:Dt({jvm:l})}),A,e.gitStats??!1,new Map,m,o,p.get(C.name)??[]);g[x]=await S.build(C.entryPoints)}};return await Promise.all(Array.from({length:u},v)),i.forEach((x,C)=>{c.addPackage(x,g[C])}),c.annotateCrossPackageEdges(),c}function nr(t,e={}){let r=[],n=new Set([...e.ignoreDirs??R,...e.additionalIgnoreDirs??[]]),s=new Set([...e.extensions??Sr,...e.additionalExtensions??[]]);function o(i){try{let a=Qn.default.readdirSync(i,{withFileTypes:!0});for(let c of a){let l=$.default.join(i,c.name);c.isDirectory()?n.has(c.name)||o(l):c.isFile()&&s.has($.default.extname(c.name).toLowerCase())&&r.push($.default.relative(t,l))}}catch{}}return o(t),r}var Xi=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;function Zi(t){return B.default.join(t,X,je)}function nf(t,e){return e?.cachePath?B.default.resolve(t,e.cachePath):B.default.join(t,X,yr)}function sf(t,e){let r=e?.cachePath?B.default.dirname(B.default.resolve(t,e.cachePath)):B.default.join(t,X);return B.default.join(r,xr)}function of(t,e){try{if(!Q.default.existsSync(t))return null;let r=JSON.parse(Q.default.readFileSync(t,"utf-8"));return!r.graph||r.digest!==e?null:me.deserialize(r.graph)}catch{return null}}function af(t,e,r){try{Q.default.mkdirSync(B.default.dirname(t),{recursive:!0}),Q.default.writeFileSync(t,JSON.stringify({digest:e,graph:r.serialize()}))}catch(n){process.stderr.write(`Warning: failed to persist workspace graph cache: ${n}
55
+ `)}}function cf(t){try{if(!Q.default.existsSync(t))return null;let e=Q.default.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}catch{return null}}var sr=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;layouts=new Map;workspaceBuilds=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;duplicationTokenCaches=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,r){this.configs.set(e,r)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,r,n=new Map){let s=this.configs.get(e),o=this.graphs.get(e)??cf(nf(e,s)),i=await Vi(e,r,o,{...K(s),coverageMap:n});return this.graphs.set(e,i),i}require(e){let r=this.graphs.get(e);if(!r)throw new Error('No graph cached for this root. Call "analyze" first.');return r}getLayout(e){let r=this.layouts.get(e);if(r)return r;let n=ct(e);return this.layouts.set(e,n),n}async getOrBuildWorkspace(e,r={}){let n=this.workspaceGraphs.get(e);if(n)return n;let s=this.workspaceBuilds.get(e);if(s)return s;let{forceFresh:o,...i}=r,a=sf(e,this.configs.get(e)),{digest:c,files:l}=Qi(e),p=o?null:of(a,c);if(p)return this.workspaceGraphs.set(e,p),p;let u=Yi(e,{...i,layout:this.getLayout(e),projectFiles:l}).then(m=>(this.workspaceGraphs.set(e,m),af(a,c,m),m)).finally(()=>{this.workspaceBuilds.delete(e)});return this.workspaceBuilds.set(e,u),u}requireWorkspace(e){let r=this.workspaceGraphs.get(e);if(!r)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return r}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let r=this.changeImpactCaches.get(e);if(r)return r;let n=this.require(e),s=Pr(n);return this.changeImpactCaches.set(e,s),s}storeLastAnalyze(e,r){this.lastAnalyze.set(e,r)}getLastEntryPoints(e){let r=this.lastAnalyze.get(e);return r?.kind==="single"?r.entryPoints:void 0}startWatching(e){if(!this.watchers.has(e))try{let r=Q.default.watch(e,{recursive:!0},(n,s)=>{!s||Xi.test(s)||this.dirtyRoots.add(e)});r.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,r)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.lastAnalyze.get(e);return r?.kind==="single"?this.getOrBuild(e,r.entryPoints,r.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e)){let s=this.workspaceGraphs.get(e);return s||this.getOrBuildWorkspace(e,K(this.configs.get(e)))}this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.workspaceGraphs.get(e);this.workspaceGraphs.delete(e);let n=this.configs.get(e);return this.getOrBuildWorkspace(e,{...K(n),forceFresh:!0,previousWorkspace:r})}async getDuplicationTokenCache(e){let r=this.duplicationTokenCaches.get(e);return r||(r=Pe(Zi(e)),this.duplicationTokenCaches.set(e,r)),r}flushDuplicationTokenCache(e){let r=this.duplicationTokenCaches.get(e);if(r)try{Ae(r,Zi(e))}catch(n){process.stderr.write(`Warning: failed to persist duplication token cache: ${n}
56
+ `)}}invalidate(e){let r=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.workspaceBuilds.delete(e),this.layouts.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),this.duplicationTokenCaches.delete(e),this.configs.delete(e),r}};var Y=d(require("path"));var ea=d(require("fs")),ta=d(require("os")),or=d(require("path"));function b(t){return{content:[{type:"text",text:JSON.stringify(t)}]}}function ra(t){if(!or.default.isAbsolute(t))throw new Error("root must be an absolute path");let e=or.default.resolve(t),r=ta.default.homedir();if(e!==r&&!e.startsWith(r+or.default.sep))throw new Error("root must be within the user home directory");let n;try{n=ea.default.statSync(e)}catch{throw new Error("root does not exist")}if(!n.isDirectory())throw new Error("root is not a directory")}async function na(t,e){let{root:r,entryPoints:n}=e;if(!t.isConfigured(r)){let m=Oe(r,{allowJs:!1});hr(m),t.storeConfig(r,m)}if(n.length===0){let m=t.getLayout(r);if(m.type!=="none"){let g=t.getConfig(r),y={...K(g),packages:e.packages};if(t.storeLastAnalyze(r,{kind:"workspace"}),t.startWatching(r),!e.eager){let C=t.hasWorkspace(r)?t.requireWorkspace(r):void 0;return b(at(m,C))}let v=await t.getOrBuildWorkspace(r,y),x=Array.from(v.packages.values()).map(({graph:C,pkg:A})=>({package:A.name,relativeRoot:A.relativeRoot,nodeCount:C.nodes.size}));return b({monorepoType:m.type,packageCount:v.packages.size,packages:x})}}let s=n.map(m=>Y.default.resolve(r,m)),o=t.getConfig(r),i=o?.coverageReportPath?vr(r,o.coverageReportPath):new Map,a=await t.getOrBuild(r,s,i);t.storeLastAnalyze(r,{kind:"single",entryPoints:s,coverageMap:i}),t.startWatching(r);let c=a.serialize(),l=c.nodes.reduce((m,g)=>(m[g.category]=(m[g.category]??0)+1,m),{}),p=a.findCycles({includeKinds:e.cycleKinds}),u=nn(a);return b({nodeCount:c.nodes.length,categories:l,cycles:p,languageCoverage:u})}async function sa(t,e){let{root:r,file:n,depth:s=1,withMeta:o=!1}=e,i=await t.ensureFresh(r),a=un(i,n,s),c=o?a.map(l=>({...l,...rt(i,l.path)})):a;return b({file:n,dependencies:c})}async function oa(t,e){let{root:r,file:n,withMeta:s=!1}=e,o=await t.ensureFresh(r),i=nt(o,n),a=s?i.map(c=>({...c,...rt(o,c.path)})):i;return b({file:n,dependents:a})}async function ia(t,e){let{root:r,file:n,testsOnly:s=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,c=await t.ensureFresh(r),l=m=>a?m.map(g=>({path:g,...rt(c,g)})):m;if(o){let m=t.getOrBuildChangeImpact(r),g=Ar(m,n),y=s?g.filter(x=>c.nodes.get(x)?.category==="test"):g,v=l(y);return b({file:n,affected:v,count:v.length})}let p=mn(c,n,{testsOnly:s,changedSymbols:i}),u=l(p);return b({file:n,affected:u,count:u.length})}async function aa(t,e){let{root:r,baseRef:n,headRef:s,minDuplicateLines:o,complexityMetric:i,complexityThreshold:a}=e,c=await t.ensureFresh(r),l=e.entryPoints??t.getLastEntryPoints(r)?.map(u=>Y.default.relative(r,u))??[],p=await yn(r,n,c,{headRef:s,entryPoints:l,minDuplicateLines:o,complexityMetric:i,complexityThreshold:a,maxCoveragePct:e.maxCoveragePct,...K(t.getConfig(r))});return e.detail==="full"?b(p):b(hn(p,{metric:i,maxItems:e.maxItems}))}async function ca(t,e){let{root:r,file:n,depth:s=1,withEdgeDetail:o=!1}=e,i=await t.ensureFresh(r),a=fn(i,n,{depth:s,withEdgeDetail:o});return b({file:n,callers:a,count:a.length})}async function la(t,e){let{root:r,entryPoints:n}=e,s=n?await t.getOrBuild(r,n.map(c=>Y.default.resolve(r,c))):await t.ensureFresh(r),o=t.getConfig(r),i=nr(r,{additionalIgnoreDirs:o?.ignoreDirs??[],additionalExtensions:o?.extensions??[]}),a=s.findUnusedFiles(i);return b({unusedFiles:a,count:a.length})}async function pa(t,e){let{root:r}=e,n=await t.ensureFresh(r),s=new Map;for(let i of n.nodes.values())for(let a of i.tags)s.set(a.name,(s.get(a.name)??0)+1);let o=[...s.entries()].map(([i,a])=>({name:i,count:a})).sort((i,a)=>a.count-i.count);return b({tags:o,count:o.length})}async function ua(t,e){let{root:r,coverageThreshold:n}=e,s=await t.ensureFresh(r),o=t.getConfig(r),i=n??o?.coverageThreshold??80;if(!ce(s))return b({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...s.nodes.values()].filter(c=>c.category!=="test"&&c.category!=="config").filter(c=>c.coveragePct!==void 0&&c.coveragePct<i).map(c=>({file:c.path,coveragePct:c.coveragePct}));return b({threshold:i,uncovered:a,count:a.length})}async function ma(t,e){let{root:r}=e,s=[...(await t.ensureFresh(r)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return b({staleDocs:s,count:s.length})}async function fa(t,e){let{root:r,metric:n="cognitiveComplexity",threshold:s=10,limit:o=20}=e,i=await t.ensureFresh(r),a=De(i,{metric:n,threshold:s,limit:o});return b({metric:n,threshold:s,functions:a,count:a.length})}async function ga(t,e){let{root:r,metric:n="cognitiveComplexity",minComplexity:s=10,maxCoveragePct:o=50,minChurn:i=0,limit:a=20}=e,c=await t.ensureFresh(r);if(!ce(c))return b({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let{hotspots:l,count:p,churnDataAvailable:u}=Ie(c,{metric:n,minComplexity:s,maxCoveragePct:o,minChurn:i,limit:a});return b({metric:n,minComplexity:s,maxCoveragePct:o,minChurn:i,churnDataAvailable:u,hotspots:l,count:p})}async function da(t,e){let{root:r,minLines:n=6,ignoreLiterals:s=!0,maxPunctuationRatio:o=.5,limit:i=50}=e,a=await t.ensureFresh(r),c=t.getConfig(r),l=e.ignoreDirs??[...R,...c?.ignoreDirs??[]],{groups:p}=await Re(a,r,{minLines:n,ignoreLiterals:s,maxPunctuationRatio:o,limit:i,ignoreDirs:l,includeGenerated:e.includeGenerated??c?.duplication?.includeGenerated??!1,ignoreGlobs:c?.duplication?.ignoreGlobs??[],tokenCache:await t.getDuplicationTokenCache(r)});return t.flushDuplicationTokenCache(r),b({minLines:n,groups:p,count:p.length})}async function ha(t,e){let{root:r,changedFiles:n,base:s,featureThreshold:o,format:i="tags"}=e,a=await t.ensureFresh(r),c=n??new kt().getChangedFiles(r,s).map(u=>Y.default.relative(r,Y.default.resolve(r,u))),l=o!==void 0?{featureDetection:{minOutDegree:o}}:void 0;if(i==="paths"){let u=Vn(a,c,l);return b({changedFiles:c,affectedTests:u,count:u.length})}let p=qn(a,c,l);return b({changedFiles:c,proposedTags:p})}async function ya(t,e){let{root:r,entryPoints:n,featureThreshold:s}=e,o=n?await t.getOrBuild(r,n.map(c=>Y.default.resolve(r,c))):await t.ensureFresh(r),i=pe(o.nodes,s!==void 0?{minOutDegree:s}:void 0),a=Array.from(i.values()).sort((c,l)=>l.outDegree-c.outDegree);return b({features:a,count:a.length})}async function xa(t,e){let{root:r,entryPoints:n,filter:s,mermaid:o=!1,slim:i=!0}=e,a=n?await t.getOrBuild(r,n.map(l=>Y.default.resolve(r,l))):await t.ensureFresh(r),c=Bt(a.serialize(),Ht(s));return o?b(xt.serialize(D.deserialize(c))):i?b(gn(c)):b(c)}async function ba(t,e){let{root:r}=e,n=t.getLayout(r);if(n.type==="none")throw new Error(`${r} is not a recognized monorepo root (no pnpm/npm/yarn/Nx/Turborepo/Gradle/sbt workspace detected).`);let s=t.hasWorkspace(r)?t.requireWorkspace(r):void 0;return b(at(n,s))}async function Sa(t,e){let{root:r,file:n}=e,o=(await t.ensureFreshWorkspace(r)).getAffectedAcrossPackages(n);return b({file:n,affected:o,count:o.length})}function ka(t,e){let{root:r}=e,n=t.invalidate(r);return b({root:r,cleared:n,message:n?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function va(t,e){let{root:r,type:n}=e,s=await t.ensureFresh(r),o=Sn(s);if(n)return b(kn(o,n));let i=Array.from(o.types.values());return b({count:i.length,types:i})}async function Ca(t,e){let{root:r,paths:n,minOutDegree:s}=e,o=await t.ensureFresh(r),i=xn(o,s!==void 0?{minOutDegree:s}:void 0);if(n?.length){let c=n.map(l=>i.get(l)).filter(Boolean);return b({count:c.length,modules:c})}let a=Array.from(i.values());return b({count:a.length,modules:a})}async function wa(t,e){let{root:r,minOutDegree:n}=e,s=await t.ensureFresh(r),o=ot(s,n!==void 0?{minOutDegree:n}:void 0),i=Object.fromEntries(o.features);return b({features:i,unassigned:o.unassigned})}async function Ea(t,e){let{root:r,function:n}=e,s=await t.ensureFresh(r);return b(Fr(s,n))}async function Ta(t,e){let{root:r,name:n}=e,s=await t.ensureFresh(r),o=bn(s,n);return b({name:n,matches:o,count:o.length})}async function Fa(t,e){let{root:r,entryPoints:n}=e,s=await t.ensureFresh(r),o=n?.length?n:Er(s,r);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return b(Tr(s,o))}async function Pa(t,e){let r=await t.ensureFresh(e.root),n=await Jn(r,e.root,{dryRun:e.dryRun??!1});return b(n)}var Aa=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo/Gradle/sbt): this returns the package layout immediately and builds per-package graphs lazily on the first get_workspace_affected call \u2014 pass eager:true to build them all up front. Use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."},eager:{type:"boolean",description:"Monorepo only: build every package graph before returning (restores the { nodeCount, categories, cycles } payload) instead of the fast layout-only response. Default false."},packages:{type:"array",items:{type:"string"},description:"Monorepo only: restrict the build to these package names or relative roots. The escape hatch for very large monorepos."},cycleKinds:{type:"array",items:{type:"string",enum:["docReference","samePackage"]},description:"Include normally-filtered cycle edge kinds in the `cycles` output: 'docReference' (Markdown doc cross-links, ADR-009), 'samePackage' (JVM same-package siblings). Default: none \u2014 only genuine import cycles are reported."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. See docs/mcp.md for details on the testsOnly, cached, changedSymbols, and withMeta options.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"compare_branches",description:"Compare the current graph (root) against baseRef, for reviewing a PR/branch: file diff, stale post-rename references, and deltas for duplication, complexity, doc drift, and coverage/risk hotspots. Returns a compact summary by default (verdict + headline + capped delta lists); pass detail:'full' for every entry. See docs/mcp.md for details. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},baseRef:{type:"string",description:"Git ref to compare against, e.g. 'main', 'origin/main', or a commit sha"},headRef:{type:"string",description:"Git ref to label the head side of the comparison (default: 'HEAD'). The graph itself always comes from the already-analyzed root, not a checkout of this ref."},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the base-ref graph from, relative to root. Defaults to the entry points from the last analyze() call for this root."},minDuplicateLines:{type:"number",description:"Minimum duplicated block size, in source lines, for the duplication delta (default: 6)"},complexityMetric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which per-function score drives the complexity delta (default: cognitiveComplexity)"},complexityThreshold:{type:"number",description:"Minimum per-function score to count as a complexity hotspot (default: 10)"},maxCoveragePct:{type:"number",description:"Maximum containing-file coverage % to count as a risk hotspot (default: 50)"},detail:{type:"string",enum:["summary","full"],description:"'summary' (default): verdict, headline, and each delta list capped at maxItems with true counts; empty sections omitted. 'full': the complete BranchComparison with every entry."},maxItems:{type:"number",description:"In summary mode, max entries kept per delta list (complexity/duplication/doc-drift/coverage); the true count is always reported alongside (default: 8). Stale references are never truncated."}},required:["root","baseRef"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes. Omit entryPoints to reuse the cached graph from a prior analyze() call instead of rebuilding.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to reuse the cached graph from a prior analyze() call."}},required:["root"]}},{name:"list_tags",description:"List every distinct tag name present in the graph, with how many nodes carry each one. Call this before querying with tag:<name> to avoid a speculative filter silently returning zero results. Includes all tag kinds \u2014 a superset of what query's slim mode keeps (slim only retains comment-marker and import tags).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. Populated for TypeScript/JavaScript, Go, and Python.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"find_risk_hotspots",description:"Find functions that are complex, in a poorly-covered file, and \u2014 when gitStats is enabled in mokosh.config \u2014 in a frequently-changed file. Requires a prior analyze() call and coverageReportPath set in mokosh.config; errors if no coverage data was loaded. Churn filtering is skipped (churnDataAvailable: false) when gitStats wasn't enabled, since complexity + low coverage alone is still a meaningful signal.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which per-function score to filter/sort on (default: cognitiveComplexity)"},minComplexity:{type:"number",description:"Minimum per-function complexity score to include (default: 10)"},maxCoveragePct:{type:"number",description:"Maximum containing-file coverage % to include (default: 50)"},minChurn:{type:"number",description:"Minimum containing-file 90-day commit count to include (default: 0). Ignored when gitStats wasn't enabled at analyze time."},limit:{type:"number",description:"Max results to return, worst-first by metric (default: 20)"}},required:["root"]}},{name:"find_duplicates",description:"Find duplicated code blocks across the project, largest-first. CSS/SCSS/Less are matched structurally by rule body; every other parsed language is tokenized and matched via suffix array. Lock files and ignored directories are always excluded. Requires a prior analyze() call. See docs/mcp.md for matching-strategy, normalization, and caching details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minLines:{type:"number",description:"Minimum duplicated block size in lines to report (default: 6)"},ignoreLiterals:{type:"boolean",description:"Normalize string/number literals too, not just identifiers, so only structural shape drives a match (default: true). Set false for stricter, exact-text-only matching."},maxPunctuationRatio:{type:"number",description:"Maximum fraction of a token-shingled block's window that may be object/array-literal structural punctuation ({ } : , [ ]) (default: 0.5). Filters out blocks that are mostly schema/object-literal shape instead of substantive shared logic. Does not apply to the CSS/Less/SCSS structural comparator. Set 1 to disable."},ignoreDirs:{type:"array",items:{type:"string"},description:"Directory names to exclude, matched against any path segment (default: DEFAULT_IGNORE_DIRS merged with this root's configured ignoreDirs, if any). Pass [] to disable."},limit:{type:"number",description:"Max duplicate blocks to return, largest-first (default: 50)"},includeGenerated:{type:"boolean",description:"Scan generated / vendored files too (default: false). By default protobuf output, *.generated.* files, files under a generated/ directory, and files with a @generated / DO NOT EDIT / Code generated by marker in their first ~500 bytes are skipped \u2014 their repetition isn't actionable copy-paste. Matches involving a generated file are tagged signals: ['generated']."}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},base:{type:"string",description:"Diff against this ref (e.g. 'origin/main') instead of only local working-tree/staged/untracked changes. Ignored when changedFiles is given. Needed in CI, where the checkout is already clean."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, path, or other node metadata. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used. See docs/mcp.md for the full query DSL reference.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Tags are filtered to kinds comment-marker and import only; function/class/variable/type/library tags are dropped in slim output. Use list_tags to see the full tag inventory, or pass slim: false to get every tag kind on matching nodes."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo: name, relativeRoot, and dependsOn. Answers from the repo layout and package.json manifests alone \u2014 no analyze() required and no graph build, so it is fast on large monorepos. Per-package nodeCount (and, for Gradle/sbt monorepos, exact dependsOn edges) are included only when a workspace graph is already built from a prior analyze() call; check the dependsOnResolved / nodeCountsResolved flags in the response.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 it returns only paths grouped by hub, so it's substantially smaller than a full graph query for the same question; compare output sizes yourself if you need an exact figure for your repo.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language \u2014 check each match's `precision` field ('call' | 'file-level') before trusting caller/importer results as symbol-exact. See docs/mcp.md for per-language coverage details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project: every exported symbol resolved to its defining file and kind, partitioned into internalFiles, unreachableFromEntry, and testFiles. Requires a prior analyze() call. When entryPoints is omitted, auto-detects from package.json exports/main/module. See docs/mcp.md for the export* expansion and partition semantics.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph and loaded mokosh.config.json for a project root, forcing the next analyze() call to rebuild from disk and re-read config. Call this after editing source files OR mokosh.config.json mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data (or a stale config).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph, as an idempotent block \u2014 re-running is safe, the existing block is replaced in place. Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call. See docs/mcp.md for tag-kind and per-language block syntax details.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function ar(){let t=new sr,e=new Na.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(ir.ListToolsRequestSchema,async()=>({tools:Aa})),e.setRequestHandler(ir.CallToolRequestSchema,async r=>{let{name:n,arguments:s}=r.params,o=s,a={analyze:c=>na(t,c),get_dependencies:c=>sa(t,c),get_dependents:c=>oa(t,c),get_affected:c=>ia(t,c),compare_branches:c=>aa(t,c),get_callers:c=>ca(t,c),find_symbol:c=>Ta(t,c),find_unused:c=>la(t,c),find_uncovered:c=>ua(t,c),list_tags:c=>pa(t,c),check_doc_drift:c=>ma(t,c),find_complex_functions:c=>fa(t,c),find_risk_hotspots:c=>ga(t,c),find_duplicates:c=>da(t,c),propose_tags:c=>ha(t,c),detect_features:c=>ya(t,c),get_type_graph:c=>va(t,c),get_module_responsibility:c=>Ca(t,c),get_feature_graph:c=>wa(t,c),get_call_graph:c=>Ea(t,c),get_api_surface:c=>Fa(t,c),query:c=>xa(t,c),get_workspace_packages:c=>ba(t,c),get_workspace_affected:c=>Sa(t,c),clear_cache:c=>ka(t,c),apply_tags:c=>Pa(t,c)}[n];if(!a)throw new Error(`Unknown tool: ${n}`);try{return ra(o.root),await a(o)}catch(c){return{content:[{type:"text",text:`Error: ${c instanceof Error?c.message:String(c)}`}],isError:!0}}}),e}async function lf(){let t=ar(),e=new Ra.StdioServerTransport;await t.connect(e)}lf().catch(console.error);0&&(module.exports={createMcpServer});
53
57
  //# sourceMappingURL=mcp.js.map