@omfalos/mokosh 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -179
- package/dist/cli.js +60 -38
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +60 -38
- package/dist/cli.mjs.map +1 -1
- package/dist/duplication-worker.d.mts +2 -2
- package/dist/duplication-worker.d.ts +2 -2
- package/dist/duplication-worker.js +4 -4
- package/dist/duplication-worker.js.map +1 -1
- package/dist/duplication-worker.mjs +4 -4
- package/dist/duplication-worker.mjs.map +1 -1
- package/dist/index.d.mts +257 -45
- package/dist/index.d.ts +257 -45
- package/dist/index.js +39 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -27
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +42 -30
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +42 -30
- package/dist/mcp.mjs.map +1 -1
- package/dist/parse-worker.d.mts +2 -2
- package/dist/parse-worker.d.ts +2 -2
- package/dist/parse-worker.js +6 -2
- package/dist/parse-worker.js.map +1 -1
- package/dist/parse-worker.mjs +6 -2
- package/dist/parse-worker.mjs.map +1 -1
- package/dist/{parse-CAKctgb6.d.mts → parse-yamNoaoL.d.mts} +1 -1
- package/dist/{parse-CAKctgb6.d.ts → parse-yamNoaoL.d.ts} +1 -1
- package/dist/{tokenizer-BaF1eUBQ.d.mts → tokenizer-DIbb0GLe.d.mts} +2 -2
- package/dist/{tokenizer-BaF1eUBQ.d.ts → tokenizer-DIbb0GLe.d.ts} +2 -2
- package/dist/{types-BtSqoqbZ.d.mts → types-C153Tz5u.d.mts} +1 -1
- package/dist/{types-BlN-U5AM.d.ts → types-y90pqeDR.d.ts} +1 -1
- package/package.json +13 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,51 +1,63 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}}});var
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`&&
|
|
2
|
+
var gr=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var g=(t,e)=>()=>(t&&(e=t(t=0)),e);var Dl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Il from"path";import{fileURLToPath as Rl}from"url";var Al,Ml,m,l=g(()=>{"use strict";Al=()=>Rl(import.meta.url),Ml=()=>Il.dirname(Al()),m=Ml()});function ft(t){dr.push(t)}function Mo(t){return[...Ll,...dr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function mt(t){hr.push(t)}function _e(){return[...Ol,...hr]}function ut(t){yr.push(t)}function xr(){return[..._l,...yr]}function Sr(t){br=t}function Cr(){return br}function gt(){dr.length=0,hr.length=0,yr.length=0,br=Lo}var Ll,dr,Ol,hr,_l,yr,Lo,br,de=g(()=>{"use strict";l();Ll=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],dr=[];Ol=[".test.",".spec.","-test.","-spec."],hr=[];_l=["jest","vitest","playwright","cypress","@testing-library/"],yr=[];Lo=.8,br=Lo});import kr from"fs";import Oo from"path";function he(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=Oo.resolve(t);return kr.existsSync(n)?n.endsWith(".json")?_o(n):e?Go(n):{}:{}}for(let n of Gl){let o=Oo.resolve(t,n);if(kr.existsSync(o)){if(n.endsWith(".json"))return _o(o);if(e)return Go(o)}}return{}}function _o(t){return JSON.parse(kr.readFileSync(t,"utf-8"))}function Go(t){let e=gr(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function vr(t){gt();for(let e of t.configMatchers??[])ft(e);for(let e of t.testPatterns??[])mt(e);for(let e of t.testLibraries??[])ut(e);t.barrelThreshold!==void 0&&Sr(t.barrelThreshold)}function T(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var Gl,wr=g(()=>{"use strict";l();de();Gl=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var V,te,ye,Ge,I,Er,G=g(()=>{"use strict";l();V="mokosh-cache",te="duplication-tokens.json",ye="graph.json",Ge="branch-graphs",I=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],Er=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".java",".kt",".kts",".scala",".sc",".groovy",".gradle",".feature",".md",".mdx"]});import ah from"fs";import lh from"path";var jo=g(()=>{"use strict";l()});var dt,$o=g(()=>{"use strict";l();dt={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let o=`"${n.path}"`;for(let s of n.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${n.path} -> ${s.toPath}`;if(!r.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),r.add(a)}}}return e.join(`
|
|
3
|
+
`)}}});var Wo=g(()=>{"use strict";l();$o()});import zo from"fs";import $l from"path";function Tr(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 Bo(t,e){if(typeof t=="string")return Tr(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let o=Bo(r[n],e);if(o)return o}}return null}function Wl(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 zl(t,e){let r=new Set,n=new Set,o=[...e];for(;o.length;){let s=o.shift();if(n.has(s))continue;n.add(s);let i=t.nodes.get(s);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 p=t.nodes.get(a.toPath);if(p)for(let f of p.exports)r.add(f.name);o.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function Fr(t,e){let r=[],n=$l.join(e,"package.json");if(zo.existsSync(n))try{let o=JSON.parse(zo.readFileSync(n,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=Bo(s,t);i&&!r.includes(i)&&r.push(i)}else if(typeof o.exports=="string"){let s=Tr(o.exports,t);s&&r.push(s)}if(r.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Tr(s,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){r.push(o);break}}return r}function Bl(t,e){let r=new Set(e);for(let n of e)t.traverse(n,o=>(r.add(o.path),!0),{direction:"outgoing"});return r}function Hl(t,e,r){let n=new Map;for(let o of e){if(r.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:o,symbol:a})}}return n}function Ul(t,e,r,n){let o=[];for(let s of t){let i=e.get(s),a=n.flatMap(u=>r.nodes.get(u)?.exports??[]).find(u=>u.name===s),c=i?.symbol??a,p=i?.file??n.find(u=>r.nodes.get(u)?.exports.some(y=>y.name===s))??n[0],f={name:s,definedIn:p,kind:Wl(c?.signature)};c?.doc&&(f.doc=c.doc),c?.signature&&(f.signature=c.signature),o.push(f)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function Jl(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!r.includes(c)&&!n(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!n(c)),a=s.filter(c=>n(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function Nr(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=Bl(t,e),n=Hl(t,r,e),o=zl(t,e),s=Ul(o,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Jl(t,r,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var Pr=g(()=>{"use strict";l()});function Dr(t,e){let r=null,n=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(r=s.path);for(let i of s.callEdges??[])i.to===e&&n.push({file:s.path,callerFunction:i.from})}let o=[];if(r){let s=t.nodes.get(r);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:o}}var Ir=g(()=>{"use strict";l()});import wh from"fs";import Th from"path";function Ho(t){let e=[...t.nodes.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>`${n}:${o.mtime}:${o.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 Rr(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,o=>(o.path!==r&&n.push(o.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Ho(t)}}function Ar(t,e){return t.impact.get(e)??[]}var Mr=g(()=>{"use strict";l()});var je,Uo=g(()=>{"use strict";l();je=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 o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.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 p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var D,xe=g(()=>{"use strict";l();Uo();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 o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,f)=>{if(p>i||s.has(c))return;let u=this.nodes.get(c);if(u&&(s.add(c),r(u,p,f)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.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 je(this.nodes).findUnusedFiles(e)}findCycles(){return new je(this.nodes).findCycles()}}});import $e from"fs";import Jo from"path";function ht(t){return Jo.join(t,V,Ge)}function Ko(t,e){return Jo.join(ht(t),`${e}.json`)}function Vo(t,e){let r=Ko(t,e);if(!$e.existsSync(r))return null;try{let n=$e.readFileSync(r,"utf-8");return D.deserialize(JSON.parse(n))}catch{return null}}function qo(t,e,r){let n=ht(t);$e.existsSync(n)||$e.mkdirSync(n,{recursive:!0}),$e.writeFileSync(Ko(t,e),JSON.stringify(r.serialize()))}var Qo=g(()=>{"use strict";l();G();xe()});import{execFileSync as Lr}from"child_process";function Zo(t,e){let r="",n=0;for(let o of t.split(`
|
|
4
|
+
`)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function es(t){let e=new Map;try{let r=Lr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${Yo}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Xo});Zo(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Lr("git",["-C",t,"log","--name-status","-M",`--format=${Yo}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:Xo});Zo(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var yt,Yo,Xo,Or=g(()=>{"use strict";l();yt=class{getChangedFiles(e,r){try{let o=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...r?[["diff","--name-only","--end-of-options",`${r}...HEAD`]]:[]].flatMap(s=>{try{return Lr("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
+
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(n){return console.error("Error getting git diff:",n),[]}}},Yo="%x00%H%x09%ae%x09%at",Xo=256*1024*1024});var We,_r=g(()=>{"use strict";l();We=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});import xt from"fs";import Kl from"path";import{load as ts}from"js-yaml";function rs(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Vl(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)),rs(r)}).filter(Boolean)}function ql(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 Ql(t){try{let e=ts(t),r={dependencies:{}};for(let[n,o]of Object.entries(e))if(!(n==="__metadata"||!o?.version))for(let s of n.split(", ")){let i=rs(s);i&&(r.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return r}catch{return null}}function Yl(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 o=n[0];if(!o||o.startsWith(" "))continue;let s=Vl(o);if(s.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function ns(t){let e=xt.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[o,s]of Object.entries(r.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies))n.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return n}function os(t){let e=xt.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Ql(e);if(r!==null)return r}return Yl(e)}function ss(t){let e=xt.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=ts(e);if(n.packages)for(let[o,s]of Object.entries(n.packages)){let{name:i,version:a}=ql(o,s.version);i&&(r.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies)){if(r.dependencies[o])continue;let i=typeof s=="string"?s:s.version;r.dependencies[o]={version:i||""}}}catch{}return r}function Gr(t){for(let e of We){let r=Kl.join(t,e);if(xt.existsSync(r))return Xl[e](r)}return null}var Xl,jr=g(()=>{"use strict";l();_r();Xl={"package-lock.json":ns,"yarn.lock":os,"pnpm-lock.yaml":ss}});function is(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 Zl(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=is(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*["']([^"']+)["']/),o=r?r[1].split(":")[0]:n?.[1];if(!o)return null;let s=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:o,...i?.[1]!==void 0&&{version:i[1]},...s?.[1]!==void 0&&{versionRef:s[1]}}}function $r(t){let e=t.split(/\r?\n/).map(s=>s.replace(/#.*$/,"").trim()),r={},n="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="versions"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=s.slice(0,a).trim(),p=is(s.slice(a+1));c&&p&&(r[c]=p)}let o={};n="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){n=i[1];continue}if(n!=="libraries"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=Zl(s.slice(a+1));if(!c)continue;let p=c.versionRef?r[c.versionRef]:c.version;p&&(o[c.group]=p)}return o}function Wr(t){let e={};for(let r of t.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#")||n.startsWith("empty="))continue;let s=n.split("=")[0].split(":");s.length>=3&&s[0]&&s[2]&&(e[s[0]]=s[2])}return e}function zr(t){let e={},r=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let o=r.exec(t);o;o=r.exec(t)){let[,s,,i]=o;s&&i&&/\d/.test(i)&&(e[s]=i)}let n=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let o=n.exec(t);o;o=n.exec(t))o[1]&&o[2]&&/\d/.test(o[2])&&(e[o[1]]=o[2]);return e}var Br=g(()=>{"use strict";l()});function bt(t){let e={},r=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let n=r.exec(t);n;n=r.exec(t)){let[,o,,s]=n;o&&s&&(e[o]=s)}return e}var Hr=g(()=>{"use strict";l()});import Ct from"fs";import St from"path";function ze(t){try{return Ct.existsSync(t)?Ct.readFileSync(t,"utf-8"):null}catch{return null}}function Ur(t){let e={},r=f=>{for(let[u,y]of Object.entries(f))!e[u]&&y&&(e[u]=y)},n=ze(St.join(t,"gradle","libs.versions.toml"));n&&r($r(n));let o=[],s=[],i=[],a=(f,u)=>{let y;try{y=Ct.readdirSync(f,{withFileTypes:!0})}catch{return}for(let x of y){let b=St.join(f,x.name);if(x.isDirectory()){u<tp&&!x.name.startsWith(".")&&!ep.has(x.name)&&a(b,u+1);continue}x.isFile()&&(x.name==="gradle.lockfile"?o.push(b):x.name==="build.gradle"||x.name==="build.gradle.kts"?s.push(b):x.name==="build.sbt"&&i.push(b))}};a(t,0);for(let f of o){let u=ze(f);u&&r(Wr(u))}for(let f of s){let u=ze(f);u&&r(zr(u))}for(let f of i){let u=ze(f);u&&r(bt(u))}try{let f=St.join(t,"project");for(let u of Ct.readdirSync(f,{withFileTypes:!0}))if(u.isFile()&&u.name.endsWith(".scala")){let y=ze(St.join(f,u.name));y&&r(bt(y))}}catch{}let c=Object.keys(e);if(c.length===0)return null;let p={};for(let f of c)p[f]={version:e[f]};return p}var ep,tp,Jr=g(()=>{"use strict";l();Br();Hr();ep=new Set(["node_modules","build",".gradle","target",".git","dist"]),tp=2});function as(t){let e=Gr(t),r=Ur(t);return r?{...e??{dependencies:{}},jvmDependencies:r}:e}var Kr=g(()=>{"use strict";l();jr();Jr();Br();jr();Jr();Hr();_r()});import cs from"path";function z(t){switch(cs.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 R(t){let e=cs.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var q=g(()=>{"use strict";l()});function Q(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function be(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 Se(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var kt=g(()=>{"use strict";l()});import rp from"coffeescript";function ps(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return Q(t.value)}}function re(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function np(t,e){let r=ps(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:R(r),type:"static"}:null}function op(t,e){let r=e.variable?.base?.value==="require",n=ps(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:R(n),type:"require"}}function ls(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let o=re(r.variable);return o?[{name:o}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(o=>re(o.variable)??re(o)).filter(o=>!!o).map(o=>({name:o}));let n=re(r);return n?[{name:n}]:[]}function sp(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=re(t.variable)??re(t.variable?.base);return e?[{name:e}]:[]}function ip(t,e,r,n){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=np(t,e);s&&r.push(s)}else if(o==="Call"){let s=op(t,e);s&&r.push(s)}else if(o==="Assign"){let s=re(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?n.push(...ls(e,void 0)):s==="exports"&&typeof i=="string"&&n.push(...ls(e,i))}else o==="ExportNamedDeclaration"&&e.clause?n.push(...sp(e.clause)):o==="ExportDefaultDeclaration"&&n.push({name:"default"})}function Vr(t,e,r,n){if(!(!e||typeof e!="object")){ip(t,e,r,n);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)Vr(t,i,r,n);else Vr(t,s,r,n)}}}function fs(t,e){let r=be(e),n=Se(t,r),o=[],s=[];try{Vr(t,rp.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var ms=g(()=>{"use strict";l();q();kt()});function Ce(t,e){us.set(t,e)}function gs(t){return us.get(t)}var us,Be=g(()=>{"use strict";l();us=new Map});import{AstBuilder as ap,GherkinClassicTokenMatcher as cp,Parser as lp}from"@cucumber/gherkin";import{IdGenerator as pp}from"@cucumber/messages";function qr(t,e){let r=new Set,n=o=>{for(let s of o)r.add(s.name.startsWith("@")?s.name.slice(1):s.name)};try{let o=new ap(fp),s=new cp,a=new lp(o,s).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 p of c.scenario.examples)n(p.tags)}if(c.rule)for(let p of c.rule.children)p.scenario&&n(p.scenario.tags)}}}catch(o){console.warn(`[GherkinParser] Failed to parse ${t}:`,o)}return{imports:[],exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:"test"}}var fp,ds=g(()=>{"use strict";l();Be();fp=pp.uuid();Ce("gherkin",qr)});function ne(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function oe(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
|
|
7
|
+
`&&r++;return r}var vt=g(()=>{"use strict";l()});function mp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function ys(t,e,r,n){let o=r?1:1+e,s=ne(t),i=r?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=ke(a,i,!1,n));let c=s.find(f=>f.type.name==="Block");c&&(o+=ke(c,i,!1,n));let p=s.findIndex(f=>f.type.name==="else");if(p>=0){let f=s[p+1];f?.type.name==="IfStatement"?o+=ys(f,e,!0,n):f&&(o+=1+ke(f,e+1,!1,n))}return o}function hs(t,e,r){let n=1+e,o=t.firstChild;for(;o;)n+=ke(o,e+1,!1,r),o=o.nextSibling;return n}function up(t,e,r){let n=0,o=t.firstChild;for(;o;)n+=ke(o,e,!1,r),o=o.nextSibling;return n}function gp(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function ke(t,e,r,n){let o=t.type.name;if(o==="IfStatement")return ys(t,e,r,n);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return hs(t,e,n);let s=o==="LogicOp"&&gp(t,n)?1:0;return e>0&&o==="FunctionLiteral"?s+hs(t,e,n):s+up(t,e,n)}function dp(t,e){return ke(t,0,!1,e)}function wt(t,e){return{complexity:mp(t,e),cognitiveComplexity:dp(t,e)}}function Qr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function xs(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=wt(n.node,e);r.push({name:s,line:oe(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Qr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=wt(n.node,e);r.push({name:a,line:oe(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var bs=g(()=>{"use strict";l();vt()});import hp from"path";import{parser as yp}from"@lezer/go";function Cs(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=yp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let S=e.slice(c.from,c.to),v=S.match(xp);v?.[1]&&o.add(v[1]);let _=S.match(bp);_&&Ss(_[1],s);let O=S.match(Sp);O&&Ss(O[1],s);break}case"ImportSpec":{let S=c.node.getChild("String");if(S){let _=e.slice(S.from,S.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:_,isExternal:!0,isStyle:!1,type:"static"});let O=c.node.getChild("DefName"),ee=O?e.slice(O.from,O.to):_.split("/").pop();ee&&ee!=="_"&&ee!=="."&&i.set(ee,_)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let S=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(S){let v=e.slice(S.from,S.to);v!=="_"&&/^[A-Z]/.test(v)&&!n.has(v)&&n.set(v,{name:v})}break}}while(c.next());let p=r.some(S=>S.rawSpecifier==="testing"),f=hp.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",u=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=wt(a.topNode,e),b=xs(a,e),w=f==="test"?[]:Cp(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(u).map(S=>({name:S,kind:"comment-marker"})),category:f,rawCallEdges:w,complexity:y,cognitiveComplexity:x,...b.length>0?{functions:b}:{}}}function Cp(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let f=p.firstChild,u=p.getChild("FieldName");if(f?.type.name==="VariableName"&&u){let y=e.slice(f.from,f.to),x=r.get(y);if(x){let b=e.slice(u.from,u.to);n.push({from:a,to:b,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=Qr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.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 xp,bp,Sp,ks=g(()=>{"use strict";l();bs();xp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,bp=/^\/\/go:build\s+(.+)$/,Sp=/^\/\/\s*\+build\s+(.+)$/});function ve(t){let e=new Set;for(let r of t.matchAll(kp))r[1]&&e.add(r[1]);return e}function Y(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 we(t){let e=Y(t),r=new Set;for(let o of e.matchAll(/@([A-Z]\w*)/g))o[1]&&r.add(o[1]);let n=new Set;for(let o of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))o[1]&&n.add(o[1]);return{annotations:[...r],typeNames:[...n]}}function Ee(t,e){return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static"}}function X(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect"}}function j(t,e){let r=[];for(let n of Y(t).split(`
|
|
8
|
+
`)){let o=n.trim();if(!o||o.startsWith("@")||o.startsWith("*"))continue;let s=o.match(/^package\s+(?:object\s+)?([\w.]+)/);if(s?.[1]){if(r.push(s[1]),!e)break;continue}if(!(e&&/^import\s/.test(o)))break}return r.length>0?r.join("."):null}function B(t,e,r={}){let n=t.replace(/\\/g,"/"),o=n.split("/").pop()??"";if(o.endsWith(".gradle")||o==="build.gradle.kts"||o==="settings.gradle.kts")return"config";if(/\/src\/(test|androidTest|integrationTest|it)\//.test(n)||e.some(i=>vp.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let s=r.annotations??[];return s.some(i=>wp.has(i))?"config":s.some(i=>Ep.has(i))||(r.typeNames??[]).some(i=>Fp.some(a=>i.endsWith(a)))?"ui":(s.some(i=>Tp.has(i)),"logic")}var kp,vp,wp,Ep,Tp,Fp,Te=g(()=>{"use strict";l();kp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,vp=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework"];wp=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Ep=new Set(["Composable","Preview"]),Tp=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Fp=["Activity","Fragment","ViewModel","Screen","Composable"]});function Dp(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function vs(t,e){let r=ve(e),o=Y(e).split(`
|
|
9
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(Np);if(f?.[2]){let y=Dp(!!f[1],f[2]);y&&s.push(Ee(t,y));continue}let u=p.match(Pp);u?.[2]&&i.add(u[2])}let a=j(e,!1);a&&s.push(X(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:B(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:we(e).annotations})}}var Np,Pp,ws=g(()=>{"use strict";l();Te();Np=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Pp=/^(?:@\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 Rp(t,e){let r=1;function n(o){let s=o.type.name;if(s==="IfStatement"||s==="CatchClause"||s==="TernaryExpression")r++;else if(Es.has(s))r++;else if(s==="SwitchLabel")o.firstChild?.type.name==="case"&&r++;else if(s==="LogicOp"){let a=e.slice(o.from,o.to);(a==="&&"||a==="||")&&r++}let i=o.firstChild;for(;i;)n(i),i=i.nextSibling}return n(t),r}function Ts(t,e,r,n){let o=r?1:1+e,s=[];for(let f=t.firstChild;f;f=f.nextSibling)s.push(f);let i=r?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Fe(a,i,!1,n));let c=s.find(f=>f.type.name==="Block");c&&(o+=Fe(c,i,!1,n));let p=s.findIndex(f=>f.type.name==="else");if(p>=0){let f=s[p+1];f?.type.name==="IfStatement"?o+=Ts(f,e,!0,n):f&&(o+=1+Fe(f,e+1,!1,n))}return o}function Yr(t,e,r){let n=1+e,o=t.firstChild;for(;o;)n+=Fe(o,e+1,!1,r),o=o.nextSibling;return n}function Ap(t,e,r){let n=0,o=t.firstChild;for(;o;)n+=Fe(o,e,!1,r),o=o.nextSibling;return n}function Mp(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function Fe(t,e,r,n){let o=t.type.name;if(o==="IfStatement")return Ts(t,e,r,n);if(Es.has(o)||o==="SwitchStatement"||o==="CatchClause"||o==="TernaryExpression")return Yr(t,e,n);let s=o==="LogicOp"&&Mp(t,n)?1:0;return e>0&&o==="LambdaExpression"?s+Yr(t,e,n):s+Ap(t,e,n)}function Lp(t,e){return Fe(t,0,!1,e)}function Xr(t,e){return{complexity:Rp(t,e),cognitiveComplexity:Lp(t,e)}}function Zr(t,e){for(let r=t.parent;r;r=r.parent)if(Ip.has(r.type.name)){let n=r.getChild("Definition");if(n)return e.slice(n.from,n.to)}}function Fs(t,e){let r=[],n=t.cursor();do if(n.name==="MethodDeclaration"||n.name==="ConstructorDeclaration"){let o=n.node.getChild("Definition");if(o){let s=e.slice(o.from,o.to),i=Zr(n.node,e),a=i&&n.name==="MethodDeclaration"?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=Xr(n.node,e);r.push({name:a,line:oe(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var Es,Ip,Ns=g(()=>{"use strict";l();vt();Es=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Ip=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"])});import{parser as Op}from"@lezer/java";function Gp(t,e){let r=t.getChild("ScopedIdentifier");if(!r)return null;let n=t.getChild("static")!=null,o=t.getChild("Asterisk")!=null,s=e.slice(r.from,r.to);return n?(o||(s=s.split(".").slice(0,-1).join(".")),s?{specifier:s,wildcard:!1}:null):o?{specifier:`${s}.*`,wildcard:!0}:{specifier:s,wildcard:!1}}function jp(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 o=n.split(".").pop();o&&e.set(o,n)}return e}function $p(t,e,r){let n=[];function o(i,a){let c=i.type.name;if(c==="MethodInvocation"){let f=i.firstChild;if(f?.type.name==="Identifier"){let u=r.get(e.slice(f.from,f.to)),y=i.getChild("MethodName");u&&y&&n.push({from:a,to:e.slice(y.from,y.to),toSpecifier:u})}}else if(c==="ObjectCreationExpression"){let f=i.getChild("TypeName");if(f){let u=r.get(e.slice(f.from,f.to));u&&n.push({from:a,to:"new",toSpecifier:u})}}let p=i.firstChild;for(;p;)o(p,a),p=p.nextSibling}let s=t.cursor();do if(s.name==="MethodDeclaration"||s.name==="ConstructorDeclaration"){let i=s.node.getChild("Definition"),a=s.node.getChild("Block")??s.node.getChild("ConstructorBody");if(i&&a){let c=e.slice(i.from,i.to),p=Zr(s.node,e),f=p&&s.name==="MethodDeclaration"?`${p}.${c}`:c;o(a,f)}}while(s.next());return n}function Ps(t,e){let r=[],n=new Map,o=new Set,s=new Set,i;try{i=Op.parse(e)}catch{return{imports:[],exports:[],tags:[],category:B(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let b=e.slice(a.from,a.to).match(_p);b?.[1]&&o.add(b[1]);break}case"MarkerAnnotation":case"Annotation":{let b=a.node.getChild("Identifier");b&&s.add(e.slice(b.from,b.to));break}case"ImportDeclaration":{let b=Gp(a.node,e);b&&r.push({fromPath:t,toPath:"",rawSpecifier:b.specifier,isExternal:!0,isStyle:!1,type:"static"});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let b=a.node.getChild("Definition");if(b){let w=e.slice(b.from,b.to);n.has(w)||n.set(w,{name:w})}}break}}while(a.next());let c=j(e,!1);c&&r.push(X(t,c));let p=B(t,r.map(b=>b.rawSpecifier),{typeNames:[...n.keys()],annotations:[...s]}),{complexity:f,cognitiveComplexity:u}=Xr(i.topNode,e),y=Fs(i,e),x=p==="test"?[]:$p(i,e,jp(r));return{imports:r,exports:Array.from(n.values()),tags:Array.from(o).map(b=>({name:b,kind:"comment-marker"})),category:p,rawCallEdges:x,complexity:f,cognitiveComplexity:u,...y.length>0?{functions:y}:{}}}var _p,Ds=g(()=>{"use strict";l();Ns();Te();_p=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/});function Is(t,e){let r=ve(e),o=Y(e).split(`
|
|
10
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(Wp);if(f?.[1]){s.push(Ee(t,f[1]));continue}let u=p.match(zp);if(u?.[2]){i.add(u[2]);continue}let y=p.match(Bp);if(y?.[1]){i.add(y[1]);continue}let x=p.match(Hp);x?.[1]&&i.add(x[1])}let a=j(e,!1);a&&s.push(X(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:B(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:we(e).annotations})}}var Wp,en,zp,Bp,Hp,Rs=g(()=>{"use strict";l();Te();Wp=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,en="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",zp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),Bp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Hp=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${en}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import Up from"livescript";function se(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Jp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=se(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>se(r.key)??se(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=se(t);return e?[{name:e}]:[]}function Kp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=se(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return Jp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>se(n.val)??se(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function qp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=Q(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:R(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=Q(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:R(s),type:"require"}}}}return null}function tn(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=qp(t,e);o&&n.push(o),r.push(...Kp(t));for(let s in t){if(Vp.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...tn(a,e,r));else n.push(...tn(i,e,r))}return n}function As(t,e){let r=be(e),n=Se(t,r),o=[],s=[];try{o=tn(Up.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Vp,Ms=g(()=>{"use strict";l();q();kt();Vp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Qp from"luaparse";function Yp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=Q(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=Q(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:R(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Xp(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Zp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function ef(t){let e=t.body,r=Xp(e),n=Zp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Ls(t,e){let r=be(e),n=Se(t,r),o=[],s=[];try{let i=Qp.parse(e);o=Yp(i,t),s=ef(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Os=g(()=>{"use strict";l();q();kt()});async function of(){return _s??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),_s}function sf(t){let e=t.trim();return e.length===0||e.startsWith("#")||tf.some(r=>e.startsWith(r))}function af(t,e){let r=t.match(nf);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function Gs(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!sf(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...af(t.value,e)),Array.isArray(t.children))for(let n of t.children)Gs(n,e,r)}async function js(t,e){let n=(await of()).parse(e),o=[];Gs(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var tf,rf,nf,_s,$s=g(()=>{"use strict";l();tf=["http://","https://","mailto:","//"],rf="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",nf=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${rf})\\b`,"g")});function cf(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=ne(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=ne(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function lf(t,e){let r=0,n=ne(t),o=0,s=0;for(;s<n.length;){let i=n[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;r+=a?1:1+e;let c=a?e:e+1,p=n[s+1],f=n[s+2];p&&(r+=H(p,c)),f&&(r+=H(f,c)),o++,s+=3}else if(i?.type.name==="else"){r+=1;let a=n[s+1];a&&(r+=H(a,e+1)),s+=2}else s++}return r}function pf(t,e){let r=0,n=ne(t),o=0;for(;o<n.length;){let s=n[o];if(s?.type.name==="except"){for(r+=1+e,o++;o<n.length&&n[o]?.type.name!=="Body";)r+=H(n[o],e),o++;o<n.length&&(r+=H(n[o],e),o++)}else s?.type.name==="Body"&&(r+=H(s,e)),o++}return r}function Ws(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=H(n,e+1),n=n.nextSibling;return r}function ff(t,e){let r=0,n=t.firstChild;for(;n;)r+=H(n,e),n=n.nextSibling;return r}function H(t,e){let r=t.type.name;switch(r){case"IfStatement":return lf(t,e);case"TryStatement":return pf(t,e);case"ForStatement":case"WhileStatement":return Ws(t,e);default:{let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+Ws(t,e):n+ff(t,e)}}}function mf(t){return H(t,0)}function rn(t){return{complexity:cf(t),cognitiveComplexity:mf(t)}}function zs(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=rn(i);r.push({name:a,line:oe(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let u=f.getChild("VariableName"),y=u?e.slice(u.from,u.to):void 0;y&&n(f,c?`${c}.${y}`:y),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var Bs=g(()=>{"use strict";l();vt()});import uf from"path";import{parser as gf}from"@lezer/python";function Hs(t,e){let r=[],n=[],o=new Set,s=uf.basename(t).toLowerCase(),i=gf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of hf(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let w=a.node.getChild("VariableName");w&&n.push({name:e.slice(w.from,w.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=kf(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=rn(i.topNode),u=zs(i,e),y=c==="test"?[]:Cf(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:f,...u.length>0?{functions:u}:{}}}function hf(t,e,r){let n=t.firstChild;return n?n.name==="from"?yf(t,e,r):xf(t,e,r):[]}function yf(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=bf(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[He(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[He(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[He(r,p.slice(0,-1),["*"],!1)]:i.map(f=>He(r,p+f,[f],!1))}function xf(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(He(r,s,["*"],!0))}o=o.nextSibling}return n}function bf(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function Sf(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),u=i.nextSibling;for(;u;){if(u.type.name==="VariableName"){let y=e.slice(u.from,u.to),x=y;if(u.nextSibling?.type.name==="as"){let w=u.nextSibling.nextSibling;w?.type.name==="VariableName"&&(x=e.slice(w.from,w.to),u=w)}let b=c===0?a:p?f+p.replace(/\./g,"/"):f+y;r.set(x,b)}u=u.nextSibling}}while(n.next());return r}function Cf(t,e){let r=Sf(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,u=e.slice(f.from,f.to),y=r.get(u);y&&n.push({from:c,to:u,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,f=a.getChild("Body");if(f){let u=f.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let y=u.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(u,p?`${p}.${x}`:x)}else i(u);u=u.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function He(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function kf(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>df.has(n.rawSpecifier))?"test":"logic"}var df,Us=g(()=>{"use strict";l();Bs();df=new Set(["pytest","unittest","nose","hypothesis"])});function Ef(t,e){let r=e.split("=>")[0]?.trim();return r?r==="_"||r==="*"||r==="given"?`${t}.*`:`${t}.${r}`:null}function Tf(t){let e=t.indexOf("{");if(e!==-1){let n=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,n===-1?void 0:n);return o?s.split(",").map(i=>Ef(o,i.trim())).filter(i=>i!=null):[]}let r=[];for(let n of t.split(",")){let o=n.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&r.push(`${s}.*`)}else r.push(o)}return r}function Js(t,e){let r=ve(e),o=Y(e).split(`
|
|
11
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(vf);if(f?.[1]){for(let y of Tf(f[1]))s.push(Ee(t,y));continue}let u=p.match(wf);u?.[2]&&i.add(u[2])}let a=j(e,!0);a&&s.push(X(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:B(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:we(e).annotations})}}var vf,wf,Ks=g(()=>{"use strict";l();Te();vf=/^\s*import\s+(.+?)\s*$/,wf=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/});import C from"typescript";function Ff(t){let e=1;function r(n){switch(n.kind){case C.SyntaxKind.IfStatement:case C.SyntaxKind.ConditionalExpression:case C.SyntaxKind.ForStatement:case C.SyntaxKind.ForInStatement:case C.SyntaxKind.ForOfStatement:case C.SyntaxKind.WhileStatement:case C.SyntaxKind.DoStatement:case C.SyntaxKind.CatchClause:case C.SyntaxKind.CaseClause:e++;break;case C.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===C.SyntaxKind.AmpersandAmpersandToken||o===C.SyntaxKind.BarBarToken||o===C.SyntaxKind.QuestionQuestionToken)&&e++;break}}C.forEachChild(n,r)}return r(t),e}function qs(t,e,r){let n=r?1:1+e,o=r?e:e+1;return n+=ie(t.expression,o,!1),n+=ie(t.thenStatement,o,!1),t.elseStatement&&(C.isIfStatement(t.elseStatement)?n+=qs(t.elseStatement,e,!0):n+=1+ie(t.elseStatement,e+1,!1)),n}function Vs(t,e){let r=1+e;return C.forEachChild(t,n=>{r+=ie(n,e+1,!1)}),r}function Nf(t,e){let r=1+e;return C.forEachChild(t,n=>{r+=ie(n,e,!1)}),r}function Pf(t,e){let r=0;return C.forEachChild(t,n=>{r+=ie(n,e,!1)}),r}function Df(t){let e=t.operatorToken.kind;return e===C.SyntaxKind.AmpersandAmpersandToken||e===C.SyntaxKind.BarBarToken||e===C.SyntaxKind.QuestionQuestionToken}function ie(t,e,r){if(C.isIfStatement(t))return qs(t,e,r);if(C.isForStatement(t)||C.isForInStatement(t)||C.isForOfStatement(t)||C.isWhileStatement(t)||C.isDoStatement(t)||C.isSwitchStatement(t))return Vs(t,e);if(C.isCatchClause(t))return Nf(t,e);let n=0;return C.isConditionalExpression(t)&&(n+=1),C.isBinaryExpression(t)&&Df(t)&&(n+=1),e>0&&(C.isFunctionDeclaration(t)||C.isFunctionExpression(t)||C.isArrowFunction(t))?n+Vs(t,e):n+Pf(t,e)}function If(t){return ie(t,0,!1)}function nn(t){return{complexity:Ff(t),cognitiveComplexity:If(t)}}var Qs=g(()=>{"use strict";l()});import E from"typescript";function Ys(t,e){Rf(t,e),Mf(t,e),Lf(t,e),Of(t,e)}function Rf(t,e){if((E.isFunctionDeclaration(t)||E.isVariableDeclaration(t))&&t.name&&E.isIdentifier(t.name)&&Af(t)){let r;if(E.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(E.isArrowFunction(n)||E.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Af(t){if(E.isFunctionDeclaration(t))return E.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&E.isSourceFile(e.parent)}function Mf(t,e){if(!E.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function Lf(t,e){if(!E.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function Of(t,e){if(E.isCallExpression(t)&&_f(t.expression))for(let r of t.arguments)E.isObjectLiteralExpression(r)&&Gf(r,e)}function _f(t){return E.isIdentifier(t)?on.has(t.text):!!(E.isPropertyAccessExpression(t)&&(on.has(t.name.text)||E.isIdentifier(t.expression)&&on.has(t.expression.text)))}function Gf(t,e){for(let r of t.properties){if(!E.isPropertyAssignment(r)||!E.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=E.isArrayLiteralExpression(n)?n.elements.filter(E.isStringLiteral):r.name.text==="tag"&&E.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var on,Xs=g(()=>{"use strict";l();on=new Set(["test","describe","it"])});import Zs from"path";import h from"typescript";function sn(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=w=>{zf(w,a),h.forEachChild(w,c)};c(i);let p=Zf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&em(a,i);let f=i.statements[0],u=f?ti(f):void 0,{complexity:y,cognitiveComplexity:x}=nn(i),b=jf(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...b.length>0?{functions:b}:{},...u!==void 0?{description:u}:{}}}function jf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=nn(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function ei(t,e,r,n){let o={name:t},s=ti(r);s!==void 0&&(o.doc=s);let i=$f(e);i!==void 0&&(o.flags=i);let a=Wf(e,n);return a!==void 0&&(o.signature=a),o}function ti(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function $f(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Wf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function zf(t,e){Bf(t,e),Hf(t,e),Jf(t,e),Kf(t,e),Xf(t,e),Ys(t,e)}function Bf(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||an(n)).length}function Hf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!Uf(t)&&(e.hasTypesOnly=!1)}function Uf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Jf(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:R(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function Kf(t,e){h.isExportDeclaration(t)?Vf(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):an(t)&&Yf(t,e)}function Vf(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))qf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function qf(t,e,r){let n=Qf(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:R(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function Qf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Yf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,ei(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,ei(o,n,t,e.sourceFile))}}}function Xf(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:R(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:R(r.text),type:"require"}))}function Zf(t,e){let r=Zs.basename(t).toLowerCase(),n=Zs.extname(t).toLowerCase();return _e().some(s=>r.includes(s))?"test":Mo(r)?"config":e.imports.some(s=>xr().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Cr()?"barrel":"logic"}function an(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function em(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=rm(o);if(s){let i=nm(o);i&&Et(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&tm(o,o.name.text,n,r)}}function tm(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?Et(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&Et(o.body,`${e}.constructor`,r,n)}function rm(t){if(an(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function nm(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function Et(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>Et(o,e,r,n))}var ri=g(()=>{"use strict";l();de();Qs();q();Xs()});function Tt(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var ni=g(()=>{"use strict";l()});import si from"postcss";import*as om from"postcss-less";function oi(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function im(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function am(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=ii.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...oi(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...oi(o)?{isExternal:!0}:{}}:null}function cm(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";im(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function ai(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=am(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...cm(n.value,e))}),r}function lm(t){return t.replace(/(?<!:)\/\/.*/g,"")}function pm(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=ii.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function Ft(t,e){let r=si.parse(lm(t));return{imports:ai(r,e),root:r}}function fm(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function Nt(t,e){try{let r=sm.parse(t),{exports:n,tags:o}=fm(r);return{imports:ai(r,e),root:r,exports:n,tags:o}}catch{return{imports:pm(t,e),root:si.parse(""),exports:[],tags:[]}}}var sm,ii,cn=g(()=>{"use strict";l();sm=om,ii=new Set(["reference","inline"])});import{parse as mm}from"postcss-scss";function ci(t){return t.startsWith("_")||t.startsWith("-")}function um(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function gm(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function dm(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||ci(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||ci(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Pt(t,e){let r=mm(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=gm(c);if(!p)return;let u={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...um(p)?{isExternal:!0}:{}};f&&(u.symbols=[f]),n.push(u)});let{exports:o,tags:s}=dm(r);return{imports:n,root:r,exports:o,tags:s}}var ln=g(()=>{"use strict";l()});function li(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function pi(t,e){if(e.length===0)return"ui";try{let r=gr("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var fi=g(()=>{"use strict";l()});function Ue(t,e){let r=z(t);if(r==="stylus"){let s=li(e,t);return{imports:s,exports:[],tags:[],category:pi(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Pt(e,t);return{imports:s,exports:a,tags:c,category:Tt(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=Nt(e,t);return{imports:s,exports:a,tags:c,category:Tt(i,s)}}let{imports:n,root:o}=Ft(e,t);return{imports:n,exports:[],tags:[],category:Tt(o,n)}}var mi=g(()=>{"use strict";l();q();ni();cn();ln();fi()});async function ui(t,e){let r=z(t),n=gs(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var gi=g(()=>{"use strict";l();q();ms();ds();ks();ws();Ds();Rs();Ms();Os();$s();Us();Ks();ri();Be();mi();de();q();Be();for(let[t,e]of[["javascript",(r,n)=>sn(r,n,"javascript")],["typescript",(r,n)=>sn(r,n,"typescript")],["css",Ue],["scss",Ue],["less",Ue],["stylus",Ue],["coffeescript",fs],["livescript",As],["lua",Ls],["python",Hs],["go",Cs],["java",Ps],["kotlin",Is],["scala",Js],["groovy",vs],["gherkin",qr],["markdown",js]])Ce(t,e)});import di from"path";function hm(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function yi(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function ym(t,e,r){if(e.isExternal||!e.toPath)return;let n=r.get(e.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(t.path)||n.testedBy.push(t.path)))}function xm(t,e){if(t.type==="markdown")for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let n=e.get(r.toPath);!n||n===t||(n.documentedBy??=[],n.documentedBy.includes(t.path)||n.documentedBy.push(t.path),n.category==="logic"&&(n.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(n.path)||t.staleFor.push(n.path)))}}function hi(t){return Math.round(t*1e4)/1e4}function bm(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let o=e.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=hi(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=hi(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function pn(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Sm(t,e){let r=e.toPath,n=di.basename(r,di.extname(r)).replace(/\.(test|spec)$/,"");pn(t.tags,n,"import")}function Cm(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)pn(t.tags,r,"import")}function km(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&pn(t.tags,o.name,"comment-marker")}function vm(t,e,r){!e.toPath||e.isExternal||(Sm(t,e),Cm(t,e),km(t,e,r))}function xi(t,e){for(let r of t.values())delete r.testedBy,delete r.documentedBy,delete r.staleFor,r.category==="test"&&(r.tags=r.tags.filter(n=>n.kind!=="import"));for(let r of t.values()){if(bm(r,t),e.size>0&&hm(r,e),r.category==="test")for(let n of r.imports)ym(r,n,t),vm(r,n,t);xm(r,t)}}var bi=g(()=>{"use strict";l()});function fn(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:Ci.has(r),importSymbolsTracked:ki.has(r),callEdgesTracked:Dt.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var Si,Ci,ki,Dt,It=g(()=>{"use strict";l();Si=new Set(["java","kotlin","scala","groovy"]),Ci=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),ki=new Set(["typescript","javascript","python"]),Dt=new Set(["typescript","javascript","go","python","java"])});import Ei from"fs";import Ne from"path";function wm(t,e){let r=t.split(`
|
|
12
|
+
`),n=null,o=new Map,s=!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)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){vi(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&vi(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function vi(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=Ne.isAbsolute(o)?o:Ne.resolve(e,o);r.set(s,i)}function wi(t){let e;try{e=Ei.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:Ne.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var Je,Ti=g(()=>{"use strict";l();Je=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return wi(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?wi(Ne.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 o=Ei.readFileSync(Ne.join(e,"go.mod"),"utf-8"),s=wm(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return Ne.join(s,i)}}}}});import Rt from"fs";import At from"path";function Fm(t){let e=new Map,r=new Set(I),n=(o,s)=>{if(s>Tm)return;let i;try{i=Rt.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){let c=At.join(o,a.name);if(a.isDirectory()){!a.name.startsWith(".")&&!r.has(a.name)&&n(c,s+1);continue}if(!a.isFile())continue;let p=At.extname(a.name);if(!Em.has(p))continue;let f=Nm(c,p===".scala"||p===".sc");if(!f)continue;let u=e.get(f);u?u.push(c):e.set(f,[c])}};n(t,0);for(let o of e.values())o.sort();return e}function Nm(t,e){let r;try{let n=Rt.openSync(t,"r");try{let o=Buffer.alloc(Fi),s=Rt.readSync(n,o,0,Fi,0);r=o.toString("utf8",0,s)}finally{Rt.closeSync(n)}}catch{return null}return j(r,e)}function mn(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function Pm(t){return At.basename(t,At.extname(t))}var Em,Tm,Fi,Ke,Ni=g(()=>{"use strict";l();G();Te();Em=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Tm=12,Fi=4096,Ke=class{extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,r,n,o){let s=this.getIndex(n);if(s.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 mn(s.get(a.join(".")));for(let c=a.length-1;c>=1;c--){let p=s.get(a.slice(0,c).join("."));if(!p)continue;let f=a[c],u=p.filter(y=>Pm(y)===f);if(u.length>0)return mn(u);if(c===a.length-1)return mn(p)}return null}getIndex(e){let r=this.indexCache.get(e);if(r)return r;let n=Fm(e);return this.indexCache.set(e,n),n}}});import Dm from"fs";import un from"path";var Ve,Pi=g(()=>{"use strict";l();Ve=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,un.sep),i=[n,un.join(n,"lib")];for(let a of i){if(!Dm.existsSync(a))continue;let c=o(un.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Im from"path";var Rm,qe,Di=g(()=>{"use strict";l();G();Rm=new Set(I),qe=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=r.replace(/^\.\//,"").split("/")[0];if(s&&Rm.has(s))return null;let i=o(Im.join(n,"_dummy"),`./${r}`);return i?[i]:null}}});import Am from"fs";import gn from"path";function Ii(t){try{return Am.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Qe,Ri=g(()=>{"use strict";l();Qe=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,gn.sep),i=gn.join(n,`${s}.py`);if(Ii(i))return[{path:i,isExternal:!1}];let a=gn.join(n,s,"__init__.py");return Ii(a)?[{path:a,isExternal:!1}]:null}}});import Ai from"path";var Mm,Ye,Mi=g(()=>{"use strict";l();Mm=["~","http://","https://","//","data:","sass:"],Ye=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(Mm.some(f=>r.startsWith(f)))return null;let s=o(e,r);if(s)return[s];let i=Ai.dirname(r),a=Ai.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var Li=g(()=>{"use strict";l();Ti();Ni();Pi();Di();Ri();Mi()});import Mt from"fs";import U from"path";var J,Lt=g(()=>{"use strict";l();Li();J=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 Qe,new Ve,new Je,new Ke,new Ye,new qe]}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`${U.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),o=this.resolutionCache.get(n);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,s.length>0?s:null),s}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 o=(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,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=U.dirname(e),o=r.startsWith("/")?r:U.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let f=this.tryExtensions(c,p,s);if(f)return f}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=U.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=U.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return Mt.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),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=U.join(r,"tsconfig.json");if(Mt.existsSync(n))try{let s=JSON.parse(Mt.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=U.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}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 o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=U.join(n,a);try{if(Mt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(U.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import Xe from"fs";import P from"path";import Lm from"piscina";function jm(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function $m(t,e){if(t.length===0)return e;let r=t.map(i=>P.dirname(i).split(P.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 o=n.join(P.sep)||P.sep,s=P.relative(e,o);return s.startsWith("..")||P.isAbsolute(s)?e:o}var Om,_m,Gm,ae,dn=g(()=>{"use strict";l();Or();de();Kr();gi();bi();It();xe();Lt();Om=["tests","test","__tests__","specs","spec"],_m=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],Gm=600;ae=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0,c=[]){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.walkIgnoreDirs=new Set([..._m,...c,...jm()]),this.resolver=n||new J(e),this.lockFile=as(e),o&&(this.progressCallback=o)}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=>P.isAbsolute(n)?n:P.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=es(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles($m(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
13
|
+
Done. Total processed: ${this.visited.size} nodes.
|
|
14
|
+
`),xi(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??Gm;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
|
|
15
|
+
Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
|
|
16
|
+
`);try{let n=P.join(m,"parse-worker.js");this.pool=new Lm({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
|
|
17
|
+
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
|
|
18
|
+
`),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=Xe.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||o.push(P.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=_e(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=P.dirname(o);if(s===o)break;for(let i of Om){let a=P.join(s,i);try{Xe.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}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.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=P.join(e,o.name);o.isDirectory()?this.walkIgnoreDirs.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=Xe.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=P.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),yi(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=Xe.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
|
|
19
|
+
Warning: failed to parse ${r}: ${o}
|
|
20
|
+
`),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ui(e,r)}makeStubNode(e,r,n){return{path:r,type:z(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:P.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:u,cognitiveComplexity:y,functions:x}=o;return{path:r,type:z(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...u!==void 0?{complexity:u}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:P.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),n.push(c)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=this.lockFile.jvmDependencies;if(r&&Si.has(z(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(r))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=r[i]?.version);return}let n=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=n?this.lockFile.dependencies[n]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function Oi(t){return Wm.has(t)?"style":"code"}var Wm,_i=g(()=>{"use strict";l();Wm=new Set(["css","scss","less","stylus"])});function zm(t){return t.trim().replace(/\s+/g," ")}function Bm(t){try{return t.fileType==="scss"?Pt(t.source,t.file).root:t.fileType==="less"?Nt(t.source,t.file).root:t.fileType==="css"?Ft(t.source,t.file).root:void 0}catch{return}}function Hm(t){let e=Bm(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${zm(f.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function Gi(t,e,r=2){let n=new Map;for(let s of t)for(let i of Hm(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let f={file:c.file,startLine:c.startLine,endLine:c.endLine},u={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,u],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var ji=g(()=>{"use strict";l();cn();ln()});function $i(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>n[n.length-1].lcpLength&&n.push({lcpLength:t[o],low:s})}for(;n.length>1;){let o=n.pop();r.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return r}var Wi=g(()=>{"use strict";l()});function zi(t,e,r){let n=0;for(let o=e;o<e+r;o++)Um.has(t[o].text)&&n++;return n/r}var Um,Bi=g(()=>{"use strict";l();Um=new Set(["{","}",":",",","[","]"])});function Hi(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(s,i)=>i),n=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?n[a+s]:-1;r.sort((a,c)=>{let p=n[a]-n[c];return p!==0?p:i(a)-i(c)}),o[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],p=r[a],f=n[c]===n[p],u=i(c)===i(p);o[p]=o[c]+(f&&u?0:1)}if([n,o]=[o,n],n[r[e-1]]===e-1)break}return r}function Ui(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let o=new Array(r);for(let i=0;i<r;i++)o[e[i]]=i;let s=0;for(let i=0;i<r;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<r&&c+s<r&&t[i+s]===t[c+s];)s++;n[a]=s,s>0&&s--}else s=0}return n}var Ji=g(()=>{"use strict";l()});function Ki(t,e,r,n=.5){let o=[],s=[],i=new Map;for(let{file:u,tokens:y}of t)if(y.length!==0){i.set(u,y);for(let x=0;x<y.length;x++)o.push(y[x].text),s.push({file:u,localIndex:x});o.push(` ${u}`),s.push({file:u,localIndex:-1})}if(o.length===0)return[];let a=Hi(o),c=Ui(o,a),p=$i(c),f=[];for(let u of p){let y=Jm(u,a,s,i,e,r,n);y&&f.push(y)}return f.sort((u,y)=>y.lines-u.lines)}function Jm(t,e,r,n,o,s,i){if(t.lcpLength<o)return;let a=[];for(let x=t.low;x<=t.high;x++){let b=r[e[x]];b.localIndex!==-1&&a.push(b)}if(a.length<2||!Km(a,n))return;let c=Vm(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=n.get(p.file);if(zi(f,p.localIndex,t.lcpLength)>i)return;let u=c.map(({file:x,localIndex:b})=>{let w=n.get(x);return{file:x,startLine:w[b].line,endLine:w[b+t.lcpLength-1].line}}),y=Math.min(...u.map(x=>x.endLine-x.startLine+1));if(!(y<s))return{occurrences:u,lines:y,tokens:t.lcpLength}}function Km(t,e){let r=null;for(let{file:n,localIndex:o}of t){if(o===0)return!0;let i=e.get(n)[o-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function Vm(t,e){let r=new Map;for(let{file:o,localIndex:s}of t){let i=r.get(o);i?i.push(s):r.set(o,[s])}let n=[];for(let[o,s]of r){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(n.push({file:o,localIndex:a}),i=a+e)}return n}var Vi=g(()=>{"use strict";l();Wi();Bi();Ji()});function qi(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function Qm(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=qi(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
|
|
21
|
+
`,s),a=i===-1?r.length:i;r=qi(r,s,a),o=a}}return r}function Yi(t,e,r=!0){let n=Qm(t,qm[e]),o=[],s=1,i=0;hn.lastIndex=0;let a=hn.exec(n);for(;a!==null;){for(let f=i;f<a.index;f++)n[f]===`
|
|
22
|
+
`&&s++;i=a.index;let c=a[0],p=c;Xm.test(c)&&!eu.has(c)?p="ID":r&&(Qi.test(c)||Zm.test(c))&&(p=Qi.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let f=i;f<a.index+c.length;f++)n[f]===`
|
|
23
|
+
`&&s++;i=a.index+c.length,a=hn.exec(n)}return o}var qm,Ym,hn,Xm,Qi,Zm,eu,Xi=g(()=>{"use strict";l();qm={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:[["<!--","-->"]]}};Ym=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],hn=new RegExp(`${Ym.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Xm=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Qi=/^\d+(?:\.\d+)?$/,Zm=/^(".*"|'.*'|`.*`)$/s,eu=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"])});import Ze from"fs";import tu from"path";function ru(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 Pe(t){try{if(!Ze.existsSync(t))return new Map;let e=Ze.readFileSync(t,"utf-8"),r=JSON.parse(e);if(!Array.isArray(r))return new Map;let n=r.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&ru(o[1]));return new Map(n)}catch{return new Map}}function De(t,e){let r=tu.dirname(e);Ze.existsSync(r)||Ze.mkdirSync(r,{recursive:!0}),Ze.writeFileSync(e,JSON.stringify([...t.entries()]))}var Zi=g(()=>{"use strict";l()});import{readFile as ea}from"fs/promises";import et from"path";import nu from"piscina";function iu(t){return We.includes(et.basename(t))}function au(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(et.sep).some(n=>r.has(n))}async function Ie(t,e,r={}){let{minLines:n=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=I,parallelTokenizing:p=!0,tokenCache:f}=r,u=[...t.nodes.values()].filter(x=>!iu(x.path)&&!au(x.path,c)),y=cu(p,u.length);try{let x=[],b=new Map;if(await Promise.all(u.map(async S=>{if(su.has(S.type)){let ge;try{ge=await ea(et.join(e,S.path),"utf8")}catch{return}x.push({file:S.path,source:ge,fileType:S.type});return}let v=f?.get(S.path),_=v&&v.mtime===S.mtime&&v.size===S.size&&v.ignoreLiterals===s,O;if(_)O=v.tokens;else{let ge;try{ge=await ea(et.join(e,S.path),"utf8")}catch{return}O=y?await y.run({source:ge,fileType:S.type,ignoreLiterals:s}):Yi(ge,S.type,s),f?.set(S.path,{mtime:S.mtime,size:S.size,ignoreLiterals:s,tokens:O})}let ee=Oi(S.type),Ro={file:S.path,tokens:O},Ao=b.get(ee);Ao?Ao.push(Ro):b.set(ee,[Ro])})),f){let S=new Set(u.map(v=>v.path));for(let v of f.keys())S.has(v)||f.delete(v)}let w=Gi(x,n);for(let[S,v]of b)for(let _ of Ki(v,o,n,i))w.push({..._,family:S});return{groups:w.sort((S,v)=>v.lines-S.lines).slice(0,a)}}finally{y&&await y.destroy()}}function cu(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??ou;if(e<n)return null;r.maxThreads!==void 0&&r.maxThreads<1&&process.stderr.write(`
|
|
8
24
|
Warning: parallelTokenizing.maxThreads (${r.maxThreads}) must be at least 1; using 1.
|
|
9
|
-
`);try{return new
|
|
25
|
+
`);try{return new nu({filename:et.join(m,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:Math.max(1,r.maxThreads)}:{}})}catch(o){return process.stderr.write(`
|
|
10
26
|
Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
|
|
11
|
-
`),null}}var zc,$c,tr=m(()=>{"use strict";l();be();Yt();Kn();eo();lo();mo();go();zc=20,$c=new Set(["css","scss","less"])});import tt from"path";function Jc(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function Kc(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=tt.extname(o),c=tt.basename(o,a),p=c==="index"?tt.basename(tt.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function V(t,e){let r=e?.minOutDegree??5;return Kc(t,Jc(t),r)}var rt=m(()=>{"use strict";l()});function Qc(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function Yc(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Xc(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function qc(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function ke(t,e){let r=e?.detectFn??V,n=e?.hubComparator??Vc,o=r(t.nodes,e),s=Qc(t,o),i=Yc(t.nodes,o,s,n);return{features:Xc(o,i),unassigned:qc(t.nodes,o,i)}}var Vc,nt=m(()=>{"use strict";l();rt();Vc=(t,e)=>t.outDegree-e.outDegree});function rr(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:yo.has(r),importSymbolsTracked:xo.has(r),callEdgesTracked:ot.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var yo,xo,ot,nr=m(()=>{"use strict";l();yo=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),xo=new Set(["typescript","javascript","python"]),ot=new Set(["typescript","javascript","go","python"])});var ve,bo=m(()=>{"use strict";l();ve=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 o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.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 p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var D,we=m(()=>{"use strict";l();bo();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 o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,u)=>{if(p>i||s.has(c))return;let g=this.nodes.get(c);if(g&&(s.add(c),r(g,p,u)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.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 ve(this.nodes).findUnusedFiles(e)}findCycles(){return new ve(this.nodes).findCycles()}}});var Q,st=m(()=>{"use strict";l();Q=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function Y(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function or(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function Te(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function sr(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new Q(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let u=a.category==="test"||a.tags.some(g=>g.name==="test");return(!n||u)&&i.push(a.path),!0},{direction:"incoming"}),i}function ir(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function ar(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function cr(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 lr(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function Ee(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function So(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function pr(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=So(t),c=[...t.nodes.values()].filter(p=>p.coveragePct!==void 0&&p.coveragePct<=o&&(!a||(p.commitCount90d??0)>=s)).flatMap(p=>(p.functions??[]).filter(u=>u[r]>=n).map(u=>({file:p.path,name:u.name,line:u.line,complexity:u.complexity,cognitiveComplexity:u.cognitiveComplexity,coveragePct:p.coveragePct,...p.commitCount90d!==void 0&&{commitCount90d:p.commitCount90d}}))).sort((p,u)=>u[r]-p[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var fr=m(()=>{"use strict";l();st()});function Co(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return C(e,"component")||C(e,"components")?"component":C(e,"controller")||C(e,"controllers")?"controller":C(e,"middleware")?"middleware":C(e,"router")||C(e,"routes")||C(e,"route")?"router":C(e,"store")||C(e,"stores")?"store":C(e,"service")||C(e,"services")?"service":C(e,"handler")||C(e,"handlers")?"handler":C(e,"adapter")||C(e,"adapters")?"adapter":C(e,"plugin")||C(e,"plugins")?"plugin":C(e,"api")?"api":C(e,"cli")||C(e,"commands")||Fe(e)==="cli"?"cli":C(e,"util")||C(e,"utils")||C(e,"helper")||C(e,"helpers")?"util":C(e,"model")||C(e,"models")||Fe(e)==="model"?"model":C(e,"parser")||C(e,"parsers")||Fe(e)==="parser"?"parser":Fe(e)==="builder"?"builder":Fe(e)==="resolver"?"resolver":"other"}function C(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Fe(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var ko=m(()=>{"use strict";l()});function ur(t,e){let r=ke(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:Co(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var mr=m(()=>{"use strict";l();nt();ko()});function dr(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(ot.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=Te(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var vo=m(()=>{"use strict";l();nr();fr()});function Zc(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function el(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function gr(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!el(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:Zc(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function hr(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var yr=m(()=>{"use strict";l()});import wo from"fs";import zd from"path";function To(t){try{return wo.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function it(t){try{return wo.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var at=m(()=>{"use strict";l()});import Ne from"fs";import M from"path";function xr(t,e){let r=M.join(e,"package.json");if(!Ne.existsSync(r))return null;let n={};try{n=JSON.parse(Ne.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:M.relative(t,e),entryPoints:tl(e,n)}:null}function tl(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(M.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(M.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(M.join(t,i))}}}e.main&&r.push(M.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(M.join(t,o));let n=r.filter(it);return n.length>0?n.slice(0,1):r.slice(0,1)}function le(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");rl(t,s,n,r)}return r}function rl(t,e,r,n){if(!e.includes("*")){nl(t,e,r,n);return}let o=e.split("/");o.includes("**")?ol(t,o,r,n):sl(t,o,r,n)}function nl(t,e,r,n){let o=M.join(t,e);if(r.has(o)||!To(o))return;r.add(o);let s=xr(t,o);s&&n.push(s)}function ol(t,e,r,n){let o=M.join(t,e[0]==="**"?"":e[0]??"");Eo(t,o,r,n)}function sl(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=M.join(t,...e.slice(0,o)),i;try{i=Ne.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=M.join(s,a.name);if(r.has(c))continue;r.add(c);let p=xr(t,c);p&&n.push(p)}}function Eo(t,e,r,n){let o;try{o=Ne.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=M.join(e,s.name);if(Ne.existsSync(M.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=xr(t,i);a&&n.push(a)}else Eo(t,i,r,n)}}var ct=m(()=>{"use strict";l();at();at()});import br from"fs";import Fo from"path";var No,Po=m(()=>{"use strict";l();ct();No={type:"npm",detect(t){let e=Fo.join(t,"package.json");if(!br.existsSync(e))return null;let r;try{r=JSON.parse(br.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||br.existsSync(Fo.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:le(t,n)}}});import pe from"fs";import P from"path";function Do(t,e,r,n){if(n>4)return[];let o;try{o=pe.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=P.join(e,a);pe.existsSync(P.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...Do(t,c,r,n+1))}return s}function il(t,e,r){let n={};try{n=JSON.parse(pe.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=P.join(e,"package.json");if(pe.existsSync(a))try{let c=JSON.parse(pe.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:P.relative(t,e),entryPoints:al(e,n,s,i)}:null}function al(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=P.resolve(t,"../..");o.push(P.resolve(a,s)),o.push(P.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(P.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(P.join(t,c))}}if(r&&o.push(P.join(t,r)),e.sourceRoot){let a=P.resolve(t,"../.."),c=P.resolve(a,e.sourceRoot);o.push(P.join(c,"index.ts"),P.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(P.join(t,a));let i=o.filter(it);return i.length>0?i.slice(0,1):o.slice(0,1)}var Io,Mo=m(()=>{"use strict";l();at();Io={type:"nx",detect(t){return pe.existsSync(P.join(t,"nx.json"))?Do(t,t,new Set,0).map(r=>il(t,r,P.join(r,"project.json"))).filter(r=>r!==null):null}}});import Ao from"fs";import cl from"path";import{load as ll}from"js-yaml";var Ro,Lo=m(()=>{"use strict";l();ct();Ro={type:"pnpm",detect(t){let e=cl.join(t,"pnpm-workspace.yaml");if(!Ao.existsSync(e))return null;let r=[];try{r=ll(Ao.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return le(t,r)}}});import pl from"fs";import fl from"path";var Oo,Go=m(()=>{"use strict";l();Oo={type:"turborepo",detect(t){return pl.existsSync(fl.join(t,"turbo.json"))?[]:null}}});import Sr from"fs";import _o from"path";var jo,Wo=m(()=>{"use strict";l();ct();jo={type:"yarn",detect(t){if(!Sr.existsSync(_o.join(t,"yarn.lock")))return null;let e=_o.join(t,"package.json");if(!Sr.existsSync(e))return null;let r;try{r=JSON.parse(Sr.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:le(t,n)}}});function z(t){zo.push(t)}function $o(){return zo}var zo,lt=m(()=>{"use strict";l();zo=[]});import ul from"path";function Cr(t,e=$o()){let r=ul.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var kr=m(()=>{"use strict";l();Po();Mo();Lo();Go();Wo();lt();lt();z(Oo);z(Io);z(Ro);z(jo);z(No)});var Pe,vr=m(()=>{"use strict";l();we();Pe=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})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function fe(t,e){Bo.set(t,e)}function Uo(t){return Bo.get(t)}var Bo,Ie=m(()=>{"use strict";l();Bo=new Map});function Ho(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function ml(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function De(t,e,r){return zl.every(n=>n(t,e,r))}var dl,gl,hl,yl,xl,bl,Sl,Cl,kl,vl,wl,Tl,El,Fl,Nl,Pl,Il,Dl,Ml,Al,Rl,Ll,Ol,Gl,_l,jl,Wl,zl,wr=m(()=>{"use strict";l();dl=(t,e)=>!e.category||Ho(t.category,e.category),gl=(t,e)=>!e.type||Ho(t.type,e.type),hl=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,yl=(t,e)=>!e.path||ml(t.path,e.path),xl=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,bl=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},Sl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),Cl=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),kl=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),vl=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,wl=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Tl=(t,e)=>e.minSize===void 0||t.size>=e.minSize,El=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Fl=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Nl=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Pl=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Il=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Dl=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Ml=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Al=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Rl=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Ll=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Ol=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Gl=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,_l=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,jl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Wl=(t,e,r)=>!e.any?.length||e.any.some(n=>De(t,n,r)),zl=[dl,gl,hl,yl,xl,bl,Sl,Cl,kl,vl,wl,Tl,El,Fl,Nl,Pl,Il,Dl,Ml,Al,Rl,Ll,Ol,Gl,_l,jl,Wl]});function pt(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=>De(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var Jo=m(()=>{"use strict";l();wr();wr()});function Ko(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!(!n||!o))switch(n){case"category":t.category=o;break;case"type":t.type=o;break;case"tag":case"tags":o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];break;case"path":t.path=o;break;case"external":t.isExternal=o.toLowerCase()==="true";break;case"importsfile":t.importsFile=o;break;case"importedby":t.importedBy=o;break;case"minimports":t.minImports=parseInt(o,10);break;case"maximports":t.maxImports=parseInt(o,10);break;case"minsize":t.minSize=parseInt(o,10);break;case"maxsize":t.maxSize=parseInt(o,10);break;case"sort":t.sort=o;break;case"sortdir":t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(o,10);break;case"hasdocstring":t.hasDocstring=o.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(o,10);break;case"maxcoverage":t.maxCoverage=parseInt(o,10);break;case"minexportusage":t.minExportUsage=parseFloat(o);break;case"maxexportusage":t.maxExportUsage=parseFloat(o);break;case"mincomplexity":t.minComplexity=parseInt(o,10);break;case"maxcomplexity":t.maxComplexity=parseInt(o,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(o,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(o,10);break;case"mincommits":t.minCommits=parseInt(o,10);break;case"maxcommits":t.maxCommits=parseInt(o,10);break;case"isdocumented":t.isDocumented=o.toLowerCase()!=="false";break;case"isstale":t.isStale=o.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=o;break}}function $l(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};Ko(o,n),Object.keys(o).length>0&&e.push(o)}return e}function ft(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith("any(")&&o.endsWith(")")){let s=o.slice(4,-1),i=$l(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}Ko(e,n)}return e}var Vo=m(()=>{"use strict";l()});var Qo=m(()=>{"use strict";l();Jo();Vo()});import Bl from"path";import F from"typescript";function X(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function Tr(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&Yo.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&Yo.has(o.expression.text)&&e.push(n)}return e}function Er(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function Fr(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=X(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=X(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Nr(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=X(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:X(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=X(s.properties,i);return i===s.properties.length-1?{start:X(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:X(s.properties,i+1).getStart(r),text:""}}return null}function Pr(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Ir(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Ul(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function ut(t,e,r,n){let o=F.createSourceFile(Bl.basename(t),e,F.ScriptTarget.Latest,!0),s=Tr(o),[i]=s;if(!i)return e;let a=Er(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Ul(a).sort())===JSON.stringify(c))return e;let p=Ir(c.map(g=>`@${g}`)),u=s.flatMap(g=>{let y=r.length===0?Nr(g,n,o):Fr(g,n,p,o);return y?[y]:[]});return u.length>0?Pr(e,u):e}var Yo,_,ue=m(()=>{"use strict";l();Yo=new Set(["describe","test","it"]);_=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Hl from"path";var mt,Xo=m(()=>{"use strict";l();ue();mt=class{name="cypress";canHandle(e){return _.has(Hl.extname(e).toLowerCase())}apply(e,r,n){return ut(e,r,n,"tags")}}});import Jl from"path";function Kl(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
27
|
+
`),null}}var ou,su,Ot=g(()=>{"use strict";l();G();Kr();_i();ji();Vi();Xi();Zi();ou=20,su=new Set(["css","scss","less"])});var ce,_t=g(()=>{"use strict";l();ce=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function le(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function yn(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function tt(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function xn(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new ce(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let f=a.category==="test"||a.tags.some(u=>u.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function bn(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function Re(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function Sn(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function Cn(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function Z(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function ta(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ae(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ta(t),c=[...t.nodes.values()].filter(p=>p.coveragePct!==void 0&&p.coveragePct<=o&&(!a||(p.commitCount90d??0)>=s)).flatMap(p=>(p.functions??[]).filter(f=>f[r]>=n).map(f=>({file:p.path,name:f.name,line:f.line,complexity:f.complexity,cognitiveComplexity:f.cognitiveComplexity,coveragePct:p.coveragePct,...p.commitCount90d!==void 0&&{commitCount90d:p.commitCount90d}}))).sort((p,f)=>f[r]-p[r]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Gt=g(()=>{"use strict";l();_t()});import{execFileSync as vn}from"child_process";import kn from"fs";import lu from"os";import pu from"path";function wn(t,e){try{return vn("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{throw new Error(`Could not resolve git ref "${e}" in ${t}`)}}async function ra(t,e,r){let n=kn.mkdtempSync(pu.join(lu.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));kn.rmdirSync(n);try{return vn("git",["worktree","add","--detach",n,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await r(n)}finally{try{vn("git",["worktree","remove","--force",n],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{kn.rmSync(n,{recursive:!0,force:!0})}}}var na=g(()=>{"use strict";l()});import fu from"path";async function la(t,e,r,n={}){let o=wn(t,e),s=Vo(t,o);if(s)return{sha:o,graph:s};let i=await ra(t,o,async a=>{let c=n.pathAliases?new J(a,{pathAliases:n.pathAliases}):void 0;return new ae(a,null,c,void 0,n.gitStats??!1,new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(r)});return qo(t,o,i),{sha:o,graph:i}}function mu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function uu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function gu(t,e=4){let r=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),n=t.occurrences.length-r.length,o=n>0?`, +${n} more`:"";return`${t.lines}L x${t.occurrences.length}: ${r.join(", ")}${o}`}function du(t,e){let{files:r,staleReferences:n,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],p=[r.added.length&&`${r.added.length} added`,r.changed.length&&`${r.changed.length} changed`,r.removed.length&&`${r.removed.length} removed`].filter(Boolean);c.push(p.length?`Files: ${p.join(", ")}`:"No file changes"),n.length>0&&c.push(`\u26A0 ${pe(n.length,"stale reference")} \u2014 removed export still imported`);let f=s.newHotspots[0];return f?c.push(`+${pe(s.newHotspots.length,"complexity hotspot")} (max ${e} ${f[e]} in ${f.file})`):s.resolvedHotspots.length>0&&c.push(`${pe(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${pe(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${pe(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${pe(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${pe(a.newHotspots.length,"risk hotspot")}`),c}function hu(t){let{staleReferences:e,duplication:r,complexity:n,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":n.newHotspots.length>0||r.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function En(t,e={}){let r=e.metric??"cognitiveComplexity",n=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:p,coverage:f}=t,u=oa(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),y=s.added.length+s.changed.length+s.removed.length,x={base:`${t.base.ref}@${sa(t.base.sha)}`,head:`${t.head.ref}@${sa(t.head.sha)}`,verdict:hu(t),headline:du(t,r),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...y<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(x.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(x.complexity={avgDelta:u,newHotspots:c.newHotspots.slice(0,n).map(b=>mu(b,r)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(x.duplication={newGroups:a.newGroups.slice(0,n).map(b=>gu(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(p.newlyStale.length>0||p.resolved.length>0)&&(x.docDrift={newlyStale:p.newlyStale.slice(0,n).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:p.newlyStale.length,resolvedCount:p.resolved.length}),f&&(f.newHotspots.length>0||f.resolvedHotspots.length>0)&&(x.coverage={avgDelta:oa(f.head.avgCoveragePct-f.base.avgCoveragePct),newHotspots:f.newHotspots.slice(0,n).map(b=>uu(b,r)),newHotspotCount:f.newHotspots.length,resolvedCount:f.resolvedHotspots.length}),x}function yu(t,e){let r=[],n=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){r.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(f=>f.name).sort(),imports:a.imports.map(f=>f.toPath).sort()}),p=JSON.stringify({category:i.category,exports:i.exports.map(f=>f.name).sort(),imports:i.imports.map(f=>f.toPath).sort()});c!==p&&n.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:r,removed:o,changed:n}}function xu(t,e){let r=[];for(let[n,o]of t.nodes){let s=e.nodes.get(n);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let p=[...e.nodes.values()].filter(f=>f.imports.some(u=>u.toPath===n&&u.symbols?.includes(c))).map(f=>f.path);p.length>0&&r.push({file:n,symbol:c,stillReferencedBy:p})}}return r}function jt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function bu(t,e,r,n,o){let s=fu.join(ht(t),`${n}-${te}`),i=Pe(s),[{groups:a},{groups:c}]=await Promise.all([Ie(e,t,{minLines:o,tokenCache:i}),Ie(r,t,{minLines:o})]);De(i,s);let p=new Set(a.map(jt)),f=new Set(c.map(jt));return{base:{groups:a.length},head:{groups:c.length},newGroups:c.filter(u=>!p.has(jt(u))),resolvedGroups:a.filter(u=>!f.has(jt(u)))}}function ia(t){let e=[...t.nodes.values()].map(r=>r.cognitiveComplexity).filter(r=>r!==void 0);return e.length===0?0:e.reduce((r,n)=>r+n,0)/e.length}function Su(t,e,r,n){let o=Re(t,{metric:r,threshold:n,limit:1/0}),s=Re(e,{metric:r,threshold:n,limit:1/0}),i=p=>`${p.file}:${p.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:ia(t)},head:{avgCognitiveComplexity:ia(e)},newHotspots:s.filter(p=>!a.has(i(p))),resolvedHotspots:o.filter(p=>!c.has(i(p)))}}function aa(t){let e=new Set;for(let r of t.nodes.values())if(!(r.type!=="markdown"||!r.staleFor))for(let n of r.staleFor)e.add(`${r.path}::${n}`);return e}function Cu(t,e){let r=aa(t),n=aa(e);return{base:{staleCount:r.size},head:{staleCount:n.size},newlyStale:[...n].filter(o=>!r.has(o)),resolved:[...r].filter(o=>!n.has(o))}}function ca(t){let e=[...t.nodes.values()].map(r=>r.coveragePct).filter(r=>r!==void 0);return e.length===0?0:e.reduce((r,n)=>r+n,0)/e.length}function ku(t,e,r){if(!Z(t)||!Z(e))return null;let n=Ae(t,{maxCoveragePct:r,limit:1/0}).hotspots,o=Ae(e,{maxCoveragePct:r,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(n.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:ca(t)},head:{avgCoveragePct:ca(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:n.filter(c=>!a.has(s(c)))}}async function Tn(t,e,r,n={}){let{sha:o,graph:s}=await la(t,e,n.entryPoints??[],n),i=wn(t,n.headRef??"HEAD"),[a,c]=await Promise.all([bu(t,s,r,o,n.minDuplicateLines),Promise.resolve(ku(s,r,n.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:n.headRef??"HEAD",sha:i},files:yu(s,r),staleReferences:xu(s,r),duplication:a,complexity:Su(s,r,n.complexityMetric,n.complexityThreshold),docDrift:Cu(s,r),coverage:c}}var oa,sa,pe,pa=g(()=>{"use strict";l();G();Qo();dn();Ot();Gt();Lt();na();oa=t=>Math.round(t*100)/100,sa=t=>t.length>8?t.slice(0,8):t;pe=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import $t from"path";function vu(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function wu(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=$t.extname(o),c=$t.basename(o,a),p=c==="index"?$t.basename($t.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function fe(t,e){let r=e?.minOutDegree??5;return wu(t,vu(t),r)}var Wt=g(()=>{"use strict";l()});function Tu(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function Fu(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Nu(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function Pu(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function rt(t,e){let r=e?.detectFn??fe,n=e?.hubComparator??Eu,o=r(t.nodes,e),s=Tu(t,o),i=Fu(t.nodes,o,s,n);return{features:Nu(o,i),unassigned:Pu(t.nodes,o,i)}}var Eu,zt=g(()=>{"use strict";l();Wt();Eu=(t,e)=>t.outDegree-e.outDegree});function fa(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,r=Ru(e);for(let n of Du)if(n.segments?.some(o=>Iu(e,o))||n.basenames?.includes(r))return n.role;return"other"}function Iu(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function Ru(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var Du,ma=g(()=>{"use strict";l();Du=[{role:"component",segments:["component","components"]},{role:"controller",segments:["controller","controllers"]},{role:"middleware",segments:["middleware"]},{role:"router",segments:["router","routes","route"]},{role:"store",segments:["store","stores"]},{role:"service",segments:["service","services"]},{role:"handler",segments:["handler","handlers"]},{role:"adapter",segments:["adapter","adapters"]},{role:"plugin",segments:["plugin","plugins"]},{role:"api",segments:["api"]},{role:"cli",segments:["cli","commands"],basenames:["cli"]},{role:"util",segments:["util","utils","helper","helpers"]},{role:"model",segments:["model","models"],basenames:["model"]},{role:"parser",segments:["parser","parsers"],basenames:["parser"]},{role:"builder",basenames:["builder"]},{role:"resolver",basenames:["resolver"]}]});function Fn(t,e){let r=rt(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:fa(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Nn=g(()=>{"use strict";l();zt();ma()});function Pn(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(Dt.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=tt(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var ua=g(()=>{"use strict";l();It();Gt()});function Au(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Mu(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Dn(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!Mu(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:Au(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function In(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var Rn=g(()=>{"use strict";l()});import ga from"fs";import qC from"path";function Bt(t){try{return ga.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ht(t){try{return ga.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var nt=g(()=>{"use strict";l()});import Lu from"fs";import An from"path";function da(t,e=[]){let r;try{r=Lu.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let n of r){let o=An.join(t,n.name);n.isDirectory()?!_u.has(n.name)&&!n.name.startsWith(".")&&da(o,e):n.isFile()&&Ou.has(An.extname(n.name).toLowerCase())&&e.push(o)}return e}function Ut(t,e,r){if(!Bt(e))return null;let n=da(e);return n.length===0?null:{name:r,root:e,relativeRoot:An.relative(t,e),entryPoints:n}}var Ou,_u,Mn=g(()=>{"use strict";l();G();nt();Ou=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),_u=new Set(I)});import ha from"fs";import ya from"path";function Gu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function ju(t){let e=Gu(t),r=new Set;for(let n of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=n[1].replace(/^:/,"").replace(/:$/,"");o&&r.add(o)}return[...r]}var xa,ba=g(()=>{"use strict";l();Mn();xa={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>ya.join(t,s)).find(s=>ha.existsSync(s));if(!e)return null;let r;try{r=ha.readFileSync(e,"utf-8")}catch{return null}let n=ju(r);if(n.length===0)return null;let o=[];for(let s of n){let i=ya.join(t,...s.split(":")),a=Ut(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import ot from"fs";import A from"path";function Ln(t,e){let r=A.join(e,"package.json");if(!ot.existsSync(r))return null;let n={};try{n=JSON.parse(ot.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:A.relative(t,e),entryPoints:$u(e,n)}:null}function $u(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(A.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(A.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(A.join(t,i))}}}e.main&&r.push(A.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(A.join(t,o));let n=r.filter(Ht);return n.length>0?n.slice(0,1):r.slice(0,1)}function Me(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");Wu(t,s,n,r)}return r}function Wu(t,e,r,n){if(!e.includes("*")){zu(t,e,r,n);return}let o=e.split("/");o.includes("**")?Bu(t,o,r,n):Hu(t,o,r,n)}function zu(t,e,r,n){let o=A.join(t,e);if(r.has(o)||!Bt(o))return;r.add(o);let s=Ln(t,o);s&&n.push(s)}function Bu(t,e,r,n){let o=A.join(t,e[0]==="**"?"":e[0]??"");Sa(t,o,r,n)}function Hu(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=A.join(t,...e.slice(0,o)),i;try{i=ot.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=A.join(s,a.name);if(r.has(c))continue;r.add(c);let p=Ln(t,c);p&&n.push(p)}}function Sa(t,e,r,n){let o;try{o=ot.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=A.join(e,s.name);if(ot.existsSync(A.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=Ln(t,i);a&&n.push(a)}else Sa(t,i,r,n)}}var Jt=g(()=>{"use strict";l();nt();nt()});import On from"fs";import Ca from"path";var ka,va=g(()=>{"use strict";l();Jt();ka={type:"npm",detect(t){let e=Ca.join(t,"package.json");if(!On.existsSync(e))return null;let r;try{r=JSON.parse(On.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||On.existsSync(Ca.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:Me(t,n)}}});import Le from"fs";import N from"path";function Ea(t,e,r,n){if(n>4)return[];let o;try{o=Le.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=N.join(e,a);Le.existsSync(N.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...Ea(t,c,r,n+1))}return s}function Uu(t,e,r){let n={};try{n=JSON.parse(Le.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=N.join(e,"package.json");if(Le.existsSync(a))try{let c=JSON.parse(Le.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:N.relative(t,e),entryPoints:Ju(e,n,s,i)}:null}function Ju(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=N.resolve(t,"../..");o.push(N.resolve(a,s)),o.push(N.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(N.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(N.join(t,c))}}if(r&&o.push(N.join(t,r)),e.sourceRoot){let a=N.resolve(t,"../.."),c=N.resolve(a,e.sourceRoot);o.push(N.join(c,"index.ts"),N.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(N.join(t,a));let i=o.filter(Ht);return i.length>0?i.slice(0,1):o.slice(0,1)}var wa,Ta=g(()=>{"use strict";l();nt();wa={type:"nx",detect(t){return Le.existsSync(N.join(t,"nx.json"))?Ea(t,t,new Set,0).map(r=>Uu(t,r,N.join(r,"project.json"))).filter(r=>r!==null):null}}});import Fa from"fs";import Ku from"path";import{load as Vu}from"js-yaml";var Na,Pa=g(()=>{"use strict";l();Jt();Na={type:"pnpm",detect(t){let e=Ku.join(t,"pnpm-workspace.yaml");if(!Fa.existsSync(e))return null;let r=[];try{r=Vu(Fa.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return Me(t,r)}}});import st from"fs";import Kt from"path";function qu(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function Qu(t){let e=qu(t),r=new Map;for(let n of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=n[1],i=n[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");r.has(c)||r.set(c,{name:o,dir:c})}return[...r.values()]}var Da,Ia=g(()=>{"use strict";l();Mn();Da={type:"sbt",detect(t){let e=Kt.join(t,"build.sbt"),r=Kt.join(t,"project");if(!st.existsSync(e)||!st.existsSync(r))return null;let n=[];try{n.push(st.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of st.readdirSync(r))a.endsWith(".scala")&&n.push(st.readFileSync(Kt.join(r,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of n)for(let c of Qu(a))o.has(c.dir)||(o.add(c.dir),s.push(c));if(s.length===0)return null;let i=[];for(let a of s){let c=Kt.join(t,...a.dir.split("/")),p=Ut(t,c,a.name);p&&i.push(p)}return i.length>0?i:null}}});import Yu from"fs";import Xu from"path";var Ra,Aa=g(()=>{"use strict";l();Ra={type:"turborepo",detect(t){return Yu.existsSync(Xu.join(t,"turbo.json"))?[]:null}}});import _n from"fs";import Ma from"path";var La,Oa=g(()=>{"use strict";l();Jt();La={type:"yarn",detect(t){if(!_n.existsSync(Ma.join(t,"yarn.lock")))return null;let e=Ma.join(t,"package.json");if(!_n.existsSync(e))return null;let r;try{r=JSON.parse(_n.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:Me(t,n)}}});function $(t){_a.push(t)}function Ga(){return _a}var _a,Vt=g(()=>{"use strict";l();_a=[]});import Zu from"path";function Gn(t,e=Ga()){let r=Zu.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var jn=g(()=>{"use strict";l();ba();va();Ta();Pa();Ia();Aa();Oa();Vt();Vt();$(Ra);$(wa);$(Na);$(La);$(ka);$(xa);$(Da)});var it,$n=g(()=>{"use strict";l();xe();it=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let r of e.nodes.values()){let n=this.getPackageForFile(r.path);if(n)for(let o of r.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==n.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function ja(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function eg(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function at(t,e,r){return Ng.every(n=>n(t,e,r))}var tg,rg,ng,og,sg,ig,ag,cg,lg,pg,fg,mg,ug,gg,dg,hg,yg,xg,bg,Sg,Cg,kg,vg,wg,Eg,Tg,Fg,Ng,Wn=g(()=>{"use strict";l();tg=(t,e)=>!e.category||ja(t.category,e.category),rg=(t,e)=>!e.type||ja(t.type,e.type),ng=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,og=(t,e)=>!e.path||eg(t.path,e.path),sg=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,ig=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},ag=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),cg=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),lg=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),pg=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,fg=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,mg=(t,e)=>e.minSize===void 0||t.size>=e.minSize,ug=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,gg=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,dg=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,hg=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,yg=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,xg=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,bg=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Sg=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Cg=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,kg=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,vg=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,wg=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Eg=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Tg=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Fg=(t,e,r)=>!e.any?.length||e.any.some(n=>at(t,n,r)),Ng=[tg,rg,ng,og,sg,ig,ag,cg,lg,pg,fg,mg,ug,gg,dg,hg,yg,xg,bg,Sg,Cg,kg,vg,wg,Eg,Tg,Fg]});function qt(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>at(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;switch(e.sort){case"size":p=c.size-a.size;break;case"imports":p=c.imports.length-a.imports.length;break;case"commitCount90d":p=(c.commitCount90d??0)-(a.commitCount90d??0);break;case"exportUsage":p=(c.avgExportUsage??0)-(a.avgExportUsage??0);break;case"complexity":p=(c.complexity??0)-(a.complexity??0);break;case"cognitiveComplexity":p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0);break}return p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var $a=g(()=>{"use strict";l();Wn();Wn()});function Dg(t,e,r,n){let o=t;switch(r){case"string":o[e]=n;break;case"int":o[e]=parseInt(n,10);break;case"float":o[e]=parseFloat(n);break;case"boolNotFalse":o[e]=n.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=n.toLowerCase()==="true";break}}function za(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!n||!o)return;if(n==="tag"||n==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(n==="sort"){t.sort=o;return}if(n==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=Pg[n];s&&Dg(t,s.field,s.kind,o)}function Ig(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};za(o,n),Object.keys(o).length>0&&e.push(o)}return e}function Qt(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith(Wa)&&o.endsWith(")")){let s=o.slice(Wa.length,-1),i=Ig(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}za(e,n)}return e}var Pg,Wa,Ba=g(()=>{"use strict";l();Pg={category:{field:"category",kind:"string"},type:{field:"type",kind:"string"},path:{field:"path",kind:"string"},importsfile:{field:"importsFile",kind:"string"},importedby:{field:"importedBy",kind:"string"},lastauthor:{field:"lastAuthor",kind:"string"},external:{field:"isExternal",kind:"boolIsTrue"},hasdocstring:{field:"hasDocstring",kind:"boolNotFalse"},isdocumented:{field:"isDocumented",kind:"boolNotFalse"},isstale:{field:"isStale",kind:"boolNotFalse"},minimports:{field:"minImports",kind:"int"},maximports:{field:"maxImports",kind:"int"},minsize:{field:"minSize",kind:"int"},maxsize:{field:"maxSize",kind:"int"},limit:{field:"limit",kind:"int"},mincoverage:{field:"minCoverage",kind:"int"},maxcoverage:{field:"maxCoverage",kind:"int"},minexportusage:{field:"minExportUsage",kind:"float"},maxexportusage:{field:"maxExportUsage",kind:"float"},mincomplexity:{field:"minComplexity",kind:"int"},maxcomplexity:{field:"maxComplexity",kind:"int"},mincognitivecomplexity:{field:"minCognitiveComplexity",kind:"int"},maxcognitivecomplexity:{field:"maxCognitiveComplexity",kind:"int"},mincommits:{field:"minCommits",kind:"int"},maxcommits:{field:"maxCommits",kind:"int"}};Wa="any("});var Ha=g(()=>{"use strict";l();$a();Ba()});import Rg from"path";import F from"typescript";function me(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function zn(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&Ua.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&Ua.has(o.expression.text)&&e.push(n)}return e}function Bn(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function Hn(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=me(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=me(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Un(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=me(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:me(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=me(s.properties,i);return i===s.properties.length-1?{start:me(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:me(s.properties,i+1).getStart(r),text:""}}return null}function Jn(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Kn(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Ag(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function Yt(t,e,r,n){let o=F.createSourceFile(Rg.basename(t),e,F.ScriptTarget.Latest,!0),s=zn(o),[i]=s;if(!i)return e;let a=Bn(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Ag(a).sort())===JSON.stringify(c))return e;let p=Kn(c.map(u=>`@${u}`)),f=s.flatMap(u=>{let y=r.length===0?Un(u,n,o):Hn(u,n,p,o);return y?[y]:[]});return f.length>0?Jn(e,f):e}var Ua,W,Oe=g(()=>{"use strict";l();Ua=new Set(["describe","test","it"]);W=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Mg from"path";var Xt,Ja=g(()=>{"use strict";l();Oe();Xt=class{name="cypress";canHandle(e){return W.has(Mg.extname(e).toLowerCase())}apply(e,r,n){return Yt(e,r,n,"tags")}}});import Lg from"path";function Og(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
12
28
|
`)}
|
|
13
29
|
|
|
14
|
-
`}function
|
|
15
|
-
`}function
|
|
16
|
-
${r.slice(c)}`}}});import
|
|
30
|
+
`}function _g(t){let e=new Set;qn.lastIndex=0;let r=qn.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=qn.exec(t);return e}var Vn,qn,Zt,Ka=g(()=>{"use strict";l();Vn=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,qn=/^@([a-zA-Z0-9_-]+)/gm;Zt=class{name="gherkin";canHandle(e){return Lg.extname(e).toLowerCase()===".feature"}apply(e,r,n){let o=r.replace(Vn,""),s=_g(o),i=n.filter(c=>!s.has(c)),a=i.length>0?Og(i):"";return Vn.test(r)?r.replace(Vn,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function Va(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),o="";for(let s=0;s<r.length;s++){let i=r[s];i==="*"?r[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(n)}var qa=g(()=>{"use strict";l()});import Gg from"path";function $g(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
|
|
31
|
+
`}function Wg(t){let e=Qn.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=n.exec(r);for(;s!==null;)s[1]&&o.push(s[1]),s=n.exec(r);return o}var Qn,jg,er,Qa=g(()=>{"use strict";l();Qn=/^\/\/go:build mokosh_[^\n]+\n/m,jg=/^package\s+\S+/m;er=class{name="go";canHandle(e){return Gg.basename(e).endsWith("_test.go")}apply(e,r,n){let o=Wg(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Qn,"");let i=$g(s);if(o!==null)return r.replace(Qn,i);let a=jg.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
|
|
32
|
+
${r.slice(c)}`}}});import zg from"path";function Hg(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
17
33
|
`)}
|
|
18
34
|
|
|
19
|
-
`}function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
35
|
+
`}function Ug(t){let e=[];Yn.lastIndex=0;let r=Yn.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Yn.exec(t);return e}var Bg,Yn,tr,Ya=g(()=>{"use strict";l();Oe();Bg=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Yn=/^ \* @group (.+)$/gm;tr=class{name="jest";canHandle(e){return W.has(zg.extname(e).toLowerCase())}apply(e,r,n){let o=Bg.exec(r),s=o?Ug(o[0]):null,i=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return r;let a=o?r.slice(o[0].length):r;return n.length===0?a:Hg(i)+a}}});import Jg from"path";function Zg(t){let e=Zn.exec(t);if(!e)return null;let r=[],n=/@Tag\("([^"]*)"\)/g,o=n.exec(e[0]);for(;o!==null;)o[1]&&r.push(o[1]),o=n.exec(e[0]);return r}function ed(t){return`${Kg}
|
|
36
|
+
${t.map(e=>`@Tag("${e}")`).join(`
|
|
37
|
+
`)}
|
|
38
|
+
`}function Xa(t){if(Za.test(t))return t;let e=qg.exec(t);if(e){let n=e.index+e[0].length;return t.slice(0,n)+Xn+`
|
|
39
|
+
`+t.slice(n)}let r=Qg.exec(t);if(r){let n=r.index+r[0].length;return t.slice(0,n)+`
|
|
40
|
+
`+Xn+`
|
|
41
|
+
`+t.slice(n)}return Xn+`
|
|
42
|
+
`+t}function td(t){return/@Tag\b/.test(t)?t:t.replace(Za,"")}var Kg,Zn,Xn,Za,Vg,qg,Qg,Yg,Xg,rr,ec=g(()=>{"use strict";l();Kg="// mokosh:tags",Zn=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,Xn="import org.junit.jupiter.api.Tag;",Za=/^import org\.junit\.jupiter\.api\.Tag;\n/m,Vg=/^(?:public\s+|final\s+|abstract\s+|sealed\s+|non-sealed\s+|strictfp\s+)*(?:class|interface|enum|record|@interface)\s+\w+/m,qg=/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,Qg=/^package\s+[^\n]+;\n/m,Yg=/\/src\/(test|androidTest|integrationTest|it)\//,Xg=/(Test|Tests|Spec|IT)\.(java|groovy)$/;rr=class{name="junit";canHandle(e){let r=e.replace(/\\/g,"/"),n=Jg.extname(r).toLowerCase();return n!==".java"&&n!==".groovy"?!1:Yg.test(r)||Xg.test(r)}apply(e,r,n){let o=Zg(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return o===null?r:td(r.replace(Zn,""));let i=ed(s);if(o!==null)return Xa(r.replace(Zn,i));let a=Vg.exec(r);if(!a)return r;let c=r.slice(0,a.index)+i+r.slice(a.index);return Xa(c)}}});import rd from"path";var nr,tc=g(()=>{"use strict";l();Oe();nr=class{name="playwright";canHandle(e){return W.has(rd.extname(e).toLowerCase())}apply(e,r,n){return Yt(e,r,n,"tag")}}});import nd from"path";function sd(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function id(t){let e=eo.exec(t);if(!e)return null;let r=e[0],n=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(r);for(;s!==null;)s[1]&&n.push(s[1]),s=o.exec(r);return n}function ad(t){let e=t.split(`
|
|
43
|
+
`),r=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(r=s)}),r<0?0:e.slice(0,r+1).reduce((o,s)=>o+s.length+1,0)}var eo,od,or,rc=g(()=>{"use strict";l();eo=/^pytestmark\s*=\s*.+$/m,od=/^import pytest\s*$/m;or=class{name="pytest";canHandle(e){return nd.extname(e).toLowerCase()===".py"}apply(e,r,n){let o=id(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(eo,"").replace(/\n{3,}/g,`
|
|
44
|
+
|
|
45
|
+
`);let i=sd(s);if(o!==null)return r.replace(eo,i);let a=od.test(r),c=ad(r),p=r.slice(0,c),f=r.slice(c),u=a?"":`import pytest
|
|
23
46
|
`,y=p.endsWith(`
|
|
24
47
|
|
|
25
48
|
`)?"":`
|
|
26
|
-
`;return`${p+y+
|
|
27
|
-
${
|
|
28
|
-
`)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function ys(t){let e=new Map;try{let r=Wr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${ds}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:gs});hs(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Wr("git",["-C",t,"log","--name-status","-M",`--format=${ds}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:gs});hs(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var kt,ds,gs,zr=m(()=>{"use strict";l();kt=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(n=>{try{return Wr("git",n,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
29
|
-
`)
|
|
30
|
-
`&&r++;return r}var Ur=m(()=>{"use strict";l()});function Fp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function Ts(t,e,r,n){let o=r?1:1+e,s=Z(t),i=r?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=ge(a,i,!1,n));let c=s.find(u=>u.type.name==="Block");c&&(o+=ge(c,i,!1,n));let p=s.findIndex(u=>u.type.name==="else");if(p>=0){let u=s[p+1];u?.type.name==="IfStatement"?o+=Ts(u,e,!0,n):u&&(o+=1+ge(u,e+1,!1,n))}return o}function ws(t,e,r){let n=1+e,o=t.firstChild;for(;o;)n+=ge(o,e+1,!1,r),o=o.nextSibling;return n}function Np(t,e,r){let n=0,o=t.firstChild;for(;o;)n+=ge(o,e,!1,r),o=o.nextSibling;return n}function Pp(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function ge(t,e,r,n){let o=t.type.name;if(o==="IfStatement")return Ts(t,e,r,n);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return ws(t,e,n);let s=o==="LogicOp"&&Pp(t,n)?1:0;return e>0&&o==="FunctionLiteral"?s+ws(t,e,n):s+Np(t,e,n)}function Ip(t,e){return ge(t,0,!1,e)}function wt(t,e){return{complexity:Fp(t,e),cognitiveComplexity:Ip(t,e)}}function Hr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function Es(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=wt(n.node,e);r.push({name:s,line:Me(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Hr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=wt(n.node,e);r.push({name:a,line:Me(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var Fs=m(()=>{"use strict";l();Ur()});import Dp from"path";import{parser as Mp}from"@lezer/go";function Ps(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=Mp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),v=b.match(Ap);v?.[1]&&o.add(v[1]);let G=b.match(Rp);G&&Ns(G[1],s);let O=b.match(Lp);O&&Ns(O[1],s);break}case"ImportSpec":{let b=c.node.getChild("String");if(b){let G=e.slice(b.from,b.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:G,isExternal:!0,isStyle:!1,type:"static"});let O=c.node.getChild("DefName"),J=O?e.slice(O.from,O.to):G.split("/").pop();J&&J!=="_"&&J!=="."&&i.set(J,G)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let b=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(b){let v=e.slice(b.from,b.to);v!=="_"&&/^[A-Z]/.test(v)&&!n.has(v)&&n.set(v,{name:v})}break}}while(c.next());let p=r.some(b=>b.rawSpecifier==="testing"),u=Dp.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",g=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=wt(a.topNode,e),w=Es(a,e),E=u==="test"?[]:Op(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(g).map(b=>({name:b,kind:"comment-marker"})),category:u,rawCallEdges:E,complexity:y,cognitiveComplexity:x,...w.length>0?{functions:w}:{}}}function Op(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let u=p.firstChild,g=p.getChild("FieldName");if(u?.type.name==="VariableName"&&g){let y=e.slice(u.from,u.to),x=r.get(y);if(x){let w=e.slice(g.from,g.to);n.push({from:a,to:w,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=Hr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function Ns(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var Ap,Rp,Lp,Is=m(()=>{"use strict";l();Fs();Ap=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Rp=/^\/\/go:build\s+(.+)$/,Lp=/^\/\/\s*\+build\s+(.+)$/});import Gp from"livescript";function ee(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function _p(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=ee(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>ee(r.key)??ee(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=ee(t);return e?[{name:e}]:[]}function jp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=ee(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return _p(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>ee(n.val)??ee(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function zp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=U(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=U(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"}}}}return null}function Jr(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=zp(t,e);o&&n.push(o),r.push(...jp(t));for(let s in t){if(Wp.has(s))continue;let i=t[s];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 Ds(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{o=Jr(Gp.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Wp,Ms=m(()=>{"use strict";l();B();vt();Wp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import $p from"luaparse";function Bp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=U(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=U(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Up(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Hp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function Jp(t){let e=t.body,r=Up(e),n=Hp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function As(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{let i=$p.parse(e);o=Bp(i,t),s=Jp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Rs=m(()=>{"use strict";l();B();vt()});async function Yp(){return Ls??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Ls}function Xp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Kp.some(r=>e.startsWith(r))}function qp(t,e){let r=t.match(Qp);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function Os(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Xp(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(...qp(t.value,e)),Array.isArray(t.children))for(let n of t.children)Os(n,e,r)}async function Gs(t,e){let n=(await Yp()).parse(e),o=[];Os(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Kp,Vp,Qp,Ls,_s=m(()=>{"use strict";l();Kp=["http://","https://","mailto:","//"],Vp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Qp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Vp})\\b`,"g")});function Zp(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=Z(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=Z(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function ef(t,e){let r=0,n=Z(t),o=0,s=0;for(;s<n.length;){let i=n[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;r+=a?1:1+e;let c=a?e:e+1,p=n[s+1],u=n[s+2];p&&(r+=j(p,c)),u&&(r+=j(u,c)),o++,s+=3}else if(i?.type.name==="else"){r+=1;let a=n[s+1];a&&(r+=j(a,e+1)),s+=2}else s++}return r}function tf(t,e){let r=0,n=Z(t),o=0;for(;o<n.length;){let s=n[o];if(s?.type.name==="except"){for(r+=1+e,o++;o<n.length&&n[o]?.type.name!=="Body";)r+=j(n[o],e),o++;o<n.length&&(r+=j(n[o],e),o++)}else s?.type.name==="Body"&&(r+=j(s,e)),o++}return r}function js(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=j(n,e+1),n=n.nextSibling;return r}function rf(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;if(r==="IfStatement")return ef(t,e);if(r==="TryStatement")return tf(t,e);if(r==="ForStatement"||r==="WhileStatement")return js(t,e);let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+js(t,e):n+rf(t,e)}function nf(t){return j(t,0)}function Kr(t){return{complexity:Zp(t),cognitiveComplexity:nf(t)}}function Ws(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=Kr(i);r.push({name:a,line:Me(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let u=p.firstChild;for(;u;){if(u.type.name==="FunctionDefinition"){let g=u.getChild("VariableName"),y=g?e.slice(g.from,g.to):void 0;y&&n(u,c?`${c}.${y}`:y),o(u)}else s(u);u=u.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var zs=m(()=>{"use strict";l();Ur()});import of from"path";import{parser as sf}from"@lezer/python";function $s(t,e){let r=[],n=[],o=new Set,s=of.basename(t).toLowerCase(),i=sf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of cf(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let E=a.node.getChild("VariableName");E&&n.push({name:e.slice(E.from,E.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=df(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:u}=Kr(i.topNode),g=Ws(i,e),y=c==="test"?[]:mf(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:u,...g.length>0?{functions:g}:{}}}function cf(t,e,r){let n=t.firstChild;return n?n.name==="from"?lf(t,e,r):pf(t,e,r):[]}function lf(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=ff(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[Ae(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Ae(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Ae(r,p.slice(0,-1),["*"],!1)]:i.map(u=>Ae(r,p+u,[u],!1))}function pf(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(Ae(r,s,["*"],!0))}o=o.nextSibling}return n}function ff(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 uf(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),u=c<=1?"./":"../".repeat(c-1),g=i.nextSibling;for(;g;){if(g.type.name==="VariableName"){let y=e.slice(g.from,g.to),x=y;if(g.nextSibling?.type.name==="as"){let E=g.nextSibling.nextSibling;E?.type.name==="VariableName"&&(x=e.slice(E.from,E.to),g=E)}let w=c===0?a:p?u+p.replace(/\./g,"/"):u+y;r.set(x,w)}g=g.nextSibling}}while(n.next());return r}function mf(t,e){let r=uf(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let u=a.firstChild,g=e.slice(u.from,u.to),y=r.get(g);y&&n.push({from:c,to:g,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,u=a.getChild("Body");if(u){let g=u.firstChild;for(;g;){if(g.type.name==="FunctionDefinition"){let y=g.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(g,p?`${p}.${x}`:x)}else i(g);g=g.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function Ae(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function df(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=>af.has(n.rawSpecifier))?"test":"logic"}var af,Bs=m(()=>{"use strict";l();zs();af=new Set(["pytest","unittest","nose","hypothesis"])});import S from"typescript";function gf(t){let e=1;function r(n){switch(n.kind){case S.SyntaxKind.IfStatement:case S.SyntaxKind.ConditionalExpression:case S.SyntaxKind.ForStatement:case S.SyntaxKind.ForInStatement:case S.SyntaxKind.ForOfStatement:case S.SyntaxKind.WhileStatement:case S.SyntaxKind.DoStatement:case S.SyntaxKind.CatchClause:case S.SyntaxKind.CaseClause:e++;break;case S.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===S.SyntaxKind.AmpersandAmpersandToken||o===S.SyntaxKind.BarBarToken||o===S.SyntaxKind.QuestionQuestionToken)&&e++;break}}S.forEachChild(n,r)}return r(t),e}function Hs(t,e,r){let n=r?1:1+e,o=r?e:e+1;return n+=te(t.expression,o,!1),n+=te(t.thenStatement,o,!1),t.elseStatement&&(S.isIfStatement(t.elseStatement)?n+=Hs(t.elseStatement,e,!0):n+=1+te(t.elseStatement,e+1,!1)),n}function Us(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e+1,!1)}),r}function hf(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function yf(t,e){let r=0;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function xf(t){let e=t.operatorToken.kind;return e===S.SyntaxKind.AmpersandAmpersandToken||e===S.SyntaxKind.BarBarToken||e===S.SyntaxKind.QuestionQuestionToken}function te(t,e,r){if(S.isIfStatement(t))return Hs(t,e,r);if(S.isForStatement(t)||S.isForInStatement(t)||S.isForOfStatement(t)||S.isWhileStatement(t)||S.isDoStatement(t)||S.isSwitchStatement(t))return Us(t,e);if(S.isCatchClause(t))return hf(t,e);let n=0;return S.isConditionalExpression(t)&&(n+=1),S.isBinaryExpression(t)&&xf(t)&&(n+=1),e>0&&(S.isFunctionDeclaration(t)||S.isFunctionExpression(t)||S.isArrowFunction(t))?n+Us(t,e):n+yf(t,e)}function bf(t){return te(t,0,!1)}function Vr(t){return{complexity:gf(t),cognitiveComplexity:bf(t)}}var Js=m(()=>{"use strict";l()});import T from"typescript";function Ks(t,e){Sf(t,e),kf(t,e),vf(t,e),wf(t,e)}function Sf(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Cf(t)){let r;if(T.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(T.isArrowFunction(n)||T.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Cf(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function kf(t,e){if(!T.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 vf(t,e){if(!T.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function wf(t,e){if(T.isCallExpression(t)&&Tf(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&Ef(r,e)}function Tf(t){return T.isIdentifier(t)?Qr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(Qr.has(t.name.text)||T.isIdentifier(t.expression)&&Qr.has(t.expression.text)))}function Ef(t,e){for(let r of t.properties){if(!T.isPropertyAssignment(r)||!T.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=T.isArrayLiteralExpression(n)?n.elements.filter(T.isStringLiteral):r.name.text==="tag"&&T.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var Qr,Vs=m(()=>{"use strict";l();Qr=new Set(["test","describe","it"])});import Qs from"path";import h from"typescript";function Yr(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=E=>{If(E,a),h.forEachChild(E,c)};c(i);let p=zf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&$f(a,i);let u=i.statements[0],g=u?Xs(u):void 0,{complexity:y,cognitiveComplexity:x}=Vr(i),w=Ff(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...w.length>0?{functions:w}:{},...g!==void 0?{description:g}:{}}}function Ff(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Vr(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function Ys(t,e,r,n){let o={name:t},s=Xs(r);s!==void 0&&(o.doc=s);let i=Nf(e);i!==void 0&&(o.flags=i);let a=Pf(e,n);return a!==void 0&&(o.signature=a),o}function Xs(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function Nf(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function Pf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function If(t,e){Df(t,e),Mf(t,e),Rf(t,e),Lf(t,e),Wf(t,e),Ks(t,e)}function Df(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||Xr(n)).length}function Mf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!Af(t)&&(e.hasTypesOnly=!1)}function Af(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Rf(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:A(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function Lf(t,e){h.isExportDeclaration(t)?Of(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Xr(t)&&jf(t,e)}function Of(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))Gf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function Gf(t,e,r){let n=_f(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:A(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function _f(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function jf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,Ys(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,Ys(o,n,t,e.sourceFile))}}}function Wf(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"require"}))}function zf(t,e){let r=Qs.basename(t).toLowerCase(),n=Qs.extname(t).toLowerCase();return ye().some(s=>r.includes(s))?"test":In(r)?"config":e.imports.some(s=>At().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Lt()?"barrel":"logic"}function Xr(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function $f(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=Uf(o);if(s){let i=Hf(o);i&&Tt(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&Bf(o,o.name.text,n,r)}}function Bf(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?Tt(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&Tt(o.body,`${e}.constructor`,r,n)}function Uf(t){if(Xr(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function Hf(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function Tt(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>Tt(o,e,r,n))}var qs=m(()=>{"use strict";l();se();Js();B();Vs()});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 Zs=m(()=>{"use strict";l()});function ei(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function ti(t,e){if(e.length===0)return"ui";try{let r=Mt("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var ri=m(()=>{"use strict";l()});function Re(t,e){let r=$(t);if(r==="stylus"){let s=ei(e,t);return{imports:s,exports:[],tags:[],category:ti(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=qe(e,t);return{imports:s,exports:a,tags:c,category:Et(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=Xe(e,t);return{imports:s,exports:a,tags:c,category:Et(i,s)}}let{imports:n,root:o}=Ye(e,t);return{imports:n,exports:[],tags:[],category:Et(o,n)}}var ni=m(()=>{"use strict";l();B();Zs();Xt();qt();ri()});async function oi(t,e){let r=$(t),n=Uo(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var si=m(()=>{"use strict";l();B();ks();vs();Is();Ms();Rs();_s();Bs();qs();Ie();ni();se();B();Ie();for(let[t,e]of[["javascript",(r,n)=>Yr(r,n,"javascript")],["typescript",(r,n)=>Yr(r,n,"typescript")],["css",Re],["scss",Re],["less",Re],["stylus",Re],["coffeescript",Cs],["livescript",Ds],["lua",As],["python",$s],["go",Ps],["gherkin",Br],["markdown",Gs]])fe(t,e)});import ii from"path";function Jf(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function ci(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function Kf(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 Vf(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 ai(t){return Math.round(t*1e4)/1e4}function Qf(t,e){let r=[];for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let o=e.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=ai(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=ai(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function qr(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Yf(t,e){let r=e.toPath,n=ii.basename(r,ii.extname(r)).replace(/\.(test|spec)$/,"");qr(t.tags,n,"import")}function Xf(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)qr(t.tags,r,"import")}function qf(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&qr(t.tags,o.name,"comment-marker")}function Zf(t,e,r){!e.toPath||e.isExternal||(Yf(t,e),Xf(t,e),qf(t,e,r))}function li(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(Qf(r,t),e.size>0&&Jf(r,e),r.category==="test")for(let n of r.imports)Kf(r,n,t),Zf(r,n,t);Vf(r,t)}}var pi=m(()=>{"use strict";l()});import mi from"fs";import he from"path";function eu(t,e){let r=t.split(`
|
|
31
|
-
`),n=null,o=new Map,s=!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)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){fi(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&fi(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function fi(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=he.isAbsolute(o)?o:he.resolve(e,o);r.set(s,i)}function ui(t){let e;try{e=mi.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:he.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var Le,di=m(()=>{"use strict";l();Le=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return ui(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?ui(he.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 o=mi.readFileSync(he.join(e,"go.mod"),"utf-8"),s=eu(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return he.join(s,i)}}}}});import tu from"fs";import Zr from"path";var Oe,gi=m(()=>{"use strict";l();Oe=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,Zr.sep),i=[n,Zr.join(n,"lib")];for(let a of i){if(!tu.existsSync(a))continue;let c=o(Zr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import ru from"path";var Ge,hi=m(()=>{"use strict";l();Ge=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=o(ru.join(n,"_dummy"),`./${r}`);return s?[s]:null}}});import nu from"fs";import en from"path";function yi(t){try{return nu.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var _e,xi=m(()=>{"use strict";l();_e=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,en.sep),i=en.join(n,`${s}.py`);if(yi(i))return[{path:i,isExternal:!1}];let a=en.join(n,s,"__init__.py");return yi(a)?[{path:a,isExternal:!1}]:null}}});import bi from"path";var ou,je,Si=m(()=>{"use strict";l();ou=["~","http://","https://","//","data:","sass:"],je=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(ou.some(u=>r.startsWith(u)))return null;let s=o(e,r);if(s)return[s];let i=bi.dirname(r),a=bi.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var Ci=m(()=>{"use strict";l();di();gi();hi();xi();Si()});import Ft from"fs";import W from"path";var re,tn=m(()=>{"use strict";l();Ci();re=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 _e,new Oe,new Le,new je,new Ge]}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`${W.dirname(e)}\0${this.langBucketFor(e)}\0${r}`}resolveAll(e,r){let n=this.cacheKey(e,r),o=this.resolutionCache.get(n);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,r);return this.resolutionCache.set(n,s.length>0?s:null),s}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 o=(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,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){return this.resolveAll(e,r)[0]??null}resolveLocalPath(e,r){let n=W.dirname(e),o=r.startsWith("/")?r:W.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let u=this.tryExtensions(c,p,s);if(u)return u}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=W.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=W.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return Ft.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),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=W.join(r,"tsconfig.json");if(Ft.existsSync(n))try{let s=JSON.parse(Ft.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=W.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}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 o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=W.join(n,a);try{if(Ft.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(W.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import We from"fs";import I from"path";import su from"piscina";function cu(t,e){if(t.length===0)return e;let r=t.map(i=>I.dirname(i).split(I.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 o=n.join(I.sep)||I.sep,s=I.relative(e,o);return s.startsWith("..")||I.isAbsolute(s)?e:o}var iu,ki,au,ze,vi=m(()=>{"use strict";l();zr();se();Yt();si();pi();we();tn();iu=["tests","test","__tests__","specs","spec"],ki=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),au=600;ze=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new re(e),this.lockFile=Hn(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(n=>I.isAbsolute(n)?n:I.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ys(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(cu(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
32
|
-
Done. Total processed: ${this.visited.size} nodes.
|
|
33
|
-
`),li(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??au;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r))){e.maxThreads!==void 0&&e.maxThreads<1&&process.stderr.write(`
|
|
34
|
-
Warning: parallelParsing.maxThreads (${e.maxThreads}) must be at least 1; using 1.
|
|
35
|
-
`);try{let n=I.join(f,"parse-worker.js");this.pool=new su({filename:n,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(n){process.stderr.write(`
|
|
36
|
-
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
|
|
37
|
-
`),this.pool=null}}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=We.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())ki.has(a.name)||o.push(I.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=ye(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=I.dirname(o);if(s===o)break;for(let i of iu){let a=I.join(s,i);try{We.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}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=We.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=I.join(e,o.name);o.isDirectory()?ki.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=We.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=I.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),ci(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=We.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
|
|
38
|
-
Warning: failed to parse ${r}: ${o}
|
|
39
|
-
`),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):oi(e,r)}makeStubNode(e,r,n){return{path:r,type:$(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:I.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:u,complexity:g,cognitiveComplexity:y,functions:x}=o;return{path:r,type:$(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...u!==void 0?{description:u}:{},...s.length>0?{callEdges:s}:{},...g!==void 0?{complexity:g}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(s.length!==0)for(let i of s){let a={...o,toPath:i.isExternal?i.path:I.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var wi=m(()=>{"use strict";l();Bt();vi();Ht();Vt();tr();rt();nt();we();tn();mr();st();yr();kr();vr()});var rn=m(()=>{"use strict";l();wi()});function Ti(t,e){return{identifier:e?.identifier??new Ct,featureMap:e?.featureDetection===!1?new Map:V(t.nodes,e?.featureDetection??void 0)}}function Ei(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new Q(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,u)=>{if(!u)return!0;if(!a.updateAffectedSymbols(c,u))return!1;if(p>0){let g=r.get(c.path);if(g)return n(g),!1}return o(c),!0},{direction:"incoming"})}}function nn(t,e,r){let{identifier:n,featureMap:o}=Ti(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return Ei(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function on(t,e,r){let{identifier:n,featureMap:o}=Ti(t,r),s=new Set;return Ei(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var Fi=m(()=>{"use strict";l();rn();jr()});var Ni=m(()=>{"use strict";l();ms();jr();Fi()});import lu from"fs";import $e from"path";async function R(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=$e.resolve(t);return await new ze(s,r,n.pathAliases?new re(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function Pi(t,e={}){let r=$e.resolve(t),n=Cr(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new Pe(r,n.type);for(let a of o){let c=e.silent?void 0:g=>{process.stderr.write(`[${a.name}] Processed ${g} files...\r`)},u=await new ze(r,null,new re(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,u)}return i}function L(t,e={}){let r=[],n=new Set([...e.ignoreDirs??K,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??jt,...e.additionalExtensions??[]]);function s(i){try{let a=lu.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=$e.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has($e.extname(c.name).toLowerCase())&&r.push($e.relative(t,p))}}catch{}}return s(t),r}var k=m(()=>{"use strict";l();_t();be();Gn();jn();Bt();Ht();Vt();tr();rt();nt();nr();we();fr();mr();vo();st();yr();kr();lt();vr();se();Ie();Qo();Ni();be();rn()});var sn=m(()=>{"use strict";l();be()});import Be from"path";import{parseArgs as pu}from"util";function fu(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return Be.resolve(t[e+1]);return process.cwd()}function H(t){return t?parseInt(t,10):void 0}function Ii(t){return t?t.split(",").map(e=>e.trim()):void 0}function mu(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(uu.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in an&&e.push(n)}return e}function du(t){return{mermaid:t.mermaid??!1,proposeTags:t["propose-tags"]??!1,plain:t.plain??!1,affectedTests:t["affected-tests"]??!1,detectFeatures:t["detect-features"]??!1,findUnused:t["find-unused"]??!1,excludeTests:t["exclude-tests"]??!1,checkCycles:t["check-cycles"]??!1,checkDocDrift:t["check-doc-drift"]??!1,findUncovered:t["find-uncovered"]??!1}}function gu(t){return{listTags:t["list-tags"]??!1,callers:t.callers??!1,silent:t.silent??!1,queryHelp:t["query-help"]??!1,typeGraph:t["type-graph"]??!1,moduleResponsibility:t["module-responsibility"]??!1,featureGraph:t["feature-graph"]??!1,callGraph:t["call-graph"]??!1,findSymbol:t["find-symbol"]??!1,apiSurface:t["api-surface"]??!1}}function hu(t){return{applyTags:t["apply-tags"]??!1,dryRun:t["dry-run"]??!1,initSkill:t["init-skill"]??!1,initConfig:t["init-config"]??!1,force:t.force??!1,dependencies:t.dependencies??!1,dependents:t.dependents??!1,affected:t.affected??!1,testsOnly:t["tests-only"]??!1,cached:t.cached??!1}}function yu(t){return{withMeta:t["with-meta"]??!1,withEdgeDetail:t["with-edge-detail"]??!1,findComplexFunctions:t["find-complex-functions"]??!1,findDuplicates:t["find-duplicates"]??!1,findRiskHotspots:t["find-risk-hotspots"]??!1,workspacePackages:t["workspace-packages"]??!1,workspaceAffected:t["workspace-affected"]??!1,clearCache:t["clear-cache"]??!1,slim:t.slim??!1,watch:t.watch??!1}}function Di(t){let e=fu(t),r=Be.join(Be.resolve(e,ae),ce),{values:n,positionals:o}=pu({args:mu(t),allowPositionals:!0,options:an}),s=n.cache,i=n.config,a=n.metric,c=n;return{rootDir:e,cachePath:s?Be.resolve(e,s):r,configPath:i?Be.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:Ii(n.paths),featureThreshold:H(n["feature-threshold"]),minOutDegree:H(n["min-out-degree"]),...du(c),...gu(c),help:t.length===0||(n.help??!1),...hu(c),changedSymbols:Ii(n["changed-symbols"]),depth:H(n.depth),...yu(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:H(n["complexity-threshold"]),limit:H(n.limit),minDuplicateLines:H(n["min-duplicate-lines"]),maxCoveragePct:H(n["max-coverage-pct"]),minChurn:H(n["min-churn"]),entryPoints:o}}var an,uu,Mi=m(()=>{"use strict";l();sn();an={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"find-risk-hotspots":{type:"boolean"},"max-coverage-pct":{type:"string"},"min-churn":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},uu=new Set(Object.entries(an).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function cn(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=u=>i?u.map(g=>({path:g,...Y(e,g)})):u;if(s){let u=Jt(e),g=Kt(u,r),y=n?g.filter(w=>e.nodes.get(w)?.category==="test"):g,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=sr(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var Ai=m(()=>{"use strict";l();k()});import ln from"path";function ne(t){return t.filter(e=>{let r=ln.basename(e).toLowerCase();return xu.some(n=>r.includes(n))})}function Nt(t){return new kt().getChangedFiles().map(e=>ln.relative(t,ln.resolve(t,e)))}var xu,Pt=m(()=>{"use strict";l();zr();xu=[".test.",".spec.","-test.","-spec."]});async function Ri(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t,i=Nt(r);if(![...e.nodes.values()].some(p=>ne([p.path]).length>0)){let p=L(r,n);e=await R(r,ne(p),e,N(s))}let c=on(e,i,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(c.join(`
|
|
40
|
-
`))}var Li=m(()=>{"use strict";l();k();Pt()});async function Oi(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:zt(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=$t(e,o);console.log(JSON.stringify(s,null,2))}var Gi=m(()=>{"use strict";l();k()});async function _i(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=L(r,n);e=await R(r,ne(c),e,N(i))}let a=await _r(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var ji=m(()=>{"use strict";l();k();Pt()});async function Wi(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Ut(e,r);console.log(JSON.stringify(n,null,2))}var zi=m(()=>{"use strict";l();k()});async function pn(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=ir(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
|
|
41
|
-
`):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var $i=m(()=>{"use strict";l();k()});async function fn(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
|
|
49
|
+
`;return`${p+y+u+i}
|
|
50
|
+
${f}`}}});import cd from"path";function md(t){let e=to.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var to,ld,pd,fd,sr,nc=g(()=>{"use strict";l();to=/^\/\/ mokosh:tags .*\n/m,ld=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,pd=/\/src\/(test|it)\//,fd=/(Spec|Suite|Test|Props)\.scala$/;sr=class{name="scalatest";canHandle(e){let r=e.replace(/\\/g,"/");return cd.extname(r).toLowerCase()!==".scala"?!1:pd.test(r)||fd.test(r)}apply(e,r,n){let o=md(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return o===null?r:r.replace(to,"");let i=`// mokosh:tags ${s.join(", ")}
|
|
51
|
+
`;if(o!==null)return r.replace(to,i);let a=ld.exec(r);return a?r.slice(0,a.index)+i+r.slice(a.index):r}}});import oc from"path";import sc from"typescript";var ud,ir,ic=g(()=>{"use strict";l();Oe();ud=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,ir=class{name="vitest";canHandle(e){return W.has(oc.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(ud,""),s=sc.createSourceFile(oc.basename(e),o,sc.ScriptTarget.Latest,!0),i=zn(s),[a]=i;if(!a)return o;let c=Bn(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(u=>{let y=n.length===0?Un(u,"tags",s):Hn(u,"tags",Kn(p),s);return y?[y]:[]});return f.length>0?Jn(o,f):o}}});import ro from"path";import ar from"typescript";function dd(t){let e=ar.createSourceFile("detect.ts",t,ar.ScriptTarget.Latest,!0);for(let r of e.statements){if(!ar.isImportDeclaration(r)||!ar.isStringLiteral(r.moduleSpecifier))continue;let n=gd[r.moduleSpecifier.text];if(n)return n}return null}function cc(t="vitest",e={},r=process.cwd()){return[new Zt,new or,new er,new rr,new sr,new no(r,t,Object.entries(e))]}function lc(t,e){return e.find(r=>r.canHandle(t))??null}var ac,gd,no,pc=g(()=>{"use strict";l();Ja();Ka();qa();Qa();Ya();ec();tc();rc();nc();Oe();ic();ac={vitest:()=>new ir,playwright:()=>new nr,cypress:()=>new Xt,jest:()=>new tr},gd={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};no=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return W.has(ro.extname(e).toLowerCase())}apply(e,r,n){let o=dd(r)??this.matchOverride(e)??this.defaultFramework;return(ac[o]??ac.vitest)().apply(e,r,n)}matchOverride(e){let r=ro.relative(this.rootDir,e).split(ro.sep).join("/");for(let[n,o]of this.frameworkOverrides)if(Va(n,r))return o;return null}}});import fc from"fs/promises";import hd from"path";async function Sd(t,e,r,n){let o;try{o=await fc.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=lc(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await fc.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function oo(t,e,r){let n=he(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=cc(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,f=[];for(let x of c.tags)xd.has(x.kind)&&yd.test(x.name)&&(bd.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),f.push(x.name)));f.sort();let u=hd.resolve(e,c.path),y=await Sd(u,f,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var yd,xd,bd,mc=g(()=>{"use strict";l();wr();pc();yd=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,xd=new Set(["import"]),bd=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var cr,so=g(()=>{"use strict";l();cr=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});var uc=g(()=>{"use strict";l();Pr();dn();Ir();Mr();Ot();Wt();zt();xe();Lt();Nn();_t();Rn();jn();$n()});var io=g(()=>{"use strict";l();uc()});function gc(t,e){return{identifier:e?.identifier??new cr,featureMap:e?.featureDetection===!1?new Map:fe(t.nodes,e?.featureDetection??void 0)}}function dc(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new ce(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let u=r.get(c.path);if(u)return n(u),!1}return o(c),!0},{direction:"incoming"})}}function ao(t,e,r){let{identifier:n,featureMap:o}=gc(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return dc(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function co(t,e,r){let{identifier:n,featureMap:o}=gc(t,r),s=new Set;return dc(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var hc=g(()=>{"use strict";l();io();so()});var yc=g(()=>{"use strict";l();mc();so();hc()});import Cd from"fs";import ct from"path";async function M(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=ct.resolve(t);return await new ae(s,r,n.pathAliases?new J(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0,n.additionalIgnoreDirs??[]).build(e)}async function xc(t,e={}){let r=ct.resolve(t),n=Gn(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new it(r,n.type);for(let a of o){let c=e.silent?void 0:u=>{process.stderr.write(`[${a.name}] Processed ${u} files...\r`)},f=await new ae(r,null,new J(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,f)}return i.annotateCrossPackageEdges(),i}function L(t,e={}){let r=[],n=new Set([...e.ignoreDirs??I,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Er,...e.additionalExtensions??[]]);function s(i){try{let a=Cd.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=ct.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has(ct.extname(c.name).toLowerCase())&&r.push(ct.relative(t,p))}}catch{}}return s(t),r}var k=g(()=>{"use strict";l();wr();G();jo();Wo();Pr();Ir();Mr();pa();Ot();Wt();zt();It();xe();Gt();Nn();ua();_t();Rn();jn();Vt();$n();de();Be();Ha();yc();G();io()});var lo=g(()=>{"use strict";l();G()});import lt from"path";import{parseArgs as kd}from"util";function vd(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return lt.resolve(t[e+1]);return process.cwd()}function K(t){return t?parseInt(t,10):void 0}function bc(t){return t?t.split(",").map(e=>e.trim()):void 0}function Ed(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(wd.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in po&&e.push(n)}return e}function Td(t){return{mermaid:t.mermaid??!1,proposeTags:t["propose-tags"]??!1,plain:t.plain??!1,affectedTests:t["affected-tests"]??!1,detectFeatures:t["detect-features"]??!1,findUnused:t["find-unused"]??!1,excludeTests:t["exclude-tests"]??!1,checkCycles:t["check-cycles"]??!1,checkDocDrift:t["check-doc-drift"]??!1,findUncovered:t["find-uncovered"]??!1}}function Fd(t){return{listTags:t["list-tags"]??!1,callers:t.callers??!1,silent:t.silent??!1,queryHelp:t["query-help"]??!1,typeGraph:t["type-graph"]??!1,moduleResponsibility:t["module-responsibility"]??!1,featureGraph:t["feature-graph"]??!1,callGraph:t["call-graph"]??!1,findSymbol:t["find-symbol"]??!1,apiSurface:t["api-surface"]??!1}}function Nd(t){return{applyTags:t["apply-tags"]??!1,dryRun:t["dry-run"]??!1,initSkill:t["init-skill"]??!1,initConfig:t["init-config"]??!1,force:t.force??!1,dependencies:t.dependencies??!1,dependents:t.dependents??!1,affected:t.affected??!1,testsOnly:t["tests-only"]??!1,cached:t.cached??!1}}function Pd(t){return{withMeta:t["with-meta"]??!1,withEdgeDetail:t["with-edge-detail"]??!1,findComplexFunctions:t["find-complex-functions"]??!1,findDuplicates:t["find-duplicates"]??!1,findRiskHotspots:t["find-risk-hotspots"]??!1,workspacePackages:t["workspace-packages"]??!1,workspaceAffected:t["workspace-affected"]??!1,clearCache:t["clear-cache"]??!1,slim:t.slim??!1,watch:t.watch??!1}}function Sc(t){let e=vd(t),r=lt.join(lt.resolve(e,V),ye),{values:n,positionals:o}=kd({args:Ed(t),allowPositionals:!0,options:po}),s=n.cache,i=n.config,a=n.metric,c=n;return{rootDir:e,cachePath:s?lt.resolve(e,s):r,configPath:i?lt.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:bc(n.paths),featureThreshold:K(n["feature-threshold"]),minOutDegree:K(n["min-out-degree"]),...Td(c),...Fd(c),help:t.length===0||(n.help??!1),...Nd(c),changedSymbols:bc(n["changed-symbols"]),depth:K(n.depth),...Pd(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:K(n["complexity-threshold"]),limit:K(n.limit),minDuplicateLines:K(n["min-duplicate-lines"]),maxCoveragePct:K(n["max-coverage-pct"]),minChurn:K(n["min-churn"]),base:n.base,compareBranches:n["compare-branches"],compareFull:n["compare-full"]??!1,compareMaxItems:K(n["compare-max-items"]),entryPoints:o}}var po,wd,Cc=g(()=>{"use strict";l();lo();po={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"find-risk-hotspots":{type:"boolean"},"max-coverage-pct":{type:"string"},"min-churn":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"},base:{type:"string"},"compare-branches":{type:"string"},"compare-full":{type:"boolean"},"compare-max-items":{type:"string"}},wd=new Set(Object.entries(po).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function fo(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(u=>({path:u,...le(e,u)})):f;if(s){let f=Rr(e),u=Ar(f,r),y=n?u.filter(b=>e.nodes.get(b)?.category==="test"):u,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=xn(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var kc=g(()=>{"use strict";l();k()});import mo from"path";function ue(t){return t.filter(e=>{let r=mo.basename(e).toLowerCase();return Dd.some(n=>r.includes(n))})}function lr(t,e){return new yt().getChangedFiles(t,e).map(r=>mo.relative(t,mo.resolve(t,r)))}var Dd,pr=g(()=>{"use strict";l();Or();Dd=[".test.",".spec.","-test.","-spec."]});async function vc(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s,base:i}=t,a=lr(r,i);if(![...e.nodes.values()].some(f=>ue([f.path]).length>0)){let f=L(r,n);e=await M(r,ue(f),e,T(s))}let p=co(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
|
|
52
|
+
`))}var wc=g(()=>{"use strict";l();k();pr()});async function Ec(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:Fr(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=Nr(e,o);console.log(JSON.stringify(s,null,2))}var Tc=g(()=>{"use strict";l();k()});async function Fc(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=L(r,n);e=await M(r,ue(c),e,T(i))}let a=await oo(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Nc=g(()=>{"use strict";l();k();pr()});async function Pc(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Dr(e,r);console.log(JSON.stringify(n,null,2))}var Dc=g(()=>{"use strict";l();k()});async function uo(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=bn(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
|
|
53
|
+
`):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Ic=g(()=>{"use strict";l();k()});async function go(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
|
|
42
54
|
`);for(let n of r)process.stderr.write(` ${n.join(" \u2192 ")}
|
|
43
|
-
`);process.exit(1)}console.log("No cycles detected.")}var
|
|
55
|
+
`);process.exit(1)}console.log("No cycles detected.")}var Rc=g(()=>{"use strict";l()});async function ho(t){let{graph:e}=t,r=[...e.nodes.values()].filter(n=>n.type==="markdown"&&n.staleFor&&n.staleFor.length>0).map(n=>({doc:n.path,staleFor:n.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
|
|
44
56
|
`);for(let{doc:n,staleFor:o}of r)process.stderr.write(` ${n} \u2014 references changed more recently: ${o.join(", ")}
|
|
45
|
-
`);process.exit(1)}console.log("No doc drift detected.")}var
|
|
46
|
-
`):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var
|
|
47
|
-
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var
|
|
48
|
-
`):JSON.stringify({tags:o,count:o.length},null,2))}var
|
|
57
|
+
`);process.exit(1)}console.log("No doc drift detected.")}var Ac=g(()=>{"use strict";l()});import fr from"fs";import yo from"path";function Mc(t){let e=yo.dirname(t),r=yo.join(e,te),n=yo.join(e,Ge),o=!1;for(let s of[t,r])fr.existsSync(s)&&(fr.unlinkSync(s),console.log(`Cache cleared: ${s}`),o=!0);fr.existsSync(n)&&(fr.rmSync(n,{recursive:!0,force:!0}),console.log(`Cache cleared: ${n}`),o=!0),o||console.log(`No cache file present at ${t}`)}var Lc=g(()=>{"use strict";l();k()});async function Oc(t){let{graph:e,rootDir:r,compareBranches:n,rawConfig:o}=t;if(!n){console.error("Error: --compare-branches requires a base ref, e.g. --compare-branches main"),process.exit(1);return}let s=await Tn(r,n,e,{entryPoints:t.entryPoints,minDuplicateLines:t.minDuplicateLines,complexityMetric:t.metric,complexityThreshold:t.complexityThreshold,maxCoveragePct:t.maxCoveragePct,...T(o)}),i=t.compareFull?s:En(s,{metric:t.metric,maxItems:t.compareMaxItems});console.log(JSON.stringify(i,null,2))}var _c=g(()=>{"use strict";l();k()});async function xo(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=yn(e,r,n??1),i=o?s.map(a=>({...a,...le(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var Gc=g(()=>{"use strict";l();k()});async function bo(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=tt(e,r),s=n?o.map(i=>({...i,...le(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var jc=g(()=>{"use strict";l();k()});async function $c(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=L(r,n);e=await M(r,c,e,T(s))}let i=fe(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var Wc=g(()=>{"use strict";l();k()});async function zc(t){let{graph:e}=t,{rootDir:r,scanOptions:n,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=L(r,n);e=await M(r,c,e,T(s))}let i=rt(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var Bc=g(()=>{"use strict";l();k()});async function So(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=Re(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var Hc=g(()=>{"use strict";l();k()});import Uc from"path";async function Co(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s,cachePath:i}=t,a=o??6,c=[...n.ignoreDirs??I,...n.additionalIgnoreDirs??[]],p=Uc.join(Uc.dirname(i),te),f=Pe(p),{groups:u}=await Ie(e,r,{minLines:a,limit:s,ignoreDirs:c,tokenCache:f});De(f,p),console.log(JSON.stringify({minLines:a,groups:u,count:u.length},null,2))}var Jc=g(()=>{"use strict";l();k()});async function ko(t){let{graph:e,metric:r,complexityThreshold:n,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!Z(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let a=n??10,c=o??50,p=s??0,{hotspots:f,count:u,churnDataAvailable:y}=Ae(e,{metric:r,minComplexity:a,maxCoveragePct:c,minChurn:p,limit:i});console.log(JSON.stringify({metric:r??"cognitiveComplexity",minComplexity:a,maxCoveragePct:c,minChurn:p,churnDataAvailable:y,hotspots:f,count:u},null,2))}var Kc=g(()=>{"use strict";l();k()});async function Vc(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=Pn(e,r);console.log(n?o.map(s=>s.path).join(`
|
|
58
|
+
`):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var qc=g(()=>{"use strict";l();k()});async function vo(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!Z(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
|
|
59
|
+
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var Qc=g(()=>{"use strict";l();k()});import Id from"path";function Ad(t){let e=Id.basename(t).toLowerCase();return Rd.some(r=>e.includes(r))}async function Yc(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=L(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!Ad(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var Rd,Xc=g(()=>{"use strict";l();k();Rd=[".test.",".spec.","-test.","-spec.",".stories."]});async function wo(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=Qt(r);s=qt(s,c)}if(n){let c=D.deserialize(s);console.log(dt.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=fn(e);console.log(JSON.stringify(o?{...Sn(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var Zc=g(()=>{"use strict";l();k()});import Md from"fs";import Eo from"path";function mr(t,e,r){let n=t;for(let o=0;o<6;o++){let s=Eo.join(n,"templates",...e);if(Md.existsSync(Eo.join(s,r)))return s;let i=Eo.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var To=g(()=>{"use strict";l()});import el from"fs";import tl from"path";function rl(t,e=process.cwd()){let r=mr(m,["config"],"mokosh.config.js"),n=tl.join(r,"mokosh.config.js"),o=tl.join(e,"mokosh.config.js");if(el.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}el.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var nl=g(()=>{"use strict";l();To()});import Fo from"fs";import ur from"path";function ol(t,e=process.cwd()){let r=mr(m,["skill"],"SKILL.md");for(let n of Ld){let o=ur.join(r,n.templateFile),s=ur.join(e,...n.destPath),i=ur.join(...n.destPath);if(Fo.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Fo.mkdirSync(ur.dirname(s),{recursive:!0}),Fo.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Ld,sl=g(()=>{"use strict";l();To();Ld=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function No(t){let{graph:e,plain:r}=t,n=new Map;for(let s of e.nodes.values())for(let i of s.tags)n.set(i.name,(n.get(i.name)??0)+1);let o=[...n.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(r?o.map(s=>s.name).join(`
|
|
60
|
+
`):JSON.stringify({tags:o,count:o.length},null,2))}var il=g(()=>{"use strict";l()});async function al(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=Fn(e,n!==void 0?{minOutDegree:n}:void 0);if(r?.length){let s=r.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var cl=g(()=>{"use strict";l();k()});async function ll(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,plain:s,rawConfig:i,base:a}=t;s||console.log("Proposing test tags based on git diff...");let c=lr(r,a);if(e.nodes.size===0){let f=L(r,n);e=await M(r,ue(f),e,T(i))}let p=ao(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?p.join(" "):JSON.stringify({proposedTags:p},null,2))}var pl=g(()=>{"use strict";l();k();pr()});async function fl(t){let{graph:e,typeFilter:r}=t,n=Dn(e);if(r){let o=In(n,r);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(n.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var ml=g(()=>{"use strict";l();k()});function ul(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var gl=g(()=>{"use strict";l()});function dl(t){console.log(JSON.stringify(Cn(t),null,2))}var hl=g(()=>{"use strict";l();k()});import Po from"path";function Od(t,e,r,n){return t!==e?t:r?Po.resolve(n,r):e}function yl(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?he(o,{isExplicitPath:!0}):he(e),i=Po.join(Po.resolve(e,V),ye),a=r.length>0?r:s.entryPoints??[],c=Od(n,i,s.cachePath,e),p={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:s}}var xl=g(()=>{"use strict";l();k();lo()});import pt from"fs";import _d from"path";function bl(t){if(!pt.existsSync(t))return null;let e=pt.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}function Do(t,e){let r=_d.dirname(e);pt.existsSync(r)||pt.mkdirSync(r,{recursive:!0}),pt.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Io(t,e,r,n={silent:!1,...T(void 0)}){return M(t,e,r,n)}var Sl=g(()=>{"use strict";l();k()});var Cl,kl,vl=g(()=>{"use strict";l();Cl=`
|
|
49
61
|
Usage: mokosh [options] <entry-point1> <entry-point2> ...
|
|
50
62
|
|
|
51
63
|
Options:
|
|
@@ -55,6 +67,9 @@ Options:
|
|
|
55
67
|
--propose-tags Propose test tags based on git diff
|
|
56
68
|
--plain Output tags as plain text instead of JSON (use with --propose-tags)
|
|
57
69
|
--affected-tests List test files affected by git diff
|
|
70
|
+
--base <ref> Diff against this ref (e.g. origin/main) instead of only local
|
|
71
|
+
working-tree/staged/untracked changes (use with --propose-tags/
|
|
72
|
+
--affected-tests); needed in CI, where the tree is already clean
|
|
58
73
|
--apply-tags Write @tag annotations into test files from graph tags
|
|
59
74
|
--dry-run Preview tag changes without writing to disk (use with --apply-tags)
|
|
60
75
|
--detect-features Output files with high out-degree (orchestrators/aggregators)
|
|
@@ -117,6 +132,13 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
|
|
|
117
132
|
--max-coverage-pct <N> Max file coverage % to include (default: 50, use with --find-risk-hotspots)
|
|
118
133
|
--min-churn <N> Min 90-day commit count to include (default: 0, ignored if gitStats
|
|
119
134
|
is off; use with --find-risk-hotspots)
|
|
135
|
+
--compare-branches <ref> Review a PR/branch: diff the current graph against <ref> (via a
|
|
136
|
+
temporary git worktree) \u2014 file changes, stale post-rename
|
|
137
|
+
references, and duplication/complexity/doc-drift/coverage deltas
|
|
138
|
+
--compare-full Print the complete BranchComparison instead of the compact summary
|
|
139
|
+
(use with --compare-branches)
|
|
140
|
+
--compare-max-items <N> Entries kept per summary delta list (default: 8; true counts always
|
|
141
|
+
reported; use with --compare-branches)
|
|
120
142
|
--workspace-packages List monorepo packages and their cross-package dependencies
|
|
121
143
|
--workspace-affected Cross-package blast-radius for --file in a monorepo
|
|
122
144
|
--find-symbol Find every file that exports --function <name> by exact name, with
|
|
@@ -137,7 +159,7 @@ Notes:
|
|
|
137
159
|
server only loads JSON config (allowJs: false) for security. This is intentional.
|
|
138
160
|
--workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
|
|
139
161
|
which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
|
|
140
|
-
`,
|
|
162
|
+
`,kl=`
|
|
141
163
|
Query filter reference (--query "key:value,key:value,...")
|
|
142
164
|
All keys are case-insensitive. Multiple keys are AND'd together.
|
|
143
165
|
|
|
@@ -260,5 +282,5 @@ COMMON PATTERNS
|
|
|
260
282
|
|
|
261
283
|
Large TypeScript logic files:
|
|
262
284
|
--query "type:typescript,category:logic,sort:size,limit:5"
|
|
263
|
-
`});var
|
|
285
|
+
`});var wl,El=g(()=>{"use strict";l();wl=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Gd from"fs";function Tl(t,e,r){let n=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await r()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Gd.watch(t,{recursive:!0},(c,p)=>{!p||wl.test(p)||(n&&clearTimeout(n),n=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{n&&clearTimeout(n),a?.close(),process.exit(0)})}var Fl=g(()=>{"use strict";l();El()});function $d(t){t.help&&(console.log(Cl),process.exit(0)),t.queryHelp&&(console.log(kl),process.exit(0)),t.initSkill&&(ol(t.force),process.exit(0)),t.initConfig&&(rl(t.force),process.exit(0)),t.clearCache&&(Mc(t.cachePath),process.exit(0))}async function Wd(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let n=await xc(r,T(e.rawConfig));return t.workspacePackages?dl(n):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),ul(n,t.file)),!0}function zd(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.findRiskHotspots||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface||!!t.compareBranches}function Bd(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:ll},{name:"--apply-tags",flag:t.applyTags,handler:Fc},{name:"--affected-tests",flag:t.affectedTests,handler:vc},{name:"--detect-features",flag:t.detectFeatures,handler:$c},{name:"--find-unused",flag:t.findUnused,handler:Yc},{name:"--check-cycles",flag:t.checkCycles,handler:go},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:ho},{name:"--find-uncovered",flag:t.findUncovered,handler:vo},{name:"--list-tags",flag:t.listTags,handler:No},{name:"--callers",flag:t.callers,handler:uo},{name:"--dependencies",flag:t.dependencies,handler:xo},{name:"--dependents",flag:t.dependents,handler:bo},{name:"--affected",flag:t.affected,handler:fo},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:So},{name:"--find-duplicates",flag:t.findDuplicates,handler:Co},{name:"--find-risk-hotspots",flag:t.findRiskHotspots,handler:ko},{name:"--type-graph",flag:t.typeGraph,handler:fl},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:al},{name:"--feature-graph",flag:t.featureGraph,handler:zc},{name:"--call-graph",flag:t.callGraph,handler:Pc},{name:"--find-symbol",flag:t.findSymbol,handler:Vc},{name:"--api-surface",flag:t.apiSurface,handler:Ec},{name:"--compare-branches",flag:!!t.compareBranches,handler:Oc}].filter(n=>n.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(n=>n.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??wo}async function Hd(t,e,r,n,o,s,i){jd.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --find-risk-hotspots, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),Tl(r,300,async()=>{let a=await Io(r,n,e.graph,{silent:s,...T(i)});Do(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function Nl(){let t=process.argv.slice(2),e=Sc(t);$d(e);let r=yl(e);vr(r.rawConfig);let{rootDir:n,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=r;if(await Wd(e,r,n))return;let a=zd(e),c=bl(s)??new D(new Map);(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),c=await Io(n,o,c,{silent:e.silent,...T(r.rawConfig)}),Do(c,s));let p={graph:c,rootDir:n,cachePath:s,entryPoints:o.map(u=>u.replace(`${n}/`,"")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines,maxCoveragePct:e.maxCoveragePct,minChurn:e.minChurn,base:e.base,compareBranches:e.compareBranches,compareFull:e.compareFull,compareMaxItems:e.compareMaxItems},f=Bd(e);if(e.watch){await Hd(f,p,n,o,s,e.silent,r.rawConfig);return}await f(p)}var jd,Pl=g(()=>{"use strict";l();k();Cc();kc();wc();Tc();Nc();Dc();Ic();Rc();Ac();Lc();_c();Gc();jc();Wc();Bc();Hc();Jc();Kc();qc();Qc();Xc();Zc();nl();sl();il();cl();pl();ml();gl();hl();xl();Sl();vl();Fl();jd=new Set([wo,uo,xo,bo,fo,vo,So,Co,ko,go,ho,No])});var Ud=Dl(()=>{l();Pl();Nl().catch(t=>{console.error(t),process.exit(1)})});export default Ud();
|
|
264
286
|
//# sourceMappingURL=cli.mjs.map
|