@omfalos/mokosh 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +68 -44
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +68 -44
- 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 +6 -4
- package/dist/duplication-worker.js.map +1 -1
- package/dist/duplication-worker.mjs +6 -4
- package/dist/duplication-worker.mjs.map +1 -1
- package/dist/index.d.mts +417 -58
- package/dist/index.d.ts +417 -58
- package/dist/index.js +43 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -28
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +46 -30
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +46 -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-D9P-y7lH.d.mts} +3 -3
- package/dist/{tokenizer-BaF1eUBQ.d.ts → tokenizer-D9P-y7lH.d.ts} +3 -3
- package/dist/{types-BtSqoqbZ.d.mts → types-Ba-BjVQG.d.mts} +5 -1
- package/dist/{types-BlN-U5AM.d.ts → types-DWARi8gF.d.ts} +5 -1
- package/package.json +3 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,51 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}}});var
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`&&
|
|
8
|
-
|
|
9
|
-
`);
|
|
2
|
+
var kn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Kl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Vl from"path";import{fileURLToPath as ql}from"url";var Yl,Ql,u,l=d(()=>{"use strict";Yl=()=>ql(import.meta.url),Ql=()=>Vl.dirname(Yl()),u=Ql()});function gt(t){vn.push(t)}function Zo(t){return[...Xl,...vn].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function ht(t){wn.push(t)}function ze(){return[...Zl,...wn]}function yt(t){En.push(t)}function Tn(){return[...ep,...En]}function Nn(t){Fn=t}function Pn(){return Fn}function xt(){vn.length=0,wn.length=0,En.length=0,Fn=es}var Xl,vn,Zl,wn,ep,En,es,Fn,be=d(()=>{"use strict";l();Xl=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],vn=[];Zl=[".test.",".spec.","-test.","-spec."],wn=[];ep=["jest","vitest","playwright","cypress","@testing-library/"],En=[];es=.8,Fn=es});import Dn from"fs";import ts from"path";function Se(t,{allowJs:e=!0,isExplicitPath:n=!1}={}){if(n){let r=ts.resolve(t);return Dn.existsSync(r)?r.endsWith(".json")?ns(r):e?rs(r):{}:{}}for(let r of tp){let o=ts.resolve(t,r);if(Dn.existsSync(o)){if(r.endsWith(".json"))return ns(o);if(e)return rs(o)}}return{}}function ns(t){return JSON.parse(Dn.readFileSync(t,"utf-8"))}function rs(t){let e=kn(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function Rn(t){xt();for(let e of t.configMatchers??[])gt(e);for(let e of t.testPatterns??[])ht(e);for(let e of t.testLibraries??[])yt(e);t.barrelThreshold!==void 0&&Nn(t.barrelThreshold)}function N(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases,additionalIgnoreDirs:t?.ignoreDirs}}var tp,In=d(()=>{"use strict";l();be();tp=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var Q,re,Ce,Be,A,An,j=d(()=>{"use strict";l();Q="mokosh-cache",re="duplication-tokens.json",Ce="graph.json",Be="branch-graphs",A=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__",".gradle","target"],An=[".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 jh from"fs";import Wh from"path";var os=d(()=>{"use strict";l()});var bt,ss=d(()=>{"use strict";l();bt={serialize(t){let e=["graph TD"],n=new Set;for(let r of t.nodes.values()){let o=`"${r.path}"`;for(let s of r.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${r.path} -> ${s.toPath}`;if(!n.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),n.add(a)}}}return e.join(`
|
|
3
|
+
`)}}});var is=d(()=>{"use strict";l();ss()});var ke,St=d(()=>{"use strict";l();ke=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let n=new Set(this.nodes.keys());return e.filter(r=>!n.has(r))}findHighExportUsage(e){let n=[];for(let r of this.nodes.values()){if(r.maxExportUsage===void 0||r.maxExportUsage<e)continue;let o=r.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);n.push({path:r.path,maxExportUsage:r.maxExportUsage,tightestDep:o?.toPath??""})}return n.sort((r,o)=>o.maxExportUsage-r.maxExportUsage)}findCycles(e={}){let n=new Set(e.includeKinds??[]),r=[],o=new Set,s=new Set,i=[],a=c=>{o.add(c),s.add(c),i.push(c);let p=this.nodes.get(c);if(p){for(let f of p.imports)if(!(!f.toPath||f.isExternal)&&!(f.isSamePackage&&!n.has("samePackage"))&&!(f.isDocReference&&!n.has("docReference")))if(s.has(f.toPath)){let m=i.indexOf(f.toPath);r.push([...i.slice(m),f.toPath])}else o.has(f.toPath)||a(f.toPath)}s.delete(c),i.pop()};for(let c of this.nodes.keys())o.has(c)||a(c);return r}}});import as from"fs";import rp from"path";function Mn(t,e){let n=t.replace(/^\.\//,"");if(e.nodes.has(n))return n;let r=n.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(r)?r:null}function cs(t,e){if(typeof t=="string")return Mn(t,e);if(t&&typeof t=="object"){let n=t;for(let r of["import","require","default"]){let o=cs(n[r],e);if(o)return o}}return null}function op(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 sp(t,e){let n=new Set,r=new Set,o=[...e];for(;o.length;){let s=o.shift();if(r.has(s))continue;r.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)n.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let f of p.exports)n.add(f.name);o.push(a.toPath)}else for(let p of a.symbols)n.add(p)}}}return n}function Ln(t,e){let n=[],r=rp.join(e,"package.json");if(as.existsSync(r))try{let o=JSON.parse(as.readFileSync(r,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=cs(s,t);i&&!n.includes(i)&&n.push(i)}else if(typeof o.exports=="string"){let s=Mn(o.exports,t);s&&n.push(s)}if(n.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Mn(s,t);i&&!n.includes(i)&&n.push(i)}}catch{}if(n.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){n.push(o);break}}return n}function ip(t,e){let n=new Set(e);for(let r of e)t.traverse(r,o=>(n.add(o.path),!0),{direction:"outgoing"});return n}function ap(t,e,n){let r=new Map;for(let o of e){if(n.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=r.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&r.set(a.name,{file:o,symbol:a})}}return r}function cp(t,e,n,r){let o=[];for(let s of t){let i=e.get(s),a=r.flatMap(m=>n.nodes.get(m)?.exports??[]).find(m=>m.name===s),c=i?.symbol??a,p=i?.file??r.find(m=>n.nodes.get(m)?.exports.some(h=>h.name===s))??r[0],f={name:s,definedIn:p,kind:op(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 lp(t,e,n){let r=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!n.includes(c)&&!r(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!r(c)),a=s.filter(c=>r(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function On(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 n=ip(t,e),r=ap(t,n,e),o=sp(t,e),s=cp(o,r,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=lp(t,n,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var _n=d(()=>{"use strict";l()});function Gn(t,e){let n=null,r=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(n=s.path);for(let i of s.callEdges??[])i.to===e&&r.push({file:s.path,callerFunction:i.from})}let o=[];if(n){let s=t.nodes.get(n);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:n,callers:r,callees:o}}var jn=d(()=>{"use strict";l()});import oy from"fs";import iy from"path";function ls(t){let e=[...t.nodes.entries()].sort(([r],[o])=>r.localeCompare(o)).map(([r,o])=>`${r}:${o.mtime}:${o.size}`).join("|"),n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function $n(t){let e=new Map;for(let n of t.nodes.keys()){let r=[];t.traverse(n,o=>(o.path!==n&&r.push(o.path),!0),{direction:"incoming"}),e.set(n,r)}return{impact:e,graphHash:ls(t)}}function Wn(t,e){return t.impact.get(e)??[]}var zn=d(()=>{"use strict";l()});var I,ve=d(()=>{"use strict";l();St();I=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let n=new Map;for(let r of e.nodes)n.set(r.path,r);return new t(n)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let n of this.nodes.values())for(let r of n.imports)if(r.toPath){let o=e.get(r.toPath)||[];o.push(n.path),e.set(r.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,n,r,o){let s=new Set,i=r.maxDepth??1/0,a=(c,p,f)=>{if(p>i||s.has(c))return;let m=this.nodes.get(c);if(m&&(s.add(c),n(m,p,f)!==!1))for(let h of o(c))a(h,p+1,c)};a(e,0,null)}traverse(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,n,r,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let n of this.nodes.values())for(let r of n.callEdges??[]){let o=e.get(r.toFile)??[];o.push(n.path),e.set(r.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,n,r={}){let o=r.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,n,r,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let n=[];return this.traverseCalls(e,r=>(r.path!==e&&n.push(r.path),!0),{direction:"incoming",maxDepth:1}),n}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let n=this.nodes.get(e);return n?n.imports.map(r=>this.nodes.get(r.toPath)).filter(r=>r!==void 0):[]}findUnusedFiles(e){return new ke(this.nodes).findUnusedFiles(e)}findCycles(e){return new ke(this.nodes).findCycles(e)}}});import He from"fs";import ps from"path";function Ct(t){return ps.join(t,Q,Be)}function fs(t,e){return ps.join(Ct(t),`${e}.json`)}function ms(t,e){let n=fs(t,e);if(!He.existsSync(n))return null;try{let r=He.readFileSync(n,"utf-8");return I.deserialize(JSON.parse(r))}catch{return null}}function us(t,e,n){let r=Ct(t);He.existsSync(r)||He.mkdirSync(r,{recursive:!0}),He.writeFileSync(fs(t,e),JSON.stringify(n.serialize()))}var ds=d(()=>{"use strict";l();j();ve()});import{execFileSync as Bn}from"child_process";function ys(t,e){let n="",r=0;for(let o of t.split(`
|
|
4
|
+
`)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");n=c??"",r=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,n,r)}}function xs(t){let e=new Map;try{let n=Bn("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${gs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:hs});ys(n,(r,o,s)=>{let i=e.get(r);if(i){i.commitCount90d+=1;return}e.set(r,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let n=Bn("git",["-C",t,"log","--name-status","-M",`--format=${gs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:hs});ys(n,(r,o,s)=>{e.has(r)||e.set(r,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var kt,gs,hs,Hn=d(()=>{"use strict";l();kt=class{getChangedFiles(e,n){try{let o=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"],...n?[["diff","--name-only","--end-of-options",`${n}...HEAD`]]:[]].flatMap(s=>{try{return Bn("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
+
`).map(a=>a.trim()).filter(a=>a!=="")}catch{return[]}});return Array.from(new Set(o))}catch(r){return console.error("Error getting git diff:",r),[]}}},gs="%x00%H%x09%ae%x09%at",hs=256*1024*1024});var Ue,Un=d(()=>{"use strict";l();Ue=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});import vt from"fs";import pp from"path";import{load as bs}from"js-yaml";function Ss(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function fp(t){return t.replace(/:$/,"").split(",").map(e=>{let n=e.trim();return n.startsWith('"')&&(n=n.slice(1)),n.endsWith('"')&&(n=n.slice(0,-1)),Ss(n)}).filter(Boolean)}function mp(t,e){let n=t.startsWith("/")?t.slice(1):t,r=n.lastIndexOf("@");return r>0?{name:n.substring(0,r),version:e||n.substring(r+1)}:{name:n,version:e}}function up(t){try{let e=bs(t),n={dependencies:{}};for(let[r,o]of Object.entries(e))if(!(r==="__metadata"||!o?.version))for(let s of r.split(", ")){let i=Ss(s);i&&(n.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return n}catch{return null}}function dp(t){let e={dependencies:{}};for(let n of t.split(/\n\n+/)){let r=n.split(`
|
|
6
|
+
`).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(r.length<2)continue;let o=r[0];if(!o||o.startsWith(" "))continue;let s=fp(o);if(s.length===0)continue;let a=r.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Cs(t){let e=vt.readFileSync(t,"utf-8"),n=JSON.parse(e),r={dependencies:{}};if(n.packages)for(let[o,s]of Object.entries(n.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(r.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies))r.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return r}function ks(t){let e=vt.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let n=up(e);if(n!==null)return n}return dp(e)}function vs(t){let e=vt.readFileSync(t,"utf-8"),n={dependencies:{}};try{let r=bs(e);if(r.packages)for(let[o,s]of Object.entries(r.packages)){let{name:i,version:a}=mp(o,s.version);i&&(n.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies)){if(n.dependencies[o])continue;let i=typeof s=="string"?s:s.version;n.dependencies[o]={version:i||""}}}catch{}return n}function Jn(t){for(let e of Ue){let n=pp.join(t,e);if(vt.existsSync(n))return gp[e](n)}return null}var gp,Kn=d(()=>{"use strict";l();Un();gp={"package-lock.json":Cs,"yarn.lock":ks,"pnpm-lock.yaml":vs}});function ws(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 hp(t){let e=t.trim();if(e.startsWith('"')||e.startsWith("'")){let a=ws(e).split(":");return a.length>=3&&a[0]&&a[2]?{group:a[0],version:a[2]}:null}if(!e.startsWith("{"))return null;let n=e.match(/module\s*=\s*["']([^"']+)["']/),r=e.match(/group\s*=\s*["']([^"']+)["']/),o=n?n[1].split(":")[0]:r?.[1];if(!o)return null;let s=e.match(/version\.ref\s*=\s*["']([^"']+)["']/)??e.match(/version\s*=\s*\{\s*ref\s*=\s*["']([^"']+)["']/),i=e.match(/version\s*=\s*["']([^"']+)["']/);return{group:o,...i?.[1]!==void 0&&{version:i[1]},...s?.[1]!==void 0&&{versionRef:s[1]}}}function Vn(t){let e=t.split(/\r?\n/).map(s=>s.replace(/#.*$/,"").trim()),n={},r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="versions"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=s.slice(0,a).trim(),p=ws(s.slice(a+1));c&&p&&(n[c]=p)}let o={};r="";for(let s of e){let i=s.match(/^\[([\w.-]+)\]$/);if(i){r=i[1];continue}if(r!=="libraries"||!s)continue;let a=s.indexOf("=");if(a===-1)continue;let c=hp(s.slice(a+1));if(!c)continue;let p=c.versionRef?n[c.versionRef]:c.version;p&&(o[c.group]=p)}return o}function qn(t){let e={};for(let n of t.split(/\r?\n/)){let r=n.trim();if(!r||r.startsWith("#")||r.startsWith("empty="))continue;let s=r.split("=")[0].split(":");s.length>=3&&s[0]&&s[2]&&(e[s[0]]=s[2])}return e}function Yn(t){let e={},n=/["']([\w.-]+):([\w.-]+):([\w.\-+]+)["']/g;for(let o=n.exec(t);o;o=n.exec(t)){let[,s,,i]=o;s&&i&&/\d/.test(i)&&(e[s]=i)}let r=/group:\s*["']([\w.-]+)["'][^\n)]*?version:\s*["']([\w.\-+]+)["']/g;for(let o=r.exec(t);o;o=r.exec(t))o[1]&&o[2]&&/\d/.test(o[2])&&(e[o[1]]=o[2]);return e}var Qn=d(()=>{"use strict";l()});function wt(t){let e={},n=/["']([\w.-]+)["']\s*%%?\s*["']([\w.-]+)["']\s*%\s*["']([\w.\-+]+)["']/g;for(let r=n.exec(t);r;r=n.exec(t)){let[,o,,s]=r;o&&s&&(e[o]=s)}return e}var Xn=d(()=>{"use strict";l()});import Tt from"fs";import Et from"path";function Je(t){try{return Tt.existsSync(t)?Tt.readFileSync(t,"utf-8"):null}catch{return null}}function Zn(t){let e={},n=f=>{for(let[m,h]of Object.entries(f))!e[m]&&h&&(e[m]=h)},r=Je(Et.join(t,"gradle","libs.versions.toml"));r&&n(Vn(r));let o=[],s=[],i=[],a=(f,m)=>{let h;try{h=Tt.readdirSync(f,{withFileTypes:!0})}catch{return}for(let y of h){let b=Et.join(f,y.name);if(y.isDirectory()){m<xp&&!y.name.startsWith(".")&&!yp.has(y.name)&&a(b,m+1);continue}y.isFile()&&(y.name==="gradle.lockfile"?o.push(b):y.name==="build.gradle"||y.name==="build.gradle.kts"?s.push(b):y.name==="build.sbt"&&i.push(b))}};a(t,0);for(let f of o){let m=Je(f);m&&n(qn(m))}for(let f of s){let m=Je(f);m&&n(Yn(m))}for(let f of i){let m=Je(f);m&&n(wt(m))}try{let f=Et.join(t,"project");for(let m of Tt.readdirSync(f,{withFileTypes:!0}))if(m.isFile()&&m.name.endsWith(".scala")){let h=Je(Et.join(f,m.name));h&&n(wt(h))}}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 yp,xp,er=d(()=>{"use strict";l();Qn();Xn();yp=new Set(["node_modules","build",".gradle","target",".git","dist"]),xp=2});function Es(t){let e=Jn(t),n=Zn(t);return n?{...e??{dependencies:{}},jvmDependencies:n}:e}var tr=d(()=>{"use strict";l();Kn();er();Qn();Kn();er();Xn();Un()});import Ts from"path";function B(t){switch(Ts.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 M(t){let e=Ts.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var X=d(()=>{"use strict";l()});function Z(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function we(t){let e=new Set,n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=n.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=n.exec(t);return e}function Ee(t,e){let n=t.toLowerCase();return n.includes(".test.")||n.includes(".spec.")||e.has("test")?"test":"logic"}var Ft=d(()=>{"use strict";l()});import bp from"coffeescript";function Ns(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return Z(t.value)}}function oe(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Sp(t,e){let n=Ns(e.source);return n?{fromPath:t,toPath:"",rawSpecifier:n,isStyle:M(n),type:"static"}:null}function Cp(t,e){let n=e.variable?.base?.value==="require",r=Ns(e.args?.[0]?.base);return!n||!r?null:{fromPath:t,toPath:"",rawSpecifier:r,isStyle:M(r),type:"require"}}function Fs(t,e){if(e)return[{name:e}];let n=t.value;if(n?.constructor?.name==="Class"){let o=oe(n.variable);return o?[{name:o}]:[]}if(n?.base?.constructor?.name==="Obj"&&Array.isArray(n.base.properties))return n.base.properties.map(o=>oe(o.variable)??oe(o)).filter(o=>!!o).map(o=>({name:o}));let r=oe(n);return r?[{name:r}]:[]}function kp(t){if(Array.isArray(t.specifiers))return t.specifiers.map(n=>n.identifier??n.original?.value).filter(n=>!!n).map(n=>({name:n}));let e=oe(t.variable)??oe(t.variable?.base);return e?[{name:e}]:[]}function vp(t,e,n,r){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=Sp(t,e);s&&n.push(s)}else if(o==="Call"){let s=Cp(t,e);s&&n.push(s)}else if(o==="Assign"){let s=oe(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?r.push(...Fs(e,void 0)):s==="exports"&&typeof i=="string"&&r.push(...Fs(e,i))}else o==="ExportNamedDeclaration"&&e.clause?r.push(...kp(e.clause)):o==="ExportDefaultDeclaration"&&r.push({name:"default"})}function nr(t,e,n,r){if(!(!e||typeof e!="object")){vp(t,e,n,r);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)nr(t,i,n,r);else nr(t,s,n,r)}}}function Ps(t,e){let n=we(e),r=Ee(t,n),o=[],s=[];try{nr(t,bp.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var Ds=d(()=>{"use strict";l();X();Ft()});function Te(t,e){Rs.set(t,e)}function Is(t){return Rs.get(t)}var Rs,Ke=d(()=>{"use strict";l();Rs=new Map});import{AstBuilder as wp,GherkinClassicTokenMatcher as Ep,Parser as Tp}from"@cucumber/gherkin";import{IdGenerator as Fp}from"@cucumber/messages";function rr(t,e){let n=new Set,r=o=>{for(let s of o)n.add(s.name.startsWith("@")?s.name.slice(1):s.name)};try{let o=new wp(Np),s=new Ep,a=new Tp(o,s).parse(e);if(a.feature){r(a.feature.tags);for(let c of a.feature.children){if(c.scenario){r(c.scenario.tags);for(let p of c.scenario.examples)r(p.tags)}if(c.rule)for(let p of c.rule.children)p.scenario&&r(p.scenario.tags)}}}catch(o){console.warn(`[GherkinParser] Failed to parse ${t}:`,o)}return{imports:[],exports:[],tags:Array.from(n).map(o=>({name:o,kind:"comment-marker"})),category:"test"}}var Np,As=d(()=>{"use strict";l();Ke();Np=Fp.uuid();Te("gherkin",rr)});function se(t){let e=[],n=t.firstChild;for(;n;)e.push(n),n=n.nextSibling;return e}function ie(t,e){let n=1;for(let r=0;r<e&&r<t.length;r++)t[r]===`
|
|
7
|
+
`&&n++;return n}var Nt=d(()=>{"use strict";l()});function Pp(t,e){let n=1;function r(o){switch(o.type.name){case"IfStatement":case"ForStatement":n++;break;case"Case":{o.firstChild?.type.name==="case"&&n++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&n++;break}}let s=o.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),n}function Ls(t,e,n,r){let o=n?1:1+e,s=se(t),i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Fe(a,i,!1,r));let c=s.find(f=>f.type.name==="Block");c&&(o+=Fe(c,i,!1,r));let p=s.findIndex(f=>f.type.name==="else");if(p>=0){let f=s[p+1];f?.type.name==="IfStatement"?o+=Ls(f,e,!0,r):f&&(o+=1+Fe(f,e+1,!1,r))}return o}function Ms(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Fe(o,e+1,!1,n),o=o.nextSibling;return r}function Dp(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Fe(o,e,!1,n),o=o.nextSibling;return r}function Rp(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Fe(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return Ls(t,e,n,r);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return Ms(t,e,r);let s=o==="LogicOp"&&Rp(t,r)?1:0;return e>0&&o==="FunctionLiteral"?s+Ms(t,e,r):s+Dp(t,e,r)}function Ip(t,e){return Fe(t,0,!1,e)}function Pt(t,e){return{complexity:Pp(t,e),cognitiveComplexity:Ip(t,e)}}function or(t,e){let r=t.getChild("Parameters")?.getChild("Parameter"),o=r?.getChild("TypeName")??r?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function Os(t,e){let n=[],r=t.cursor();do if(r.name==="FunctionDecl"){let o=r.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=Pt(r.node,e);n.push({name:s,line:ie(e,r.from),complexity:i,cognitiveComplexity:a})}}else if(r.name==="MethodDecl"){let o=r.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=or(r.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=Pt(r.node,e);n.push({name:a,line:ie(e,r.from),complexity:c,cognitiveComplexity:p})}}while(r.next());return n}var _s=d(()=>{"use strict";l();Nt()});import Ap from"path";import{parser as Mp}from"@lezer/go";function js(t,e){let n=[],r=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 C=e.slice(c.from,c.to),E=C.match(Lp);E?.[1]&&o.add(E[1]);let G=C.match(Op);G&&Gs(G[1],s);let S=C.match(_p);S&&Gs(S[1],s);break}case"ImportSpec":{let C=c.node.getChild("String");if(C){let G=e.slice(C.from,C.to).slice(1,-1);n.push({fromPath:t,toPath:"",rawSpecifier:G,isExternal:!0,isStyle:!1,type:"static"});let S=c.node.getChild("DefName"),F=S?e.slice(S.from,S.to):G.split("/").pop();F&&F!=="_"&&F!=="."&&i.set(F,G)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let C=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(C){let E=e.slice(C.from,C.to);E!=="_"&&/^[A-Z]/.test(E)&&!r.has(E)&&r.set(E,{name:E})}break}}while(c.next());let p=n.some(C=>C.rawSpecifier==="testing"),f=Ap.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",m=new Set([...o,...s]),{complexity:h,cognitiveComplexity:y}=Pt(a.topNode,e),b=Os(a,e),v=f==="test"?[]:Gp(a,e,i);return{imports:n,exports:Array.from(r.values()),tags:Array.from(m).map(C=>({name:C,kind:"comment-marker"})),category:f,rawCallEdges:v,complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{}}}function Gp(t,e,n){let r=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let f=p.firstChild,m=p.getChild("FieldName");if(f?.type.name==="VariableName"&&m){let h=e.slice(f.from,f.to),y=n.get(h);if(y){let b=e.slice(m.from,m.to);r.push({from:a,to:b,toSpecifier:y})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=or(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return r}function Gs(t,e){for(let n of t.split(/[\s,&|!()]+/)){let r=n.trim();r&&r!=="ignore"&&e.add(r)}}var Lp,Op,_p,$s=d(()=>{"use strict";l();_s();Lp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Op=/^\/\/go:build\s+(.+)$/,_p=/^\/\/\s*\+build\s+(.+)$/});function ir(t){let e=t.replace(/\.\w+$/,"");return zp.test(e)}function Ne(t){let e=new Set;for(let n of t.matchAll(jp))n[1]&&e.add(n[1]);return e}function ee(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,n=>n.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,n=>" ".repeat(n.length)),e}function Pe(t){let e=ee(t),n=new Set;for(let o of e.matchAll(/@([A-Z]\w*)/g))o[1]&&n.add(o[1]);let r=new Set;for(let o of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))o[1]&&r.add(o[1]);return{annotations:[...n],typeNames:[...r]}}function De(t,e){return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static"}}function te(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect",isSamePackage:!0}}function $(t,e){let n=[];for(let r of ee(t).split(`
|
|
8
|
+
`)){let o=r.trim();if(!o||o.startsWith("@")||o.startsWith("*"))continue;let s=o.match(/^package\s+(?:object\s+)?([\w.]+)/);if(s?.[1]){if(n.push(s[1]),!e)break;continue}if(!(e&&/^import\s/.test(o)))break}return n.length>0?n.join("."):null}function H(t,e,n={}){let r=t.replace(/\\/g,"/"),o=r.split("/").pop()??"";if(o.endsWith(".gradle")||o==="build.gradle.kts"||o==="settings.gradle.kts")return"config";if(Wp.test(r)||e.some(i=>$p.some(a=>i===a||i.startsWith(`${a}.`))))return"test";let s=n.annotations??[];return s.some(i=>Bp.has(i))?"config":s.some(i=>Hp.has(i))||(n.typeNames??[]).some(i=>Jp.some(a=>i.endsWith(a)))?"ui":s.some(i=>Up.has(i))?"logic":ir(o)?"test":"logic"}var jp,$p,sr,Wp,zp,Bp,Hp,Up,Jp,Re=d(()=>{"use strict";l();jp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,$p=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework","org.testng","org.assertj","com.google.truth","org.hamcrest","io.mockk","com.nhaarman.mockitokotlin2"],sr=["test","androidTest","integrationTest","it"],Wp=new RegExp(`/src/(${sr.join("|")})/`),zp=/(?:Test|Tests|Spec|IT|ITCase)$/;Bp=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Hp=new Set(["Composable","Preview"]),Up=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Jp=["Activity","Fragment","ViewModel","Screen","Composable"]});function qp(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function Ws(t,e){let n=Ne(e),o=ee(e).split(`
|
|
9
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(Kp);if(f?.[2]){let h=qp(!!f[1],f[2]);h&&s.push(De(t,h));continue}let m=p.match(Vp);m?.[2]&&i.add(m[2])}let a=$(e,!1);a&&s.push(te(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:H(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:Pe(e).annotations})}}var Kp,Vp,zs=d(()=>{"use strict";l();Re();Kp=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Vp=/^(?:@\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 Qp(t,e){let n=1;function r(o){let s=o.type.name;if(s==="IfStatement"||s==="CatchClause"||s==="TernaryExpression")n++;else if(Bs.has(s))n++;else if(s==="SwitchLabel")o.firstChild?.type.name==="case"&&n++;else if(s==="LogicOp"){let a=e.slice(o.from,o.to);(a==="&&"||a==="||")&&n++}let i=o.firstChild;for(;i;)r(i),i=i.nextSibling}return r(t),n}function Hs(t,e,n,r){let o=n?1:1+e,s=[];for(let f=t.firstChild;f;f=f.nextSibling)s.push(f);let i=n?e:e+1,a=s[1];a&&a.type.name!=="Block"&&(o+=Ie(a,i,!1,r));let c=s.find(f=>f.type.name==="Block");c&&(o+=Ie(c,i,!1,r));let p=s.findIndex(f=>f.type.name==="else");if(p>=0){let f=s[p+1];f?.type.name==="IfStatement"?o+=Hs(f,e,!0,r):f&&(o+=1+Ie(f,e+1,!1,r))}return o}function ar(t,e,n){let r=1+e,o=t.firstChild;for(;o;)r+=Ie(o,e+1,!1,n),o=o.nextSibling;return r}function Xp(t,e,n){let r=0,o=t.firstChild;for(;o;)r+=Ie(o,e,!1,n),o=o.nextSibling;return r}function Zp(t,e){let n=e.slice(t.from,t.to);return n==="&&"||n==="||"}function Ie(t,e,n,r){let o=t.type.name;if(o==="IfStatement")return Hs(t,e,n,r);if(Bs.has(o)||o==="SwitchStatement"||o==="CatchClause"||o==="TernaryExpression")return ar(t,e,r);let s=o==="LogicOp"&&Zp(t,r)?1:0;return e>0&&o==="LambdaExpression"?s+ar(t,e,r):s+Xp(t,e,r)}function ef(t,e){return Ie(t,0,!1,e)}function cr(t,e){return{complexity:Qp(t,e),cognitiveComplexity:ef(t,e)}}function lr(t,e){for(let n=t.parent;n;n=n.parent)if(Yp.has(n.type.name)){let r=n.getChild("Definition");if(r)return e.slice(r.from,r.to)}}function Us(t,e){let n=[],r=t.cursor();do if(r.name==="MethodDeclaration"||r.name==="ConstructorDeclaration"){let o=r.node.getChild("Definition");if(o){let s=e.slice(o.from,o.to),i=lr(r.node,e),a=i&&r.name==="MethodDeclaration"?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=cr(r.node,e);n.push({name:a,line:ie(e,r.from),complexity:c,cognitiveComplexity:p})}}while(r.next());return n}var Bs,Yp,Js=d(()=>{"use strict";l();Nt();Bs=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Yp=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"])});import{parser as tf}from"@lezer/java";function rf(t,e){let n=t.getChild("ScopedIdentifier");if(!n)return null;let r=t.getChild("static")!=null,o=t.getChild("Asterisk")!=null,s=e.slice(n.from,n.to);return r?(o||(s=s.split(".").slice(0,-1).join(".")),s?{specifier:s,wildcard:!1}:null):o?{specifier:`${s}.*`,wildcard:!0}:{specifier:s,wildcard:!1}}function of(t){let e=new Map;for(let n of t){if(n.type==="side-effect")continue;let r=n.rawSpecifier;if(r.endsWith(".*"))continue;let o=r.split(".").pop();o&&e.set(o,r)}return e}function sf(t,e){let n=t;if(n.name==="GenericType"&&(n=n.firstChild),!n)return null;if(n.name==="TypeName")return e.slice(n.from,n.to);if(n.name==="ScopedTypeName"){let r=null;for(let o=n.firstChild;o;o=o.nextSibling)o.name==="TypeName"&&(r=o);return r?e.slice(r.from,r.to):null}return null}function af(t,e,n){let r=[];function o(i,a){let c=i.type.name;if(c==="MethodInvocation"){let f=i.firstChild;if(f?.type.name==="Identifier"){let m=n.get(e.slice(f.from,f.to)),h=i.getChild("MethodName");m&&h&&r.push({from:a,to:e.slice(h.from,h.to),toSpecifier:m})}}else if(c==="ObjectCreationExpression"){let f=i.getChild("TypeName")??i.getChild("GenericType")??i.getChild("ScopedTypeName"),m=f&&sf(f,e);if(m){let h=n.get(m);h&&r.push({from:a,to:"new",toSpecifier:h})}}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=lr(s.node,e),f=p&&s.name==="MethodDeclaration"?`${p}.${c}`:c;o(a,f)}}while(s.next());return r}function Ks(t,e){let n=[],r=new Map,o=new Set,s=new Set,i;try{i=tf.parse(e)}catch{return{imports:[],exports:[],tags:[],category:H(t,[])}}let a=i.cursor();do switch(a.name){case"LineComment":{let b=e.slice(a.from,a.to).match(nf);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=rf(a.node,e);b&&n.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 v=e.slice(b.from,b.to);r.has(v)||r.set(v,{name:v})}}break}}while(a.next());let c=$(e,!1);c&&n.push(te(t,c));let p=H(t,n.map(b=>b.rawSpecifier),{typeNames:[...r.keys()],annotations:[...s]}),{complexity:f,cognitiveComplexity:m}=cr(i.topNode,e),h=Us(i,e),y=p==="test"?[]:af(i,e,of(n));return{imports:n,exports:Array.from(r.values()),tags:Array.from(o).map(b=>({name:b,kind:"comment-marker"})),category:p,rawCallEdges:y,complexity:f,cognitiveComplexity:m,...h.length>0?{functions:h}:{}}}var nf,Vs=d(()=>{"use strict";l();Js();Re();nf=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/});function qs(t,e){let n=Ne(e),o=ee(e).split(`
|
|
10
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(cf);if(f?.[1]){s.push(De(t,f[1]));continue}let m=p.match(lf);if(m?.[2]){i.add(m[2]);continue}let h=p.match(pf);if(h?.[1]){i.add(h[1]);continue}let y=p.match(ff);y?.[1]&&i.add(y[1])}let a=$(e,!1);a&&s.push(te(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:H(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:Pe(e).annotations})}}var cf,pr,lf,pf,ff,Ys=d(()=>{"use strict";l();Re();cf=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,pr="(?: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+)*",lf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),pf=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),ff=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${pr}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`)});import mf from"livescript";function ae(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function uf(t){if(!t)return[];if(t.constructor?.name==="Class"){let n=ae(t.title);return n?[{name:n}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(n=>ae(n.key)??ae(n.val)).filter(n=>!!n).map(n=>({name:n}));let e=ae(t);return e?[{name:e}]:[]}function df(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let n=t.left,r=ae(n.head),s=n.tails?.[0]?.key?.name;if(r==="module"&&s==="exports")return uf(t.right);if(r==="exports"&&typeof s=="string")return[{name:s}];if(n.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let n=t.right;if(n?.constructor?.name==="Obj"&&Array.isArray(n.items))return n.items.map(r=>ae(r.val)??ae(r.key)).filter(r=>!!r).map(r=>({name:r}))}return[]}function hf(t,e){let n=t.constructor?.name||t.type;if(n==="Import"){let r=t.right?.value;if(typeof r=="string"){let o=Z(r);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:M(o),type:"static"}}}if(n==="Chain"&&t.head?.value==="require"){let r=t.tails?.[0];if(r?.constructor?.name==="Call"||r?.type==="Call"){let o=r.args?.[0]?.value;if(typeof o=="string"){let s=Z(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:M(s),type:"require"}}}}return null}function fr(t,e,n){if(!t||typeof t!="object")return[];let r=[],o=hf(t,e);o&&r.push(o),n.push(...df(t));for(let s in t){if(gf.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)r.push(...fr(a,e,n));else r.push(...fr(i,e,n))}return r}function Qs(t,e){let n=we(e),r=Ee(t,n),o=[],s=[];try{o=fr(mf.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:r}}var gf,Xs=d(()=>{"use strict";l();X();Ft();gf=new Set(["first_line","first_column","last_line","last_column","line","column"])});import yf from"luaparse";function xf(t,e){let n=[];function r(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=Z(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=Z(i.raw))}s&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:M(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)r(a);else r(i)}}}return r(t),n}function bf(t){let e=new Set;for(let n of t)n.type==="LocalStatement"&&n.variables.forEach((r,o)=>{n.init[o]?.type==="TableConstructorExpression"&&e.add(r.name)});return e}function Sf(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let n=e.arguments[0];if(n?.type!=="TableConstructorExpression")return[];let r=[];for(let o of n.fields)o.type==="TableKeyString"&&r.push({name:o.key.name});return r}function Cf(t){let e=t.body,n=bf(e),r=Sf(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&n.has(s.identifier.base.name)&&r.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&r.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&n.has(i.base.name)&&r.push({name:i.identifier.name});let o=new Set;return r.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Zs(t,e){let n=we(e),r=Ee(t,n),o=[],s=[];try{let i=yf.parse(e);o=xf(i,t),s=Cf(i)}catch{}return{imports:o,exports:s,tags:Array.from(n).map(i=>({name:i,kind:"comment-marker"})),category:r}}var ei=d(()=>{"use strict";l();X();Ft()});async function Ef(){return ti??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),ti}function Tf(t){let e=t.trim();return e.length===0||e.startsWith("#")||kf.some(n=>e.startsWith(n))}function Ff(t,e){let n=t.match(wf);return n?n.map(r=>({fromPath:e,toPath:"",rawSpecifier:r,isStyle:!1,type:"static",isDocReference:!0})):[]}function ni(t,e,n){if(t.type==="link"&&typeof t.url=="string"&&!Tf(t.url)&&n.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static",isDocReference:!0}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&n.push(...Ff(t.value,e)),Array.isArray(t.children))for(let r of t.children)ni(r,e,n)}async function ri(t,e){let r=(await Ef()).parse(e),o=[];ni(r,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var kf,vf,wf,ti,oi=d(()=>{"use strict";l();kf=["http://","https://","mailto:","//"],vf="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",wf=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${vf})\\b`,"g")});function Nf(t){let e=1;function n(r){switch(r.type.name){case"IfStatement":{e+=se(r).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=se(r).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=r.firstChild;for(;o;)n(o),o=o.nextSibling}return n(t),e}function Pf(t,e){let n=0,r=se(t),o=0,s=0;for(;s<r.length;){let i=r[s];if(i?.type.name==="if"||i?.type.name==="elif"){let a=o>0;n+=a?1:1+e;let c=a?e:e+1,p=r[s+1],f=r[s+2];p&&(n+=U(p,c)),f&&(n+=U(f,c)),o++,s+=3}else if(i?.type.name==="else"){n+=1;let a=r[s+1];a&&(n+=U(a,e+1)),s+=2}else s++}return n}function Df(t,e){let n=0,r=se(t),o=0;for(;o<r.length;){let s=r[o];if(s?.type.name==="except"){for(n+=1+e,o++;o<r.length&&r[o]?.type.name!=="Body";)n+=U(r[o],e),o++;o<r.length&&(n+=U(r[o],e),o++)}else s?.type.name==="Body"&&(n+=U(s,e)),o++}return n}function si(t,e){let n=1+e,r=t.firstChild;for(;r;)n+=U(r,e+1),r=r.nextSibling;return n}function Rf(t,e){let n=0,r=t.firstChild;for(;r;)n+=U(r,e),r=r.nextSibling;return n}function U(t,e){let n=t.type.name;switch(n){case"IfStatement":return Pf(t,e);case"TryStatement":return Df(t,e);case"ForStatement":case"WhileStatement":return si(t,e);default:{let r=n==="ConditionalExpression"||n==="and"||n==="or"?1:0;return e>0&&(n==="FunctionDefinition"||n==="LambdaExpression")?r+si(t,e):r+Rf(t,e)}}}function If(t){return U(t,0)}function mr(t){return{complexity:Nf(t),cognitiveComplexity:If(t)}}function ii(t,e){let n=[];function r(i,a){let{complexity:c,cognitiveComplexity:p}=mr(i);n.push({name:a,line:ie(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 m=f.getChild("VariableName"),h=m?e.slice(m.from,m.to):void 0;h&&r(f,c?`${c}.${h}`:h),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&r(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),n}var ai=d(()=>{"use strict";l();Nt()});import Af from"path";import{parser as Mf}from"@lezer/python";function ci(t,e){let n=[],r=[],o=new Set,s=Af.basename(t).toLowerCase(),i=Mf.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let y=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);y?.[1]&&o.add(y[1]);break}case"ImportStatement":{for(let y of Of(a.node,e,t))n.push(y);break}case"FunctionDefinition":case"ClassDefinition":{let y=a.node.parent;if(y?.name==="Script"||y?.name==="DecoratedStatement"&&y.parent?.name==="Script"){let v=a.node.getChild("VariableName");v&&r.push({name:e.slice(v.from,v.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let y=a.node.firstChild;y?.name==="VariableName"&&r.push({name:e.slice(y.from,y.to)})}break}}while(a.next());let c=zf(s,n,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=mr(i.topNode),m=ii(i,e),h=c==="test"?[]:Wf(i,e);return{imports:n,exports:r,tags:Array.from(o).map(y=>({name:y,kind:"comment-marker"})),category:c,rawCallEdges:h,complexity:p,cognitiveComplexity:f,...m.length>0?{functions:m}:{}}}function Of(t,e,n){let r=t.firstChild;return r?r.name==="from"?_f(t,e,n):Gf(t,e,n):[]}function _f(t,e,n){let r=t.firstChild;if(!r)return[];let o=r.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(r.to,o.from).trim(),i=jf(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[Ve(n,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[Ve(n,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[Ve(n,p.slice(0,-1),["*"],!1)]:i.map(f=>Ve(n,p+f,[f],!1))}function Gf(t,e,n){let r=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),r.push(Ve(n,s,["*"],!0))}o=o.nextSibling}return r}function jf(t,e){let n=[],r=t;for(;r;)r.name==="*"?n.push("*"):r.name==="VariableName"&&(n.push(e.slice(r.from,r.to)),r.nextSibling?.name==="as"&&(r=r.nextSibling.nextSibling??r.nextSibling)),r=r.nextSibling;return n}function $f(t,e){let n=new Map,r=t.cursor();do{if(r.name!=="ImportStatement")continue;let s=r.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),m=i.nextSibling;for(;m;){if(m.type.name==="VariableName"){let h=e.slice(m.from,m.to),y=h;if(m.nextSibling?.type.name==="as"){let v=m.nextSibling.nextSibling;v?.type.name==="VariableName"&&(y=e.slice(v.from,v.to),m=v)}let b=c===0?a:p?f+p.replace(/\./g,"/"):f+h;n.set(y,b)}m=m.nextSibling}}while(r.next());return n}function Wf(t,e){let n=$f(t,e),r=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,m=e.slice(f.from,f.to),h=n.get(m);h&&r.push({from:c,to:m,toSpecifier:h})}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 m=f.firstChild;for(;m;){if(m.type.name==="FunctionDefinition"){let h=m.getChild("VariableName"),y=h?e.slice(h.from,h.to):void 0;y&&o(m,p?`${p}.${y}`:y)}else i(m);m=m.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),r}function Ve(t,e,n,r){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:r,type:"static",symbols:n.length>0?n:void 0}}function zf(t,e,n){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":n.has("test")||e.some(r=>Lf.has(r.rawSpecifier))?"test":"logic"}var Lf,li=d(()=>{"use strict";l();ai();Lf=new Set(["pytest","unittest","nose","hypothesis"])});function Uf(t,e){let n=e.split("=>")[0]?.trim();return n?n==="_"||n==="*"||n==="given"?`${t}.*`:`${t}.${n}`:null}function Jf(t){let e=t.indexOf("{");if(e!==-1){let r=t.indexOf("}",e),o=t.slice(0,e).trim().replace(/\.$/,""),s=t.slice(e+1,r===-1?void 0:r);return o?s.split(",").map(i=>Uf(o,i.trim())).filter(i=>i!=null):[]}let n=[];for(let r of t.split(",")){let o=r.trim().replace(/\s+as\s+\w+$/,"");if(o)if(o.endsWith("._")||o.endsWith(".*")||o.endsWith(".given")){let s=o.replace(/\.(_|\*|given)$/,"");s&&n.push(`${s}.*`)}else n.push(o)}return n}function pi(t,e){let n=Ne(e),o=ee(e).split(`
|
|
11
|
+
`),s=[],i=new Set;for(let p of o){let f=p.match(Bf);if(f?.[1]){for(let h of Jf(f[1]))s.push(De(t,h));continue}let m=p.match(Hf);m?.[2]&&i.add(m[2])}let a=$(e,!0);a&&s.push(te(t,a));let c=Array.from(i,p=>({name:p}));return{imports:s,exports:c,tags:Array.from(n).map(p=>({name:p,kind:"comment-marker"})),category:H(t,s.map(p=>p.rawSpecifier),{typeNames:[...i],annotations:Pe(e).annotations})}}var Bf,Hf,fi=d(()=>{"use strict";l();Re();Bf=/^\s*import\s+(.+?)\s*$/,Hf=/^(?:@\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 k from"typescript";function Kf(t){let e=1;function n(r){switch(r.kind){case k.SyntaxKind.IfStatement:case k.SyntaxKind.ConditionalExpression:case k.SyntaxKind.ForStatement:case k.SyntaxKind.ForInStatement:case k.SyntaxKind.ForOfStatement:case k.SyntaxKind.WhileStatement:case k.SyntaxKind.DoStatement:case k.SyntaxKind.CatchClause:case k.SyntaxKind.CaseClause:e++;break;case k.SyntaxKind.BinaryExpression:{let o=r.operatorToken.kind;(o===k.SyntaxKind.AmpersandAmpersandToken||o===k.SyntaxKind.BarBarToken||o===k.SyntaxKind.QuestionQuestionToken)&&e++;break}}k.forEachChild(r,n)}return n(t),e}function ui(t,e,n){let r=n?1:1+e,o=n?e:e+1;return r+=ce(t.expression,o,!1),r+=ce(t.thenStatement,o,!1),t.elseStatement&&(k.isIfStatement(t.elseStatement)?r+=ui(t.elseStatement,e,!0):r+=1+ce(t.elseStatement,e+1,!1)),r}function mi(t,e){let n=1+e;return k.forEachChild(t,r=>{n+=ce(r,e+1,!1)}),n}function Vf(t,e){let n=1+e;return k.forEachChild(t,r=>{n+=ce(r,e,!1)}),n}function qf(t,e){let n=0;return k.forEachChild(t,r=>{n+=ce(r,e,!1)}),n}function Yf(t){let e=t.operatorToken.kind;return e===k.SyntaxKind.AmpersandAmpersandToken||e===k.SyntaxKind.BarBarToken||e===k.SyntaxKind.QuestionQuestionToken}function ce(t,e,n){if(k.isIfStatement(t))return ui(t,e,n);if(k.isForStatement(t)||k.isForInStatement(t)||k.isForOfStatement(t)||k.isWhileStatement(t)||k.isDoStatement(t)||k.isSwitchStatement(t))return mi(t,e);if(k.isCatchClause(t))return Vf(t,e);let r=0;return k.isConditionalExpression(t)&&(r+=1),k.isBinaryExpression(t)&&Yf(t)&&(r+=1),e>0&&(k.isFunctionDeclaration(t)||k.isFunctionExpression(t)||k.isArrowFunction(t))?r+mi(t,e):r+qf(t,e)}function Qf(t){return ce(t,0,!1)}function ur(t){return{complexity:Kf(t),cognitiveComplexity:Qf(t)}}var di=d(()=>{"use strict";l()});import T from"typescript";function gi(t,e){Xf(t,e),em(t,e),tm(t,e),nm(t,e)}function Xf(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Zf(t)){let n;if(T.isFunctionDeclaration(t))n="function";else{let r=t.initializer;n=r&&(T.isArrowFunction(r)||T.isFunctionExpression(r))?"function":"variable"}e.tags.add({name:t.name.text,kind:n})}}function Zf(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function em(t,e){if(!T.isStringLiteral(t))return;let n=t.text.match(/@[\w-]+/g);if(n)for(let r of n)e.tags.add({name:r.substring(1),kind:"comment-marker"})}function tm(t,e){if(!T.isSourceFile(t))return;let n=/@tag\s+([a-zA-Z0-9_-]+)/g,r=t.getFullText(),o=n.exec(r);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=n.exec(r)}function nm(t,e){if(T.isCallExpression(t)&&rm(t.expression))for(let n of t.arguments)T.isObjectLiteralExpression(n)&&om(n,e)}function rm(t){return T.isIdentifier(t)?dr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(dr.has(t.name.text)||T.isIdentifier(t.expression)&&dr.has(t.expression.text)))}function om(t,e){for(let n of t.properties){if(!T.isPropertyAssignment(n)||!T.isIdentifier(n.name)||n.name.text!=="tags"&&n.name.text!=="tag")continue;let{initializer:r}=n,o=T.isArrayLiteralExpression(r)?r.elements.filter(T.isStringLiteral):n.name.text==="tag"&&T.isStringLiteral(r)?[r]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var dr,hi=d(()=>{"use strict";l();dr=new Set(["test","describe","it"])});import yi from"path";import x from"typescript";function gr(t,e,n){let r=[],o=new Map,s=new Set,i=x.createSourceFile(t,e,x.ScriptTarget.Latest,!0,n==="typescript"?x.ScriptKind.TSX:x.ScriptKind.JSX),a={filePath:t,imports:r,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=v=>{cm(v,a),x.forEachChild(v,c)};c(i);let p=bm(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&Sm(a,i);let f=i.statements[0],m=f?bi(f):void 0,{complexity:h,cognitiveComplexity:y}=ur(i),b=sm(i);return{imports:r,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:y,...b.length>0?{functions:b}:{},...m!==void 0?{description:m}:{}}}function sm(t){let e=[],n=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=ur(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},r=(o,s)=>{if(x.isFunctionDeclaration(o)&&o.name&&o.body?n(o.name.text,o):x.isVariableDeclaration(o)&&x.isIdentifier(o.name)&&o.initializer&&(x.isArrowFunction(o.initializer)||x.isFunctionExpression(o.initializer))?n(o.name.text,o.initializer):s&&x.isMethodDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.${o.name.text}`,o):s&&x.isConstructorDeclaration(o)&&o.body?n(`${s}.constructor`,o):s&&x.isGetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body?n(`${s}.get ${o.name.text}`,o):s&&x.isSetAccessorDeclaration(o)&&x.isIdentifier(o.name)&&o.body&&n(`${s}.set ${o.name.text}`,o),x.isClassDeclaration(o)&&o.name){let i=o.name.text;x.forEachChild(o,a=>r(a,i));return}x.forEachChild(o,i=>r(i,s))};return r(t,void 0),e}function xi(t,e,n,r){let o={name:t},s=bi(n);s!==void 0&&(o.doc=s);let i=im(e);i!==void 0&&(o.flags=i);let a=am(e,r);return a!==void 0&&(o.signature=a),o}function bi(t){let e=x.getJSDocCommentsAndTags(t);for(let n of e)if(x.isJSDoc(n)&&n.comment)return x.getTextOfJSDocComment(n.comment)||void 0}function im(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),n=x.getJSDocTags(t).map(r=>r.tagName.text).filter(r=>e.has(r));return n.length>0?n:void 0}function am(t,e){let n=x.createPrinter({removeComments:!0}),r=o=>n.printNode(x.EmitHint.Unspecified,o,e);if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)){let o=t.parameters.map(r).join(", "),s=t.type?r(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(x.isVariableDeclaration(t)){if(t.type)return r(t.type);if(t.initializer&&(x.isArrowFunction(t.initializer)||x.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(r).join(", "),i=o.type?r(o.type):"unknown";return`(${s}) => ${i}`}return}if(x.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(x.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(x.isTypeAliasDeclaration(t))return r(t.type);if(x.isEnumDeclaration(t))return`enum ${t.name.text}`}function cm(t,e){lm(t,e),pm(t,e),mm(t,e),um(t,e),xm(t,e),gi(t,e)}function lm(t,e){if(!x.isSourceFile(t))return;let n=t.statements.filter(r=>!x.isEmptyStatement(r));e.totalStatements=n.length,e.exportStatements=n.filter(r=>x.isExportDeclaration(r)||x.isExportAssignment(r)||hr(r)).length}function pm(t,e){if(x.isJsxElement(t)||x.isJsxSelfClosingElement(t)||x.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(x.isFunctionDeclaration(t)||x.isMethodDeclaration(t)||x.isArrowFunction(t)||x.isClassDeclaration(t)||x.isVariableStatement(t)||x.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}x.isExportDeclaration(t)&&!fm(t)&&(e.hasTypesOnly=!1)}function fm(t){return t.isTypeOnly?!0:!t.exportClause||!x.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function mm(t,e){if(!x.isImportDeclaration(t)||!t.moduleSpecifier||!x.isStringLiteral(t.moduleSpecifier))return;let n=[];if(t.importClause&&(t.importClause.name&&n.push("default"),t.importClause.namedBindings))if(x.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)n.push(o.name.text);else x.isNamespaceImport(t.importClause.namedBindings)&&n.push("*");let r=n.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:M(t.moduleSpecifier.text),type:r,symbols:n.length>0?n:void 0})}function um(t,e){x.isExportDeclaration(t)?dm(t,e):x.isExportAssignment(t)?e.exports.set("default",{name:"default"}):hr(t)&&ym(t,e)}function dm(t,e){if(t.moduleSpecifier&&x.isStringLiteral(t.moduleSpecifier))gm(t,t.moduleSpecifier.text,e);else if(t.exportClause&&x.isNamedExports(t.exportClause))for(let n of t.exportClause.elements){let r=n.name.text;e.exports.set(r,{name:r})}}function gm(t,e,n){let r=hm(t),o={fromPath:n.filePath,toPath:"",rawSpecifier:e,isStyle:M(e),type:"re-export"};r.length>0&&(o.symbols=r),n.imports.push(o)}function hm(t){return t.exportClause?x.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ym(t,e){if((x.isFunctionDeclaration(t)||x.isClassDeclaration(t)||x.isInterfaceDeclaration(t)||x.isTypeAliasDeclaration(t)||x.isEnumDeclaration(t))&&t.name){let r=t.name.text;e.exports.set(r,xi(r,t,t,e.sourceFile));return}if(x.isVariableStatement(t)){for(let r of t.declarationList.declarations)if(x.isIdentifier(r.name)){let o=r.name.text;e.exports.set(o,xi(o,r,t,e.sourceFile))}}}function xm(t,e){if(!x.isCallExpression(t))return;let n=t.arguments[0];!n||!x.isStringLiteral(n)||(t.expression.kind===x.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:M(n.text),type:"dynamic"}):x.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:n.text,isStyle:M(n.text),type:"require"}))}function bm(t,e){let n=yi.basename(t).toLowerCase(),r=yi.extname(t).toLowerCase();return ze().some(s=>n.includes(s))?"test":Zo(n)?"config":e.imports.some(s=>Tn().some(i=>s.rawSpecifier.includes(i)))?"test":r===".tsx"||r===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Pn()?"barrel":"logic"}function hr(t){return x.canHaveModifiers(t)&&x.getModifiers(t)?.some(e=>e.kind===x.SyntaxKind.ExportKeyword)===!0}function Sm(t,e){let n=t.rawCallEdges??[];t.rawCallEdges=n;let r=new Map;for(let o of e.statements){if(!x.isImportDeclaration(o)||!x.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&r.set(i.name.text,s),i.namedBindings&&x.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)r.set(a.name.text,s)}if(r.size!==0)for(let o of e.statements){let s=km(o);if(s){let i=vm(o);i&&Dt(i,s,r,n);continue}x.isClassDeclaration(o)&&o.name&&Cm(o,o.name.text,r,n)}}function Cm(t,e,n,r){for(let o of t.members)x.isMethodDeclaration(o)&&o.body&&x.isIdentifier(o.name)?Dt(o.body,`${e}.${o.name.text}`,n,r):x.isConstructorDeclaration(o)&&o.body&&Dt(o.body,`${e}.constructor`,n,r)}function km(t){if(hr(t)){if(x.isFunctionDeclaration(t)&&t.name)return t.name.text;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(x.isIdentifier(e.name)&&e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.name.text}}}function vm(t){if(x.isFunctionDeclaration(t))return t.body;if(x.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(x.isArrowFunction(e.initializer)||x.isFunctionExpression(e.initializer)))return e.initializer}}function Dt(t,e,n,r){if(x.isCallExpression(t)&&x.isIdentifier(t.expression)){let o=t.expression.text,s=n.get(o);s&&!r.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&r.push({from:e,to:o,toSpecifier:s})}x.forEachChild(t,o=>Dt(o,e,n,r))}var Si=d(()=>{"use strict";l();be();di();X();hi()});function Rt(t,e){if(e.length===0)return"ui";let n=!1;return t.walk(r=>{if(r.type==="rule")return n=!0,!1}),n?"ui":"barrel"}var Ci=d(()=>{"use strict";l()});import vi from"postcss";import*as wm from"postcss-less";function ki(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Tm(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Fm(t,e){let n=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(n){let s=n[1]?.trim()??"",i=n[2]??"";if(!i)return null;let a=wi.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...ki(i)?{isExternal:!0}:{}}}let r=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=r?r[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...ki(o)?{isExternal:!0}:{}}:null}function Nm(t,e){let n=[],r=/url\(['"]?([^'")]+)['"]?\)/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";Tm(s)&&n.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=r.exec(t)}return n}function Ei(t,e){let n=[];return t.walk(r=>{if(r.type==="atrule"&&r.name==="import"){let o=Fm(r.params,e);o&&n.push(o)}r.type==="decl"&&n.push(...Nm(r.value,e))}),n}function Pm(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Dm(t,e){let n=[],r=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=wi.has(s)?"side-effect":"static";n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=r.exec(t)}return n}function It(t,e){let n=vi.parse(Pm(t));return{imports:Ei(n,e),root:n}}function Rm(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type!=="atrule")continue;let{value:o}=r;if(o===void 0)continue;let s=r.name;s&&(e.push({name:s}),n.push({name:s,kind:"variable"}))}return{exports:e,tags:n}}function At(t,e){try{let n=Em.parse(t),{exports:r,tags:o}=Rm(n);return{imports:Ei(n,e),root:n,exports:r,tags:o}}catch{return{imports:Dm(t,e),root:vi.parse(""),exports:[],tags:[]}}}var Em,wi,yr=d(()=>{"use strict";l();Em=wm,wi=new Set(["reference","inline"])});import{parse as Im}from"postcss-scss";function Ti(t){return t.startsWith("_")||t.startsWith("-")}function Am(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Mm(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let n=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:n,alias:o}:{specifier:n}}function Lm(t){let e=[],n=[];for(let r of t.nodes??[]){if(r.type==="decl"&&r.prop.startsWith("$")){let o=r.prop.slice(1);if(!o||Ti(o))continue;e.push({name:o}),n.push({name:o,kind:"variable"});continue}if(r.type==="atrule"&&(r.name==="mixin"||r.name==="function")){let s=r.params.match(/^([\w-]+)/)?.[1];if(!s||Ti(s))continue;let i=r.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),n.push({name:s,kind:"function"})}}return{exports:e,tags:n}}function Mt(t,e){let n=Im(t),r=[];n.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=Mm(c);if(!p)return;let m={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...Am(p)?{isExternal:!0}:{}};f&&(m.symbols=[f]),r.push(m)});let{exports:o,tags:s}=Lm(n);return{imports:r,root:n,exports:o,tags:s}}var xr=d(()=>{"use strict";l()});function Fi(t,e){let n=[],r=/@require\s+['"]([^'"]+)['"]/g,o=r.exec(t);for(;o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=r.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&n.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return n}function Ni(t,e){if(e.length===0)return"ui";try{let n=kn("stylus");return new n.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Pi=d(()=>{"use strict";l()});function qe(t,e){let n=B(t);if(n==="stylus"){let s=Fi(e,t);return{imports:s,exports:[],tags:[],category:Ni(e,s)}}if(n==="scss"){let{imports:s,root:i,exports:a,tags:c}=Mt(e,t);return{imports:s,exports:a,tags:c,category:Rt(i,s)}}if(n==="less"){let{imports:s,root:i,exports:a,tags:c}=At(e,t);return{imports:s,exports:a,tags:c,category:Rt(i,s)}}let{imports:r,root:o}=It(e,t);return{imports:r,exports:[],tags:[],category:Rt(o,r)}}var Di=d(()=>{"use strict";l();X();Ci();yr();xr();Pi()});async function Ri(t,e){let n=B(t),r=Is(n);return r?r(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Ii=d(()=>{"use strict";l();X();Ds();As();$s();zs();Vs();Ys();Xs();ei();oi();li();fi();Si();Ke();Di();be();X();Ke();for(let[t,e]of[["javascript",(n,r)=>gr(n,r,"javascript")],["typescript",(n,r)=>gr(n,r,"typescript")],["css",qe],["scss",qe],["less",qe],["stylus",qe],["coffeescript",Ps],["livescript",Qs],["lua",Zs],["python",ci],["go",js],["java",Ks],["kotlin",qs],["scala",pi],["groovy",Ws],["gherkin",rr],["markdown",ri]])Te(t,e)});import Ai from"path";function Om(t,e){let n=e.get(t.path);n!==void 0&&(t.coveragePct=n)}function Li(t,e){for(let n of t)if(n.isExternal){let r=n.rawSpecifier.startsWith("@")?n.rawSpecifier.split("/").slice(0,2).join("/"):n.rawSpecifier.split("/")[0];r&&!e.some(o=>o.name===r)&&e.push({name:r,kind:"library"})}}function _m(t,e,n){if(e.isExternal||!e.toPath)return;let r=n.get(e.toPath);r&&(r.category!=="logic"&&r.category!=="barrel"||(r.testedBy??=[],r.testedBy.includes(t.path)||r.testedBy.push(t.path)))}function Gm(t,e){if(t.type==="markdown")for(let n of t.imports){if(n.isExternal||!n.toPath)continue;let r=e.get(n.toPath);!r||r===t||(r.documentedBy??=[],r.documentedBy.includes(t.path)||r.documentedBy.push(t.path),r.category==="logic"&&(r.lastCommitAt??0)>(t.lastCommitAt??0)&&(t.staleFor??=[],t.staleFor.includes(r.path)||t.staleFor.push(r.path)))}}function Mi(t){return Math.round(t*1e4)/1e4}function jm(t,e){let n=[];for(let r of t.imports){if(r.isExternal||!r.toPath)continue;let o=e.get(r.toPath);if(!o||o.exports.length===0)continue;let s;if(r.symbols===void 0){if(r.type==="side-effect")continue;s=1}else r.symbols.includes("*")?s=1:s=r.symbols.length/o.exports.length;r.exportUsageRatio=Mi(Math.min(1,s)),n.push(r.exportUsageRatio)}n.length>0&&(t.avgExportUsage=Mi(n.reduce((r,o)=>r+o,0)/n.length),t.maxExportUsage=Math.max(...n))}function br(t,e,n){e&&(t.some(r=>r.name===e&&r.kind===n)||t.push({name:e,kind:n}))}function $m(t,e){let n=e.toPath,r=Ai.basename(n,Ai.extname(n)).replace(/\.(test|spec)$/,"");br(t.tags,r,"import")}function Wm(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let n of e.symbols)br(t.tags,n,"import")}function zm(t,e,n){let r=n.get(e.toPath);if(!(!r||r.category==="test"))for(let o of r.tags)o.kind==="comment-marker"&&br(t.tags,o.name,"comment-marker")}function Bm(t,e,n){!e.toPath||e.isExternal||($m(t,e),Wm(t,e),zm(t,e,n))}function Oi(t,e){for(let n of t.values())delete n.testedBy,delete n.documentedBy,delete n.staleFor,n.category==="test"&&(n.tags=n.tags.filter(r=>r.kind!=="import"));for(let n of t.values()){if(jm(n,t),e.size>0&&Om(n,e),n.category==="test")for(let r of n.imports)_m(n,r,t),Bm(n,r,t);Gm(n,t)}}var _i=d(()=>{"use strict";l()});function Sr(t){let e=new Map;for(let n of t.nodes.values())e.set(n.type,(e.get(n.type)??0)+1);return[...e.entries()].map(([n,r])=>({type:n,fileCount:r,exportsTracked:ji.has(n),importSymbolsTracked:$i.has(n),callEdgesTracked:Lt.has(n)})).sort((n,r)=>r.fileCount-n.fileCount)}var Gi,ji,$i,Lt,Ot=d(()=>{"use strict";l();Gi=new Set(["java","kotlin","scala","groovy"]),ji=new Set(["typescript","javascript","python","go","java","kotlin","scala","groovy","scss","less","lua","coffeescript"]),$i=new Set(["typescript","javascript","python"]),Lt=new Set(["typescript","javascript","go","python","java"])});import Bi from"fs";import Ae from"path";function Hm(t,e){let n=t.split(`
|
|
12
|
+
`),r=null,o=new Map,s=!1;for(let i of n){let a=i.trim();if(a.startsWith("module ")){r=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Wi(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Wi(a.replace(/^replace\s+/,""),e,o)}return{mod:r,replaces:o}}function Wi(t,e,n){let[r,o]=t.split("=>").map(a=>a.trim());if(!r||!o)return;let s=r.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=Ae.isAbsolute(o)?o:Ae.resolve(e,o);n.set(s,i)}function zi(t){let e;try{e=Bi.readdirSync(t,{withFileTypes:!0})}catch{return null}let n=e.filter(r=>r.isFile()&&r.name.endsWith(".go")&&!r.name.endsWith("_test.go")).map(r=>({path:Ae.join(t,r.name),isExternal:!1})).sort((r,o)=>r.path.localeCompare(o.path));return n.length>0?n:null}var Ye,Cr=d(()=>{"use strict";l();Ye=class{extensions=[".go"];goModCache=new Map;resolve(e,n,r,o){let{mod:s,replaces:i}=this.readGoMod(r);if(!s)return null;let a=this.applyReplace(n,i,r);if(a!==void 0)return zi(a);if(n!==s&&!n.startsWith(`${s}/`))return null;let c=n.slice(s.length).replace(/^\//,"");return c?zi(Ae.join(r,c)):null}readGoMod(e){let n=this.goModCache.get(e);if(n!==void 0)return n;let r={mod:null,replaces:new Map};try{let o=Bi.readFileSync(Ae.join(e,"go.mod"),"utf-8"),s=Hm(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,r),r}}applyReplace(e,n,r){for(let[o,s]of n){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return Ae.join(s,i)}}}}});import _t from"fs";import Gt from"path";function Ji(t){let e=t.replace(/\\/g,"/"),n=e.match(/^(.*)\/src\/([^/]+)(?:\/|$)/);if(!n?.[1]||!n[2]){let s=e.lastIndexOf("/");return{module:s===-1?e:e.slice(0,s),rootSegment:"",sourceRoot:"unknown"}}let r=n[2],o=r==="main"?"main":Km.has(r)?r:"unknown";return{module:n[1],rootSegment:r,sourceRoot:o}}function Vm(t,e=[]){let n=new Map,r=(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set([...A,...r,...e]),s=(a,c)=>{let{module:p,rootSegment:f,sourceRoot:m}=Ji(c),h=n.get(a);if(!h){n.set(a,[{module:p,rootSegment:f,sourceRoot:m,files:[c]}]);return}let y=h.find(b=>b.module===p&&b.rootSegment===f);y?y.files.push(c):h.push({module:p,rootSegment:f,sourceRoot:m,files:[c]})},i=(a,c)=>{if(c>Jm)return;let p;try{p=_t.readdirSync(a,{withFileTypes:!0})}catch{return}for(let f of p){let m=Gt.join(a,f.name);if(f.isDirectory()){!f.name.startsWith(".")&&!o.has(f.name)&&i(m,c+1);continue}if(!f.isFile())continue;let h=Gt.extname(f.name);if(!Um.has(h))continue;let y=Ym(m,h===".scala"||h===".sc");y&&s(y,m)}};i(t,0);for(let a of n.values())for(let c of a)c.files.sort();return n}function qm(t,e){let n=t.get(e);if(!(!n||n.length===0))return n.length===1?n[0]?.files:n.flatMap(r=>r.files).sort()}function Ym(t,e){let n;try{let r=_t.openSync(t,"r");try{let o=Buffer.alloc(Hi),s=_t.readSync(r,o,0,Hi,0);n=o.toString("utf8",0,s)}finally{_t.closeSync(r)}}catch{return null}return $(n,e)}function kr(t){return!t||t.length===0?null:t.map(e=>({path:e,isExternal:!1}))}function Ui(t){return Gt.basename(t,Gt.extname(t))}var Um,Jm,Hi,Km,le,vr=d(()=>{"use strict";l();j();Re();Um=new Set([".java",".kt",".kts",".scala",".sc",".groovy"]),Jm=12,Hi=4096,Km=new Set(sr);le=class{constructor(e=[]){this.extraIgnoreDirs=e}extraIgnoreDirs;extensions=[".java",".kt",".kts",".scala",".sc",".groovy",".gradle"];indexCache=new Map;resolve(e,n,r,o){let s=this.getIndex(r);if(s.size===0)return null;let i=n.endsWith(".*"),a=(i?n.slice(0,-2):n).split(".").filter(Boolean);if(a.length===0)return null;if(i){let c=s.get(a.join("."));if(!c)return null;let p=Ji(e),f=c.filter(y=>y.module===p.module&&y.rootSegment===p.rootSegment),m=p.sourceRoot!=="main"&&p.sourceRoot!=="unknown",h=f.flatMap(y=>m?y.files:y.files.filter(b=>!ir(Ui(b))));return kr(h)}for(let c=a.length-1;c>=1;c--){let p=qm(s,a.slice(0,c).join("."));if(!p)continue;let f=a[c],m=p.filter(h=>Ui(h)===f);if(m.length>0)return kr(m);if(c===a.length-1)return kr(p)}return null}getIndex(e){let n=this.indexCache.get(e);if(n)return n;let r=Vm(e,this.extraIgnoreDirs);return this.indexCache.set(e,r),r}}});import Qm from"fs";import wr from"path";var Qe,Er=d(()=>{"use strict";l();Qe=class{extensions=[".lua"];resolve(e,n,r,o){let s=n.replace(/\./g,wr.sep),i=[r,wr.join(r,"lib")];for(let a of i){if(!Qm.existsSync(a))continue;let c=o(wr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Xm from"path";var Zm,Xe,Tr=d(()=>{"use strict";l();j();Zm=new Set(A),Xe=class{extensions=[".md",".mdx"];resolve(e,n,r,o){let s=n.replace(/^\.\//,"").split("/")[0];if(s&&Zm.has(s))return null;let i=o(Xm.join(r,"_dummy"),`./${n}`);return i?[i]:null}}});import eu from"fs";import Fr from"path";function Ki(t){try{return eu.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ze,Nr=d(()=>{"use strict";l();Ze=class{extensions=[".py"];resolve(e,n,r,o){let s=n.replace(/\./g,Fr.sep),i=Fr.join(r,`${s}.py`);if(Ki(i))return[{path:i,isExternal:!1}];let a=Fr.join(r,s,"__init__.py");return Ki(a)?[{path:a,isExternal:!1}]:null}}});import Vi from"path";var tu,et,Pr=d(()=>{"use strict";l();tu=["~","http://","https://","//","data:","sass:"],et=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,n,r,o){if(tu.some(f=>n.startsWith(f)))return null;let s=o(e,n);if(s)return[s];let i=Vi.dirname(n),a=Vi.basename(n),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});function jt(t={}){return[new Ze,new Qe,new Ye,t.jvm??new le,new et,new Xe]}var Dr=d(()=>{"use strict";l();Cr();vr();Er();Tr();Nr();Pr();Cr();vr();Er();Tr();Nr();Pr()});import $t from"fs";import J from"path";var K,Wt=d(()=>{"use strict";l();Dr();K=class{constructor(e,n={}){this.rootDir=e;this.workspaceMap=n.workspaceMap??new Map,this.tsconfigSearchPaths=n.tsconfigSearchPaths??[e],this.pathAliases=n.pathAliases,this.langResolvers=n.langResolvers??jt()}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolutionCache=new Map;langBucketFor(e){for(let n=0;n<this.langResolvers.length;n++)if(this.langResolvers[n]?.extensions.some(r=>e.endsWith(r)))return String(n);return"none"}cacheKey(e,n){return`${J.dirname(e)}\0${this.langBucketFor(e)}\0${n}`}resolveAll(e,n){let r=this.cacheKey(e,n),o=this.resolutionCache.get(r);if(o!==void 0)return o??[];let s=this.resolveAllUncached(e,n);return this.resolutionCache.set(r,s.length>0?s:null),s}resolveAllUncached(e,n){let r=this.resolvePathAlias(n);if(r)return[r];if(n.startsWith(".")||n.startsWith("/")){let i=this.resolveLocalPath(e,n);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,n,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(n);return s?[s]:[{path:n,isExternal:!0}]}resolve(e,n){return this.resolveAll(e,n)[0]??null}resolveLocalPath(e,n){let r=J.dirname(e),o=n.startsWith("/")?n:J.resolve(r,n),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let 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,n,r){let o=e+n;if(this.isFile(o))return{path:o,isExternal:r};let s=J.join(e,`index${n}`);if(this.isFile(s))return{path:s,isExternal:r};if(n===".py"){let i=J.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:r}}return null}isFile(e){try{return $t.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let n in this.pathAliases){let r=this.matchAliasPattern(n,e),o=this.pathAliases[n];if(r&&o){let s=this.tryAliasSubstitutions(o,r[1]||"");if(s)return s}}for(let n of this.tsconfigSearchPaths){let r=J.join(n,"tsconfig.json");if($t.existsSync(r))try{let s=JSON.parse($t.readFileSync(r,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",n);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,n){let r=this.aliasRegexCache.get(e);if(!r){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");r=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,r)}return n.match(r)}tryAliasSubstitutions(e,n,r=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",n),a=J.resolve(r,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[n,r]of this.workspaceMap){if(e!==n&&!e.startsWith(`${n}/`))continue;let o=e.slice(n.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:n};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=J.join(r,a);try{if($t.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:r}}let i=this.resolveLocalPath(J.join(r,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import tt from"fs";import R from"path";import nu from"piscina";function iu(){return(process.env.MOKOSH_IGNORE_DIRS??"").split(",").map(t=>t.trim()).filter(Boolean)}function au(t,e){if(t.length===0)return e;let n=t.map(i=>R.dirname(i).split(R.sep)),r=n[0]??[];for(let i of n.slice(1)){let a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;r=r.slice(0,a)}let o=r.join(R.sep)||R.sep,s=R.relative(e,o);return s.startsWith("..")||R.isAbsolute(s)?e:o}var ru,ou,su,pe,Rr=d(()=>{"use strict";l();Hn();be();tr();Ii();_i();Ot();ve();Wt();ru=["tests","test","__tests__","specs","spec"],ou=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage",".pytest_cache","__pycache__"],su=600;pe=class{constructor(e,n=null,r,o,s=!1,i=new Map,a=!0,c=[],p=null){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.docFiles=p;this.previousGraph=n,this.walkIgnoreDirs=new Set([...ou,...c,...iu()]),this.resolver=r||new K(e),this.lockFile=Es(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;docFiles;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;walkIgnoreDirs;async build(e){let n=e.map(r=>R.isAbsolute(r)?r:R.resolve(this.rootDir,r));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=xs(this.rootDir));try{for(let r of n)this.enqueue(r);return await this.drain(),await this.processTestFiles(au(n,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
|
|
13
|
+
Done. Total processed: ${this.visited.size} nodes.
|
|
14
|
+
`),Oi(this.graph.nodes,this.coverageMap),new I(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},n=e.minFiles??su;if(!(n>0&&!this.hasAtLeastFiles(this.rootDir,n))){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 r=R.join(u,"parse-worker.js");this.pool=new nu({filename:r,...e.maxThreads!==void 0?{maxThreads:Math.max(1,e.maxThreads)}:{}})}catch(r){process.stderr.write(`
|
|
17
|
+
Warning: failed to start parse worker pool, falling back to synchronous parsing: ${r}
|
|
18
|
+
`),this.pool=null}}}hasAtLeastFiles(e,n){let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=tt.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())this.walkIgnoreDirs.has(a.name)||o.push(R.join(s,a.name));else if(a.isFile()&&(r++,r>=n))return!0}return r>=n}async processTestFiles(e){let n=ze(),r=s=>n.some(i=>s.name.includes(i));this.walkProject(e,r);let o=e;for(;o!==this.rootDir;){let s=R.dirname(o);if(s===o)break;for(let i of ru){let a=R.join(s,i);try{tt.statSync(a).isDirectory()&&this.walkProject(a,r)}catch{}}o=s}await this.drain()}async processDocFiles(){if(this.docFiles!==null){for(let e of this.docFiles)this.enqueue(e);await this.drain();return}this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,n){let r;try{r=tt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of r){let s=R.join(e,o.name);o.isDirectory()?this.walkIgnoreDirs.has(o.name)||this.walkProject(s,n):o.isFile()&&n(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(n=>this.finishFile(n)))}}async finishFile(e){let n=tt.statSync(e,{throwIfNoEntry:!1});if(!n?.isFile())return;let r=R.relative(this.rootDir,e),o=await this.getNode(e,r,n);o.imports=await this.resolveImports(e,o.imports),Li(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,n,r){let o=this.previousGraph?.nodes.get(n);if(o&&o.mtime===r.mtimeMs&&o.size===r.size)return{...o};let s=await this.tryParse(e,n);if(!s)return this.makeStubNode(e,n,r);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,n,r,s,i);return this.attachGitStats(a,n),a}async tryParse(e,n){let r=tt.readFileSync(e,"utf-8");try{return await this.parseContent(e,r)}catch(o){return process.stderr.write(`
|
|
19
|
+
Warning: failed to parse ${n}: ${o}
|
|
20
|
+
`),null}}parseContent(e,n){return this.pool?this.pool.run({filePath:e,content:n}):Ri(e,n)}makeStubNode(e,n,r){return{path:n,type:B(e),category:"other",imports:[],exports:[],tags:[],mtime:r.mtimeMs,size:r.size}}resolveCallEdges(e,n){let r=[];for(let o of n??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&r.push({from:o.from,to:o.to,toFile:R.relative(this.rootDir,s.path)})}catch{}return r}buildNode(e,n,r,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:m,cognitiveComplexity:h,functions:y}=o;return{path:n,type:B(e),category:p,imports:i,exports:a,tags:c,mtime:r.mtimeMs,size:r.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...m!==void 0?{complexity:m}:{},...h!==void 0?{cognitiveComplexity:h}:{},...y!==void 0?{functions:y}:{}}}attachGitStats(e,n){let r=this.gitStatsMap?.get(n);r&&(e.commitCount90d=r.commitCount90d,r.lastAuthor!==void 0&&(e.lastAuthor=r.lastAuthor),r.lastCommitAt!==void 0&&(e.lastCommitAt=r.lastCommitAt))}async resolveImports(e,n){let r=[];for(let o of n){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(!(s.length===0||o.type==="side-effect"&&o.rawSpecifier.endsWith(".*")&&s.every(a=>a.isExternal)))for(let a of s){if(!a.isExternal&&a.path===e)continue;let c={...o,toPath:a.isExternal?a.path:R.relative(this.rootDir,a.path),isExternal:a.isExternal};a.isWorkspace&&(c.isWorkspace=!0,c.workspacePackage=a.workspacePackage),a.isExternal?this.attachLockfileVersion(c):this.enqueue(a.path),r.push(c)}}return r}attachLockfileVersion(e){if(!this.lockFile)return;let n=this.lockFile.jvmDependencies;if(n&&Gi.has(B(e.fromPath))){let s=e.rawSpecifier.replace(/\.\*$/,""),i="";for(let a of Object.keys(n))(s===a||s.startsWith(`${a}.`))&&a.length>i.length&&(i=a);i&&(e.version=n[i]?.version);return}let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],o=r?this.lockFile.dependencies[r]:void 0;o&&(e.version=o.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});function qi(t){return cu.has(t)?"style":"code"}var cu,Yi=d(()=>{"use strict";l();cu=new Set(["css","scss","less","stylus"])});import Qi from"path";function uu(t,e){let n=t.split(/[\\/]/),r=/^\*\*\/(.+?)\/\*\*$/.exec(e);return r?n.includes(r[1]):e.startsWith("*.")?Qi.basename(t).endsWith(e.slice(1)):n.includes(e)}function zt(t,e=[]){if(t.split(/[\\/]/).some(o=>lu.has(o)))return!0;let r=Qi.basename(t);return pu.some(o=>r.endsWith(o))?!0:e.some(o=>uu(t,o))}function nt(t){let e=t.slice(0,mu).toLowerCase();return fu.some(n=>e.includes(n))}var lu,pu,fu,mu,Ir=d(()=>{"use strict";l();lu=new Set(["generated","__generated__","__generated","gen","__snapshots__"]),pu=[".pb.go",".pb.ts",".pb.js","_pb2.py","_pb2.pyi","_pb.dart",".g.dart",".generated.ts",".generated.tsx",".generated.js",".generated.jsx","_generated.go",".gen.go",".gen.ts",".snap"],fu=["@generated","do not edit","code generated by","autogenerated","auto-generated","this file was automatically generated","this is a generated file","jest snapshot v1"],mu=500});function du(t){return t.trim().replace(/\s+/g," ")}function gu(t){try{return t.fileType==="scss"?Mt(t.source,t.file).root:t.fileType==="less"?At(t.source,t.file).root:t.fileType==="css"?It(t.source,t.file).root:void 0}catch{return}}function hu(t){let e=gu(t);if(!e)return[];let n=[];return e.walkRules(r=>{let o=r.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=r.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${du(f.value)}`).join(";");n.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),n}function Xi(t,e,n=2){let r=new Map;for(let s of t)for(let i of hu(s)){if(i.declCount<n||i.lines<e)continue;let a=r.get(i.signature);a?a.push(i):r.set(i.signature,[i])}let o=[];for(let s of r.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],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},m={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,m],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Zi=d(()=>{"use strict";l();yr();xr()});function ea(t){let e=t.length,n=[],r=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<r[r.length-1].lcpLength;){let i=r.pop();n.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>r[r.length-1].lcpLength&&r.push({lcpLength:t[o],low:s})}for(;r.length>1;){let o=r.pop();n.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return n}var ta=d(()=>{"use strict";l()});function na(t,e,n){let r=0;for(let o=e;o<e+n;o++)yu.has(t[o].text)&&r++;return r/n}var yu,ra=d(()=>{"use strict";l();yu=new Set(["{","}",":",",","[","]"])});function oa(t){let e=t.length;if(e===0)return[];let n=Array.from({length:e},(s,i)=>i),r=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)r[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?r[a+s]:-1;n.sort((a,c)=>{let p=r[a]-r[c];return p!==0?p:i(a)-i(c)}),o[n[0]]=0;for(let a=1;a<e;a++){let c=n[a-1],p=n[a],f=r[c]===r[p],m=i(c)===i(p);o[p]=o[c]+(f&&m?0:1)}if([r,o]=[o,r],r[n[e-1]]===e-1)break}return n}function sa(t,e){let n=t.length,r=new Array(n).fill(0);if(n===0)return r;let o=new Array(n);for(let i=0;i<n;i++)o[e[i]]=i;let s=0;for(let i=0;i<n;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<n&&c+s<n&&t[i+s]===t[c+s];)s++;r[a]=s,s>0&&s--}else s=0}return r}var ia=d(()=>{"use strict";l()});function aa(t,e,n,r=.5){let o=[],s=[],i=new Map;for(let{file:m,tokens:h}of t)if(h.length!==0){i.set(m,h);for(let y=0;y<h.length;y++)o.push(h[y].text),s.push({file:m,localIndex:y});o.push(` ${m}`),s.push({file:m,localIndex:-1})}if(o.length===0)return[];let a=oa(o),c=sa(o,a),p=ea(c),f=[];for(let m of p){let h=xu(m,a,s,i,e,n,r);h&&f.push(h)}return f.sort((m,h)=>h.lines-m.lines)}function xu(t,e,n,r,o,s,i){if(t.lcpLength<o)return;let a=[];for(let y=t.low;y<=t.high;y++){let b=n[e[y]];b.localIndex!==-1&&a.push(b)}if(a.length<2||!bu(a,r))return;let c=Su(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=r.get(p.file);if(na(f,p.localIndex,t.lcpLength)>i)return;let m=c.map(({file:y,localIndex:b})=>{let v=r.get(y);return{file:y,startLine:v[b].line,endLine:v[b+t.lcpLength-1].line}}),h=Math.min(...m.map(y=>y.endLine-y.startLine+1));if(!(h<s))return{occurrences:m,lines:h,tokens:t.lcpLength}}function bu(t,e){let n=null;for(let{file:r,localIndex:o}of t){if(o===0)return!0;let i=e.get(r)[o-1].text;if(n===null)n=i;else if(n!==i)return!0}return!1}function Su(t,e){let n=new Map;for(let{file:o,localIndex:s}of t){let i=n.get(o);i?i.push(s):n.set(o,[s])}let r=[];for(let[o,s]of n){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(r.push({file:o,localIndex:a}),i=a+e)}return r}var ca=d(()=>{"use strict";l();ta();ra();ia()});function la(t,e,n){let r=t.slice(e,n).replace(/[^\n]/g," ");return t.slice(0,e)+r+t.slice(n)}function ku(t,e){if(!e)return t;let n=t;for(let[r,o]of e.block??[]){let s=0;for(;;){let i=n.indexOf(r,s);if(i===-1)break;let a=n.indexOf(o,i+r.length),c=a===-1?n.length:a+o.length;n=la(n,i,c),s=c}}for(let r of e.line??[]){let o=0;for(;;){let s=n.indexOf(r,o);if(s===-1)break;let i=n.indexOf(`
|
|
21
|
+
`,s),a=i===-1?n.length:i;n=la(n,s,a),o=a}}return n}function wu(t,e){let n=vu[e];if(!n)return t;let r=t.split(`
|
|
22
|
+
`),o=e==="go",s=!1,i=!1;for(let a=0;a<r.length;a++){let c=r[a],p=()=>{r[a]=c.replace(/[^\r]/g," ")};if(s){p(),c.includes(")")&&(s=!1);continue}if(i){p(),(/}\s*from\s/.test(c)||c.includes("}"))&&(i=!1);continue}n.some(f=>f.test(c))&&(p(),o&&/^\s*import\s+\(/.test(c)&&!c.includes(")")?s=!0:(e==="typescript"||e==="javascript")&&/^\s*import\b/.test(c)&&c.includes("{")&&!c.includes("}")&&(i=!0))}return r.join(`
|
|
23
|
+
`)}function fa(t,e,n=!0){let r=wu(ku(t,Cu[e]),e),o=[],s=1,i=0;Ar.lastIndex=0;let a=Ar.exec(r);for(;a!==null;){for(let f=i;f<a.index;f++)r[f]===`
|
|
24
|
+
`&&s++;i=a.index;let c=a[0],p=c;Tu.test(c)&&!Nu.has(c)?p="ID":n&&(pa.test(c)||Fu.test(c))&&(p=pa.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let f=i;f<a.index+c.length;f++)r[f]===`
|
|
25
|
+
`&&s++;i=a.index+c.length,a=Ar.exec(r)}return o}var Cu,vu,Eu,Ar,Tu,pa,Fu,Nu,ma=d(()=>{"use strict";l();Cu={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:[["<!--","-->"]]}};vu={typescript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],javascript:[/^\s*import[\s{("*]/,/^\s*export\s.*\sfrom\s/],python:[/^\s*import\s+\S/,/^\s*from\s+\S+\s+import[\s(]/],go:[/^\s*import\s+["(]/],java:[/^\s*import\s+/],kotlin:[/^\s*import\s+/],scala:[/^\s*import\s+/],groovy:[/^\s*import\s+/]};Eu=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Ar=new RegExp(`${Eu.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Tu=/^[A-Za-z_$][A-Za-z0-9_$]*$/,pa=/^\d+(?:\.\d+)?$/,Fu=/^(".*"|'.*'|`.*`)$/s,Nu=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 rt from"fs";import Pu from"path";function Du(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mtime=="number"&&typeof e.size=="number"&&typeof e.ignoreLiterals=="boolean"&&typeof e.generated=="boolean"&&Array.isArray(e.tokens)}function Me(t){try{if(!rt.existsSync(t))return new Map;let e=rt.readFileSync(t,"utf-8"),n=JSON.parse(e);if(!Array.isArray(n))return new Map;let r=n.filter(o=>Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&Du(o[1]));return new Map(r)}catch{return new Map}}function Le(t,e){let n=Pu.dirname(e);rt.existsSync(n)||rt.mkdirSync(n,{recursive:!0}),rt.writeFileSync(e,JSON.stringify([...t.entries()]))}var ua=d(()=>{"use strict";l()});import{readFile as da}from"fs/promises";import ot from"path";import Ru from"piscina";function Mu(t){return Ue.includes(ot.basename(t))}function Lu(t,e){if(e.length===0)return!1;let n=new Set(e);return t.split(ot.sep).some(r=>n.has(r))}function ga(t,e){let n=[];return new Set(t.occurrences.map(r=>r.file)).size===1&&n.push("same-file"),t.occurrences.some(r=>e.has(r.file))&&n.push("generated"),n.length>0?{...t,signals:n}:t}async function Oe(t,e,n={}){let{minLines:r=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=A,includeGenerated:p=!1,ignoreGlobs:f=[],parallelTokenizing:m=!0,tokenCache:h}=n,y=[...t.nodes.values()].filter(C=>!Mu(C.path)&&!Lu(C.path,c)),b=new Set,v=Ou(m,y.length);try{let C=[],E=new Map;if(await Promise.all(y.map(async S=>{let F=zt(S.path,f);if(F&&!p)return;if(Au.has(S.type)){let Y;try{Y=await da(ot.join(e,S.path),"utf8")}catch{return}let Xo=F||nt(Y);if(Xo&&!p)return;Xo&&b.add(S.path),C.push({file:S.path,source:Y,fileType:S.type});return}let q=h?.get(S.path),Jl=q&&q.mtime===S.mtime&&q.size===S.size&&q.ignoreLiterals===s,dt,xe;if(Jl)dt=q.tokens,xe=q.generated;else{let Y;try{Y=await da(ot.join(e,S.path),"utf8")}catch{return}if(xe=F||nt(Y),xe&&!p)return;dt=v?await v.run({source:Y,fileType:S.type,ignoreLiterals:s}):fa(Y,S.type,s),h?.set(S.path,{mtime:S.mtime,size:S.size,ignoreLiterals:s,generated:xe,tokens:dt})}if(xe&&!p)return;xe&&b.add(S.path);let qo=qi(S.type),Yo={file:S.path,tokens:dt},Qo=E.get(qo);Qo?Qo.push(Yo):E.set(qo,[Yo])})),h){let S=new Set(y.map(F=>F.path));for(let F of h.keys())S.has(F)||h.delete(F)}let G=Xi(C,r).map(S=>ga(S,b));for(let[S,F]of E)for(let q of aa(F,o,r,i))G.push(ga({...q,family:S},b));return{groups:G.sort((S,F)=>F.lines-S.lines).slice(0,a)}}finally{v&&await v.destroy()}}function Ou(t,e){if(t===!1)return null;let n=typeof t=="object"?t:{},r=n.minFiles??Iu;if(e<r)return null;n.maxThreads!==void 0&&n.maxThreads<1&&process.stderr.write(`
|
|
26
|
+
Warning: parallelTokenizing.maxThreads (${n.maxThreads}) must be at least 1; using 1.
|
|
27
|
+
`);try{return new Ru({filename:ot.join(u,"duplication-worker.js"),...n.maxThreads!==void 0?{maxThreads:Math.max(1,n.maxThreads)}:{}})}catch(o){return process.stderr.write(`
|
|
10
28
|
Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
|
|
11
|
-
`),null}}var Bc,Uc,ir=m(()=>{"use strict";l();be();tr();Qn();ro();fo();ho();yo();Bc=20,Uc=new Set(["css","scss","less"])});import rt from"path";function Vc(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 Qc(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=rt.extname(o),c=rt.basename(o,a),p=c==="index"?rt.basename(rt.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 Qc(t,Vc(t),r)}var nt=m(()=>{"use strict";l()});function Xc(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 qc(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 Zc(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 el(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??Yc,o=r(t.nodes,e),s=Xc(t,o),i=qc(t.nodes,o,s,n);return{features:Zc(o,i),unassigned:el(t.nodes,o,i)}}var Yc,ot=m(()=>{"use strict";l();nt();Yc=(t,e)=>t.outDegree-e.outDegree});function ar(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:bo.has(r),importSymbolsTracked:So.has(r),callEdgesTracked:st.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var bo,So,st,cr=m(()=>{"use strict";l();bo=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),So=new Set(["typescript","javascript","python"]),st=new Set(["typescript","javascript","go","python"])});var ve,Co=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();Co();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 g=this.nodes.get(c);if(g&&(s.add(c),r(g,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 ve(this.nodes).findUnusedFiles(e)}findCycles(){return new ve(this.nodes).findCycles()}}});var Q,it=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 lr(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 pr(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 f=a.category==="test"||a.tags.some(g=>g.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function fr(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 ur(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 mr(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 dr(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 ko(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function gr(t,e={}){let{metric:r="cognitiveComplexity",minComplexity:n=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ko(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 hr=m(()=>{"use strict";l();it()});function vo(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 wo=m(()=>{"use strict";l()});function yr(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:vo(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var xr=m(()=>{"use strict";l();ot();wo()});function br(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(st.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 To=m(()=>{"use strict";l();cr();hr()});function tl(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function rl(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Sr(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(!rl(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:tl(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 Cr(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 kr=m(()=>{"use strict";l()});import Eo from"fs";import Bd from"path";function Fo(t){try{return Eo.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function at(t){try{return Eo.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var ct=m(()=>{"use strict";l()});import Ne from"fs";import M from"path";function vr(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:nl(e,n)}:null}function nl(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(at);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(/^\.\//,"");ol(t,s,n,r)}return r}function ol(t,e,r,n){if(!e.includes("*")){sl(t,e,r,n);return}let o=e.split("/");o.includes("**")?il(t,o,r,n):al(t,o,r,n)}function sl(t,e,r,n){let o=M.join(t,e);if(r.has(o)||!Fo(o))return;r.add(o);let s=vr(t,o);s&&n.push(s)}function il(t,e,r,n){let o=M.join(t,e[0]==="**"?"":e[0]??"");No(t,o,r,n)}function al(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=vr(t,c);p&&n.push(p)}}function No(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=vr(t,i);a&&n.push(a)}else No(t,i,r,n)}}var lt=m(()=>{"use strict";l();ct();ct()});import wr from"fs";import Po from"path";var Io,Do=m(()=>{"use strict";l();lt();Io={type:"npm",detect(t){let e=Po.join(t,"package.json");if(!wr.existsSync(e))return null;let r;try{r=JSON.parse(wr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||wr.existsSync(Po.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 Ao(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(...Ao(t,c,r,n+1))}return s}function cl(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:ll(e,n,s,i)}:null}function ll(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(at);return i.length>0?i.slice(0,1):o.slice(0,1)}var Mo,Ro=m(()=>{"use strict";l();ct();Mo={type:"nx",detect(t){return pe.existsSync(P.join(t,"nx.json"))?Ao(t,t,new Set,0).map(r=>cl(t,r,P.join(r,"project.json"))).filter(r=>r!==null):null}}});import Lo from"fs";import pl from"path";import{load as fl}from"js-yaml";var Oo,Go=m(()=>{"use strict";l();lt();Oo={type:"pnpm",detect(t){let e=pl.join(t,"pnpm-workspace.yaml");if(!Lo.existsSync(e))return null;let r=[];try{r=fl(Lo.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return le(t,r)}}});import ul from"fs";import ml from"path";var _o,jo=m(()=>{"use strict";l();_o={type:"turborepo",detect(t){return ul.existsSync(ml.join(t,"turbo.json"))?[]:null}}});import Tr from"fs";import Wo from"path";var zo,$o=m(()=>{"use strict";l();lt();zo={type:"yarn",detect(t){if(!Tr.existsSync(Wo.join(t,"yarn.lock")))return null;let e=Wo.join(t,"package.json");if(!Tr.existsSync(e))return null;let r;try{r=JSON.parse(Tr.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){Bo.push(t)}function Uo(){return Bo}var Bo,pt=m(()=>{"use strict";l();Bo=[]});import dl from"path";function Er(t,e=Uo()){let r=dl.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 Fr=m(()=>{"use strict";l();Do();Ro();Go();jo();$o();pt();pt();z(_o);z(Mo);z(Oo);z(zo);z(Io)});var Pe,Nr=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){Ho.set(t,e)}function Jo(t){return Ho.get(t)}var Ho,Ie=m(()=>{"use strict";l();Ho=new Map});function Ko(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function gl(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function De(t,e,r){return Bl.every(n=>n(t,e,r))}var 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,$l,Bl,Pr=m(()=>{"use strict";l();hl=(t,e)=>!e.category||Ko(t.category,e.category),yl=(t,e)=>!e.type||Ko(t.type,e.type),xl=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,bl=(t,e)=>!e.path||gl(t.path,e.path),Sl=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,Cl=(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)))},kl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),vl=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),wl=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),Tl=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,El=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Fl=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Nl=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Pl=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Il=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Dl=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Ml=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Al=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Rl=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Ll=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Ol=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Gl=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,_l=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,jl=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Wl=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,zl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,$l=(t,e,r)=>!e.any?.length||e.any.some(n=>De(t,n,r)),Bl=[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,$l]});function ft(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 Vo=m(()=>{"use strict";l();Pr();Pr()});function Qo(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 Ul(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};Qo(o,n),Object.keys(o).length>0&&e.push(o)}return e}function ut(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=Ul(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}Qo(e,n)}return e}var Yo=m(()=>{"use strict";l()});var Xo=m(()=>{"use strict";l();Vo();Yo()});import Hl 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 Ir(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)&&qo.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&qo.has(o.expression.text)&&e.push(n)}return e}function Dr(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 Mr(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 Ar(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 Rr(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 Lr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Jl(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function mt(t,e,r,n){let o=F.createSourceFile(Hl.basename(t),e,F.ScriptTarget.Latest,!0),s=Ir(o),[i]=s;if(!i)return e;let a=Dr(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Jl(a).sort())===JSON.stringify(c))return e;let p=Lr(c.map(g=>`@${g}`)),f=s.flatMap(g=>{let y=r.length===0?Ar(g,n,o):Mr(g,n,p,o);return y?[y]:[]});return f.length>0?Rr(e,f):e}var qo,_,ue=m(()=>{"use strict";l();qo=new Set(["describe","test","it"]);_=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Kl from"path";var dt,Zo=m(()=>{"use strict";l();ue();dt=class{name="cypress";canHandle(e){return _.has(Kl.extname(e).toLowerCase())}apply(e,r,n){return mt(e,r,n,"tags")}}});import Vl from"path";function Ql(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
29
|
+
`),null}}var Iu,Au,Bt=d(()=>{"use strict";l();j();tr();Yi();Ir();Zi();ca();ma();Ir();ua();Iu=20,Au=new Set(["css","scss","less"])});var fe,Ht=d(()=>{"use strict";l();fe=class{affectedSymbols=new Map;constructor(e,n){this.affectedSymbols.set(e,new Set(["default",...n]))}updateAffectedSymbols(e,n){let r=this.affectedSymbols.get(n)||new Set,o=e.imports.find(c=>c.toPath===n);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||r.has("*")||r.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function me(t,e){let n=t.nodes.get(e);if(n)return{category:n.category,exports:n.exports.map(r=>r.name)}}function Mr(t,e,n=1){let r=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return r.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:n}),r}function st(t,e){let n=[];return t.traverse(e,r=>{if(r.path===e)return!0;let o=r.imports.find(s=>s.toPath===e);return n.push({path:r.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),n}function Lr(t,e,n={}){let{testsOnly:r=!1,changedSymbols:o}=n,s=o?new fe(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(m=>m.name==="test");return(!r||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function Or(t,e,n={}){let{depth:r=1,withEdgeDetail:o=!1}=n,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:r}),s}function _e(t,e={}){let{metric:n="cognitiveComplexity",threshold:r=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[n]>=r).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[n]-s[n]).slice(0,o)}function _r(t){return{nodes:t.nodes.map(n=>({path:n.path,type:n.type,category:n.category,exports:n.exports.map(r=>r.name),tags:n.tags.filter(r=>r.kind==="comment-marker"||r.kind==="import").map(r=>r.name),importsFiles:n.imports.filter(r=>!r.isExternal&&r.toPath).map(r=>r.toPath),...n.description!==void 0&&{description:n.description},...n.testedBy!==void 0&&{testedBy:n.testedBy},...n.coveragePct!==void 0&&{coveragePct:n.coveragePct},...n.avgExportUsage!==void 0&&{avgExportUsage:n.avgExportUsage},...n.maxExportUsage!==void 0&&{maxExportUsage:n.maxExportUsage}})),cycles:t.cycles}}function Gr(t){let e=t.getPackageDependencies(),n=Array.from(t.packages.values()).map(({graph:r,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:r.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:n.length,packages:n}}function ne(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function ha(t){return[...t.nodes.values()].some(e=>e.commitCount90d!==void 0)}function Ge(t,e={}){let{metric:n="cognitiveComplexity",minComplexity:r=10,maxCoveragePct:o=50,minChurn:s=0,limit:i=20}=e,a=ha(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[n]>=r).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[n]-p[n]).slice(0,i);return{hotspots:c,count:c.length,churnDataAvailable:a}}var Ut=d(()=>{"use strict";l();Ht()});import{execFileSync as $r}from"child_process";import jr from"fs";import _u from"os";import Gu from"path";function Wr(t,e){try{return $r("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 ya(t,e,n){let r=jr.mkdtempSync(Gu.join(_u.tmpdir(),`mokosh-worktree-${e.slice(0,12)}-`));jr.rmdirSync(r);try{return $r("git",["worktree","add","--detach",r,e],{cwd:t,stdio:["ignore","pipe","pipe"]}),await n(r)}finally{try{$r("git",["worktree","remove","--force",r],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch{jr.rmSync(r,{recursive:!0,force:!0})}}}var xa=d(()=>{"use strict";l()});import ju from"path";async function wa(t,e,n,r={}){let o=Wr(t,e),s=ms(t,o);if(s)return{sha:o,graph:s};let i=await ya(t,o,async a=>{let c=r.pathAliases?new K(a,{pathAliases:r.pathAliases}):void 0;return new pe(a,null,c,void 0,r.gitStats??!1,new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[]).build(n)});return us(t,o,i),{sha:o,graph:i}}function $u(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]})`}function Wu(t,e){return`${t.file}:${t.line} ${t.name} (${t[e]}, cov ${t.coveragePct}%)`}function zu(t,e=4){let n=t.occurrences.slice(0,e).map(s=>`${s.file}:${s.startLine}-${s.endLine}`),r=t.occurrences.length-n.length,o=r>0?`, +${r} more`:"";return`${t.lines}L x${t.occurrences.length}: ${n.join(", ")}${o}`}function Bu(t,e){let{files:n,staleReferences:r,duplication:o,complexity:s,docDrift:i,coverage:a}=t,c=[],p=[n.added.length&&`${n.added.length} added`,n.changed.length&&`${n.changed.length} changed`,n.removed.length&&`${n.removed.length} removed`].filter(Boolean);c.push(p.length?`Files: ${p.join(", ")}`:"No file changes"),r.length>0&&c.push(`\u26A0 ${ue(r.length,"stale reference")} \u2014 removed export still imported`);let f=s.newHotspots[0];return f?c.push(`+${ue(s.newHotspots.length,"complexity hotspot")} (max ${e} ${f[e]} in ${f.file})`):s.resolvedHotspots.length>0&&c.push(`${ue(s.resolvedHotspots.length,"complexity hotspot")} resolved`),o.newGroups.length>0?c.push(`+${ue(o.newGroups.length,"duplication group")}`):o.resolvedGroups.length>0&&c.push(`${ue(o.resolvedGroups.length,"duplication group")} resolved`),i.newlyStale.length>0&&c.push(`${ue(i.newlyStale.length,"doc")} newly stale`),a&&a.newHotspots.length>0&&c.push(`+${ue(a.newHotspots.length,"risk hotspot")}`),c}function Hu(t){let{staleReferences:e,duplication:n,complexity:r,docDrift:o,coverage:s}=t;return e.length>0||(s?.newHotspots.length??0)>0?"attention":r.newHotspots.length>0||n.newGroups.length>0||o.newlyStale.length>0?"review-worthy":"clean"}function zr(t,e={}){let n=e.metric??"cognitiveComplexity",r=e.maxItems??8,o=e.maxPathList??100,{files:s,staleReferences:i,duplication:a,complexity:c,docDrift:p,coverage:f}=t,m=ba(c.head.avgCognitiveComplexity-c.base.avgCognitiveComplexity),h=s.added.length+s.changed.length+s.removed.length,y={base:`${t.base.ref}@${Sa(t.base.sha)}`,head:`${t.head.ref}@${Sa(t.head.sha)}`,verdict:Hu(t),headline:Bu(t,n),files:{added:s.added.length,changed:s.changed.length,removed:s.removed.length,...h<=o?{paths:{added:s.added,changed:s.changed,removed:s.removed}}:{}}};return i.length>0&&(y.staleReferences=i),(c.newHotspots.length>0||c.resolvedHotspots.length>0)&&(y.complexity={avgDelta:m,newHotspots:c.newHotspots.slice(0,r).map(b=>$u(b,n)),newHotspotCount:c.newHotspots.length,resolvedCount:c.resolvedHotspots.length}),(a.newGroups.length>0||a.resolvedGroups.length>0)&&(y.duplication={newGroups:a.newGroups.slice(0,r).map(b=>zu(b)),newGroupCount:a.newGroups.length,resolvedCount:a.resolvedGroups.length,totalGroups:a.head.groups}),(p.newlyStale.length>0||p.resolved.length>0)&&(y.docDrift={newlyStale:p.newlyStale.slice(0,r).map(b=>b.replace("::"," \u2192 ")),newlyStaleCount:p.newlyStale.length,resolvedCount:p.resolved.length}),f&&(f.newHotspots.length>0||f.resolvedHotspots.length>0)&&(y.coverage={avgDelta:ba(f.head.avgCoveragePct-f.base.avgCoveragePct),newHotspots:f.newHotspots.slice(0,r).map(b=>Wu(b,n)),newHotspotCount:f.newHotspots.length,resolvedCount:f.resolvedHotspots.length}),y}function Uu(t,e){let n=[],r=[];for(let[s,i]of e.nodes){let a=t.nodes.get(s);if(!a){n.push(s);continue}let c=JSON.stringify({category:a.category,exports:a.exports.map(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&&r.push(s)}let o=[...t.nodes.keys()].filter(s=>!e.nodes.has(s));return{added:n,removed:o,changed:r}}function Ju(t,e){let n=[];for(let[r,o]of t.nodes){let s=e.nodes.get(r);if(!s)continue;let i=new Set(s.exports.map(c=>c.name)),a=o.exports.map(c=>c.name).filter(c=>!i.has(c));if(a.length!==0)for(let c of a){let p=[...e.nodes.values()].filter(f=>f.imports.some(m=>m.toPath===r&&m.symbols?.includes(c))).map(f=>f.path);p.length>0&&n.push({file:r,symbol:c,stillReferencedBy:p})}}return n}function Jt(t){return t.occurrences.map(e=>`${e.file}:${e.startLine}-${e.endLine}`).sort().join("|")}async function Ku(t,e,n,r,o){let s=ju.join(Ct(t),`${r}-${re}`),i=Me(s),[{groups:a},{groups:c}]=await Promise.all([Oe(e,t,{minLines:o,tokenCache:i}),Oe(n,t,{minLines:o})]);Le(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(m=>!p.has(Jt(m))),resolvedGroups:a.filter(m=>!f.has(Jt(m)))}}function Ca(t){let e=[...t.nodes.values()].map(n=>n.cognitiveComplexity).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function Vu(t,e,n,r){let o=_e(t,{metric:n,threshold:r,limit:1/0}),s=_e(e,{metric:n,threshold:r,limit:1/0}),i=p=>`${p.file}:${p.name}`,a=new Set(o.map(i)),c=new Set(s.map(i));return{base:{avgCognitiveComplexity:Ca(t)},head:{avgCognitiveComplexity:Ca(e)},newHotspots:s.filter(p=>!a.has(i(p))),resolvedHotspots:o.filter(p=>!c.has(i(p)))}}function ka(t){let e=new Set;for(let n of t.nodes.values())if(!(n.type!=="markdown"||!n.staleFor))for(let r of n.staleFor)e.add(`${n.path}::${r}`);return e}function qu(t,e){let n=ka(t),r=ka(e);return{base:{staleCount:n.size},head:{staleCount:r.size},newlyStale:[...r].filter(o=>!n.has(o)),resolved:[...n].filter(o=>!r.has(o))}}function va(t){let e=[...t.nodes.values()].map(n=>n.coveragePct).filter(n=>n!==void 0);return e.length===0?0:e.reduce((n,r)=>n+r,0)/e.length}function Yu(t,e,n){if(!ne(t)||!ne(e))return null;let r=Ge(t,{maxCoveragePct:n,limit:1/0}).hotspots,o=Ge(e,{maxCoveragePct:n,limit:1/0}).hotspots,s=c=>`${c.file}:${c.name}`,i=new Set(r.map(s)),a=new Set(o.map(s));return{base:{avgCoveragePct:va(t)},head:{avgCoveragePct:va(e)},newHotspots:o.filter(c=>!i.has(s(c))),resolvedHotspots:r.filter(c=>!a.has(s(c)))}}async function Br(t,e,n,r={}){let{sha:o,graph:s}=await wa(t,e,r.entryPoints??[],r),i=Wr(t,r.headRef??"HEAD"),[a,c]=await Promise.all([Ku(t,s,n,o,r.minDuplicateLines),Promise.resolve(Yu(s,n,r.maxCoveragePct))]);return{base:{ref:e,sha:o},head:{ref:r.headRef??"HEAD",sha:i},files:Uu(s,n),staleReferences:Ju(s,n),duplication:a,complexity:Vu(s,n,r.complexityMetric,r.complexityThreshold),docDrift:qu(s,n),coverage:c}}var ba,Sa,ue,Ea=d(()=>{"use strict";l();j();ds();Rr();Bt();Ut();Wt();xa();ba=t=>Math.round(t*100)/100,Sa=t=>t.length>8?t.slice(0,8):t;ue=(t,e)=>`${t} ${e}${t===1?"":"s"}`});import Kt from"path";function Qu(t){let e=new Map;for(let[n,r]of t){let o=r.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(n,o)}return e}function Xu(t,e,n){let r=new Map;for(let[o,s]of e){if(s<n)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Kt.extname(o),c=Kt.basename(o,a),p=c==="index"?Kt.basename(Kt.dirname(o)):c;r.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return r}function de(t,e){let n=e?.minOutDegree??5;return Xu(t,Qu(t),n)}var Vt=d(()=>{"use strict";l()});function ed(t,e){let n=new Map;for(let r of e.values()){let o=new Set;t.traverse(r.path,s=>(s.path!==r.path&&o.add(s.path),!0),{direction:"outgoing"}),n.set(r.path,o)}return n}function td(t,e,n,r){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())n.get(a.path)?.has(s)&&(!i||r(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function nd(t,e){let n=new Map;for(let r of t.values()){let o=r.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===r.path&&s.push(i);n.set(o,{hub:r.path,outDegree:r.outDegree,files:s})}return n}function rd(t,e,n){let r=[];for(let o of t.keys())!e.has(o)&&!n.has(o)&&r.push(o);return r}function it(t,e){let n=e?.detectFn??de,r=e?.hubComparator??Zu,o=n(t.nodes,e),s=ed(t,o),i=td(t.nodes,o,s,r);return{features:nd(o,i),unassigned:rd(t.nodes,o,i)}}var Zu,qt=d(()=>{"use strict";l();Vt();Zu=(t,e)=>t.outDegree-e.outDegree});function Ta(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path,n=id(e);for(let r of od)if(r.segments?.some(o=>sd(e,o))||r.basenames?.includes(n))return r.role;return"other"}function sd(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function id(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var od,Fa=d(()=>{"use strict";l();od=[{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 Hr(t,e){let n=it(t,e),r=new Map;for(let[s,i]of n.features){for(let a of i.files)r.set(a,s);r.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=r.get(s.path);o.set(s.path,{path:s.path,role:Ta(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var Ur=d(()=>{"use strict";l();qt();Fa()});function Jr(t,e){let n=[];for(let r of t.nodes.values())if(r.exports.some(o=>o.name===e))if(Lt.has(r.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});n.push({path:r.path,category:r.category,precision:"call",callers:o})}else{let o=st(t,r.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));n.push({path:r.path,category:r.category,precision:"file-level",importers:o})}return n}var Na=d(()=>{"use strict";l();Ot();Ut()});function ad(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function cd(t,e){if(e==="type-only")return!0;let n=t.signature??"";return n.startsWith("interface ")||n.startsWith("class ")||n.startsWith("enum ")}function Kr(t){let e=new Map;for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript"))for(let o of r.exports){if(!cd(o,r.category))continue;let s=`${r.path}::${o.name}`;e.set(s,{name:o.name,file:r.path,kind:ad(o.signature),...o.doc?{doc:o.doc}:{}})}let n=[];for(let r of t.nodes.values())if(!(r.type!=="typescript"&&r.type!=="javascript")){for(let o of r.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&n.push({fromFile:r.path,toType:s,toFile:o.toPath})}return{types:e,edges:n}}function Vr(t,e){let n=null;for(let s of t.types.values())if(s.name===e){n=s;break}if(!n)return{type:null,usedByFiles:[],uses:[]};let r=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===n.file&&r.add(s.fromFile),s.fromFile===n.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:n,usedByFiles:Array.from(r),uses:Array.from(o.values())}}var qr=d(()=>{"use strict";l()});import Pa from"fs";import Gk from"path";function Yt(t){try{return Pa.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Qt(t){try{return Pa.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var at=d(()=>{"use strict";l()});import ld from"fs";import Yr from"path";function Da(t,e=[]){let n;try{n=ld.readdirSync(t,{withFileTypes:!0})}catch{return e}for(let r of n){let o=Yr.join(t,r.name);r.isDirectory()?!fd.has(r.name)&&!r.name.startsWith(".")&&Da(o,e):r.isFile()&&pd.has(Yr.extname(r.name).toLowerCase())&&e.push(o)}return e}function Xt(t,e,n){if(!Yt(e))return null;let r=Da(e);return r.length===0?null:{name:n,root:e,relativeRoot:Yr.relative(t,e),entryPoints:r}}var pd,fd,Qr=d(()=>{"use strict";l();j();at();pd=new Set([".java",".kt",".kts",".scala",".sc",".groovy",".gradle"]),fd=new Set(A)});import Ra from"fs";import Ia from"path";function md(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function ud(t){let e=md(t),n=new Set;for(let r of e.matchAll(/['"](:[A-Za-z0-9_\-.:]+)['"]/g)){let o=r[1].replace(/^:/,"").replace(/:$/,"");o&&n.add(o)}return[...n]}var Aa,Ma=d(()=>{"use strict";l();Qr();Aa={type:"gradle",detect(t){let e=["settings.gradle.kts","settings.gradle"].map(s=>Ia.join(t,s)).find(s=>Ra.existsSync(s));if(!e)return null;let n;try{n=Ra.readFileSync(e,"utf-8")}catch{return null}let r=ud(n);if(r.length===0)return null;let o=[];for(let s of r){let i=Ia.join(t,...s.split(":")),a=Xt(t,i,s);a&&o.push(a)}return o.length>0?o:null}}});import ct from"fs";import L from"path";function Xr(t,e){let n=L.join(e,"package.json");if(!ct.existsSync(n))return null;let r={};try{r=JSON.parse(ct.readFileSync(n,"utf-8"))}catch{return null}let o=r.name;return o?{name:o,root:e,relativeRoot:L.relative(t,e),entryPoints:dd(e,r)}:null}function dd(t,e){let n=[];if(e.exports){let o=e.exports;if(typeof o=="string")n.push(L.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")n.push(L.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&n.push(L.join(t,i))}}}e.main&&n.push(L.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])n.push(L.join(t,o));let r=n.filter(Qt);return r.length>0?r.slice(0,1):n.slice(0,1)}function je(t,e){let n=[],r=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");gd(t,s,r,n)}return n}function gd(t,e,n,r){if(!e.includes("*")){hd(t,e,n,r);return}let o=e.split("/");o.includes("**")?yd(t,o,n,r):xd(t,o,n,r)}function hd(t,e,n,r){let o=L.join(t,e);if(n.has(o)||!Yt(o))return;n.add(o);let s=Xr(t,o);s&&r.push(s)}function yd(t,e,n,r){let o=L.join(t,e[0]==="**"?"":e[0]??"");La(t,o,n,r)}function xd(t,e,n,r){let o=e.findIndex(a=>a.includes("*")),s=L.join(t,...e.slice(0,o)),i;try{i=ct.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=L.join(s,a.name);if(n.has(c))continue;n.add(c);let p=Xr(t,c);p&&r.push(p)}}function La(t,e,n,r){let o;try{o=ct.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=L.join(e,s.name);if(ct.existsSync(L.join(i,"package.json"))&&!n.has(i)){n.add(i);let a=Xr(t,i);a&&r.push(a)}else La(t,i,n,r)}}var Zt=d(()=>{"use strict";l();at();at()});import Zr from"fs";import Oa from"path";var _a,Ga=d(()=>{"use strict";l();Zt();_a={type:"npm",detect(t){let e=Oa.join(t,"package.json");if(!Zr.existsSync(e))return null;let n;try{n=JSON.parse(Zr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n||Zr.existsSync(Oa.join(t,"yarn.lock")))return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:je(t,r)}}});import $e from"fs";import D from"path";function $a(t,e,n,r){if(r>4)return[];let o;try{o=$e.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=D.join(e,a);$e.existsSync(D.join(c,"project.json"))&&!n.has(c)?(n.add(c),s.push(c)):s.push(...$a(t,c,n,r+1))}return s}function bd(t,e,n){let r={};try{r=JSON.parse($e.readFileSync(n,"utf-8"))}catch{return null}let o=r.name,s,i,a=D.join(e,"package.json");if($e.existsSync(a))try{let c=JSON.parse($e.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:D.relative(t,e),entryPoints:Sd(e,r,s,i)}:null}function Sd(t,e,n,r){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=D.resolve(t,"../..");o.push(D.resolve(a,s)),o.push(D.resolve(t,s))}if(r){let a=r;if(typeof a=="string")o.push(D.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(D.join(t,c))}}if(n&&o.push(D.join(t,n)),e.sourceRoot){let a=D.resolve(t,"../.."),c=D.resolve(a,e.sourceRoot);o.push(D.join(c,"index.ts"),D.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(D.join(t,a));let i=o.filter(Qt);return i.length>0?i.slice(0,1):o.slice(0,1)}var ja,Wa=d(()=>{"use strict";l();at();ja={type:"nx",detect(t){return $e.existsSync(D.join(t,"nx.json"))?$a(t,t,new Set,0).map(n=>bd(t,n,D.join(n,"project.json"))).filter(n=>n!==null):null}}});import za from"fs";import Cd from"path";import{load as kd}from"js-yaml";var Ba,Ha=d(()=>{"use strict";l();Zt();Ba={type:"pnpm",detect(t){let e=Cd.join(t,"pnpm-workspace.yaml");if(!za.existsSync(e))return null;let n=[];try{n=kd(za.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return je(t,n)}}});import lt from"fs";import en from"path";function vd(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"")}function wd(t){let e=vd(t),n=new Map;for(let r of e.matchAll(/(?:lazy\s+)?val\s+([A-Za-z0-9_]+)\s*=\s*\(?\s*project\b([^\n]*)/g)){let o=r[1],i=r[2].match(/\bfile\s*\(\s*["']([^"']+)["']\s*\)/),a=i?i[1]:o;if(a==="."||a==="./")continue;let c=a.replace(/^\.\//,"").replace(/\/$/,"");n.has(c)||n.set(c,{name:o,dir:c})}return[...n.values()]}var Ua,Ja=d(()=>{"use strict";l();Qr();Ua={type:"sbt",detect(t){let e=en.join(t,"build.sbt"),n=en.join(t,"project");if(!lt.existsSync(e)||!lt.existsSync(n))return null;let r=[];try{r.push(lt.readFileSync(e,"utf-8"))}catch{return null}try{for(let a of lt.readdirSync(n))a.endsWith(".scala")&&r.push(lt.readFileSync(en.join(n,a),"utf-8"))}catch{}let o=new Set,s=[];for(let a of r)for(let c of wd(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=en.join(t,...a.dir.split("/")),p=Xt(t,c,a.name);p&&i.push(p)}return i.length>0?i:null}}});import Ed from"fs";import Td from"path";var Ka,Va=d(()=>{"use strict";l();Ka={type:"turborepo",detect(t){return Ed.existsSync(Td.join(t,"turbo.json"))?[]:null}}});import eo from"fs";import qa from"path";var Ya,Qa=d(()=>{"use strict";l();Zt();Ya={type:"yarn",detect(t){if(!eo.existsSync(qa.join(t,"yarn.lock")))return null;let e=qa.join(t,"package.json");if(!eo.existsSync(e))return null;let n;try{n=JSON.parse(eo.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!n)return null;let r=Array.isArray(n)?n:n.packages??[];return r.length===0?null:je(t,r)}}});function W(t){Xa.push(t)}function Za(){return Xa}var Xa,tn=d(()=>{"use strict";l();Xa=[]});import Gv from"fs";import $v from"path";var ec=d(()=>{"use strict";l()});import Nd from"path";function to(t,e=Za()){let n=Nd.resolve(t),r=new Map,o=[];for(let i of e){let a=i.detect(n);if(a!==null){o.push(i.type);for(let c of a)r.has(c.name)||r.set(c.name,c)}}if(o.length===0)return{root:n,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(r.values());return{root:n,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var no=d(()=>{"use strict";l();Ma();Ga();Wa();Ha();Ja();Va();Qa();tn();ec();tn();W(Ka);W(ja);W(Ba);W(Ya);W(_a);W(Aa);W(Ua)});var pt,ro=d(()=>{"use strict";l();ve();pt=class t{constructor(e,n){this.monorepoRoot=e;this.type=n}monorepoRoot;type;packages=new Map;addPackage(e,n){this.packages.set(e.name,{graph:n,pkg:e})}annotateCrossPackageEdges(){for(let{graph:e}of this.packages.values())for(let n of e.nodes.values()){let r=this.getPackageForFile(n.path);if(r)for(let o of n.imports){if(o.isExternal||o.isWorkspace)continue;let s=this.getPackageForFile(o.toPath);s&&s.name!==r.name&&(o.isWorkspace=!0,o.workspacePackage=s.name)}}}getPackageForFile(e){for(let{pkg:n}of this.packages.values())if(e===n.relativeRoot||e.startsWith(`${n.relativeRoot}/`))return n}getPackageDependencies(){let e=new Map;for(let{graph:n,pkg:r}of this.packages.values()){let o=new Set;for(let s of n.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(r.name,[...o])}return e}getAffectedAcrossPackages(e){let n=this.getPackageForFile(e);if(!n)return[];let r=this.packages.get(n.name);if(!r)return[];let o=[];r.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:n.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==n.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===n.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:n})=>({pkg:{name:n.name,relativeRoot:n.relativeRoot,entryPoints:n.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let n=new t(e.monorepoRoot,e.type);for(let{pkg:r,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new I(s);n.packages.set(r.name,{graph:i,pkg:{...r,root:""}})}return n}}});function tc(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Pd(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function ft(t,e,n){return rg.every(r=>r(t,e,n))}var Dd,Rd,Id,Ad,Md,Ld,Od,_d,Gd,jd,$d,Wd,zd,Bd,Hd,Ud,Jd,Kd,Vd,qd,Yd,Qd,Xd,Zd,eg,tg,ng,rg,oo=d(()=>{"use strict";l();Dd=(t,e)=>!e.category||tc(t.category,e.category),Rd=(t,e)=>!e.type||tc(t.type,e.type),Id=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,Ad=(t,e)=>!e.path||Pd(t.path,e.path),Md=(t,e)=>e.isExternal===void 0?!0:t.imports.some(r=>r.isExternal)===e.isExternal,Ld=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let n=e.tags.filter(o=>!o.startsWith("!")),r=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(n.length>0&&!n.some(o=>t.tags.some(s=>s.name===o))||r.some(o=>t.tags.some(s=>s.name===o)))},Od=(t,e)=>!e.allTags?.length||e.allTags.every(n=>t.tags.some(r=>r.name===n)),_d=(t,e)=>!e.importsFile||t.imports.some(n=>n.toPath?.includes(e.importsFile)),Gd=(t,e,n)=>e.importedBy===void 0?!0:(n?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),jd=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,$d=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Wd=(t,e)=>e.minSize===void 0||t.size>=e.minSize,zd=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Bd=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Hd=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Ud=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Jd=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Kd=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Vd=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,qd=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Yd=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Qd=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Xd=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Zd=(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,ng=(t,e,n)=>!e.any?.length||e.any.some(r=>ft(t,r,n)),rg=[Dd,Rd,Id,Ad,Md,Ld,Od,_d,Gd,jd,$d,Wd,zd,Bd,Hd,Ud,Jd,Kd,Vd,qd,Yd,Qd,Xd,Zd,eg,tg,ng]});function nn(t,e){let n=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=n.get(a.toPath)??[];c.push(i.path),n.set(a.toPath,c)}}let r=t.nodes.filter(i=>ft(i,e,n)),o=new Set(r.map(i=>i.path)),s=r.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 nc=d(()=>{"use strict";l();oo();oo()});function sg(t,e,n,r){let o=t;switch(n){case"string":o[e]=r;break;case"int":o[e]=parseInt(r,10);break;case"float":o[e]=parseFloat(r);break;case"boolNotFalse":o[e]=r.toLowerCase()!=="false";break;case"boolIsTrue":o[e]=r.toLowerCase()==="true";break}}function oc(t,e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n).trim().toLowerCase(),o=e.slice(n+1).trim();if(!r||!o)return;if(r==="tag"||r==="tags"){o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];return}if(r==="sort"){t.sort=o;return}if(r==="sortdir"){t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";return}let s=og[r];s&&sg(t,s.field,s.kind,o)}function ig(t){let e=[];for(let n of t.split("|")){let r=n.trim();if(!r)continue;let o={};oc(o,r),Object.keys(o).length>0&&e.push(o)}return e}function rn(t){let e={},n=t.split(",");for(let r of n){let o=r.trim();if(o.toLowerCase().startsWith(rc)&&o.endsWith(")")){let s=o.slice(rc.length,-1),i=ig(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}oc(e,r)}return e}var og,rc,sc=d(()=>{"use strict";l();og={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"}};rc="any("});var ic=d(()=>{"use strict";l();nc();sc()});import ag from"path";import P from"typescript";function ge(t,e){let n=t[e];if(n===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return n}function so(t){let e=[];for(let n of t.statements){if(!P.isExpressionStatement(n))continue;let r=n.expression;if(!P.isCallExpression(r))continue;let o=r.expression;P.isIdentifier(o)&&ac.has(o.text)&&e.push(r),P.isPropertyAccessExpression(o)&&P.isIdentifier(o.expression)&&ac.has(o.expression.text)&&e.push(r)}return e}function io(t,e,n){for(let r of t.arguments){if(!P.isObjectLiteralExpression(r))continue;let o=r.properties.find(s=>P.isPropertyAssignment(s)&&P.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!P.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(P.isStringLiteral).map(s=>s.text)}return null}function ao(t,e,n,r){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=ge(t.arguments,s);if(!P.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>P.isPropertyAssignment(p)&&P.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(r),end:a.initializer.getEnd(),text:n};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${n}`}}let o=ge(t.arguments,t.arguments.length-1);return{start:o.getStart(r),end:o.getStart(r),text:`{ ${e}: ${n} }, `}}function co(t,e,n){let r=t.arguments;for(let o=1;o<r.length;o++){let s=ge(r,o);if(!P.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>P.isPropertyAssignment(c)&&P.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:ge(r,o-1).getEnd(),end:s.getEnd(),text:""};let a=ge(s.properties,i);return i===s.properties.length-1?{start:ge(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(n),end:ge(s.properties,i+1).getStart(n),text:""}}return null}function lo(t,e){let n=[...e].sort((o,s)=>s.start-o.start),r=t;for(let o of n)r=r.slice(0,o.start)+o.text+r.slice(o.end);return r}function po(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function cg(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function on(t,e,n,r){let o=P.createSourceFile(ag.basename(t),e,P.ScriptTarget.Latest,!0),s=so(o),[i]=s;if(!i)return e;let a=io(i,r,o),c=[...n].sort();if(a!==null&&JSON.stringify(cg(a).sort())===JSON.stringify(c))return e;let p=po(c.map(m=>`@${m}`)),f=s.flatMap(m=>{let h=n.length===0?co(m,r,o):ao(m,r,p,o);return h?[h]:[]});return f.length>0?lo(e,f):e}var ac,z,We=d(()=>{"use strict";l();ac=new Set(["describe","test","it"]);z=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import lg from"path";var sn,cc=d(()=>{"use strict";l();We();sn=class{name="cypress";canHandle(e){return z.has(lg.extname(e).toLowerCase())}apply(e,n,r){return on(e,n,r,"tags")}}});import pg from"path";function fg(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
|
|
12
30
|
`)}
|
|
13
31
|
|
|
14
|
-
`}function
|
|
15
|
-
`}function
|
|
16
|
-
${
|
|
32
|
+
`}function mg(t){let e=new Set;mo.lastIndex=0;let n=mo.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=mo.exec(t);return e}var fo,mo,an,lc=d(()=>{"use strict";l();fo=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,mo=/^@([a-zA-Z0-9_-]+)/gm;an=class{name="gherkin";canHandle(e){return pg.extname(e).toLowerCase()===".feature"}apply(e,n,r){let o=n.replace(fo,""),s=mg(o),i=r.filter(c=>!s.has(c)),a=i.length>0?fg(i):"";return fo.test(n)?n.replace(fo,a):a?n.replace(/^(Feature:)/m,`${a}$1`):n}}});function pc(t,e){let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/"),o="";for(let s=0;s<n.length;s++){let i=n[s];i==="*"?n[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(r)}var fc=d(()=>{"use strict";l()});import ug from"path";function gg(t){return`//go:build ${t.map(n=>`mokosh_${n}`).join(" || ")}
|
|
33
|
+
`}function hg(t){let e=uo.exec(t);if(!e)return null;let n=e[0]??"",r=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=r.exec(n);for(;s!==null;)s[1]&&o.push(s[1]),s=r.exec(n);return o}var uo,dg,cn,mc=d(()=>{"use strict";l();uo=/^\/\/go:build mokosh_[^\n]+\n/m,dg=/^package\s+\S+/m;cn=class{name="go";canHandle(e){return ug.basename(e).endsWith("_test.go")}apply(e,n,r){let o=hg(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(uo,"");let i=gg(s);if(o!==null)return n.replace(uo,i);let a=dg.exec(n);if(!a)return n;let c=a.index;return`${n.slice(0,c)+i}
|
|
34
|
+
${n.slice(c)}`}}});import yg from"path";function bg(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
|
|
17
35
|
`)}
|
|
18
36
|
|
|
19
|
-
`}function
|
|
20
|
-
|
|
37
|
+
`}function Sg(t){let e=[];go.lastIndex=0;let n=go.exec(t);for(;n!==null;)n[1]&&e.push(n[1]),n=go.exec(t);return e}var xg,go,ln,uc=d(()=>{"use strict";l();We();xg=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,go=/^ \* @group (.+)$/gm;ln=class{name="jest";canHandle(e){return z.has(yg.extname(e).toLowerCase())}apply(e,n,r){let o=xg.exec(n),s=o?Sg(o[0]):null,i=[...r].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return n;let a=o?n.slice(o[0].length):n;return r.length===0?a:bg(i)+a}}});import Cg from"path";function Ng(t){let e=yo.exec(t);if(!e)return null;let n=[],r=/@Tag\("([^"]*)"\)/g,o=r.exec(e[0]);for(;o!==null;)o[1]&&n.push(o[1]),o=r.exec(e[0]);return n}function Pg(t){return`${kg}
|
|
38
|
+
${t.map(e=>`@Tag("${e}")`).join(`
|
|
39
|
+
`)}
|
|
40
|
+
`}function dc(t){if(gc.test(t))return t;let e=wg.exec(t);if(e){let r=e.index+e[0].length;return t.slice(0,r)+ho+`
|
|
41
|
+
`+t.slice(r)}let n=Eg.exec(t);if(n){let r=n.index+n[0].length;return t.slice(0,r)+`
|
|
42
|
+
`+ho+`
|
|
43
|
+
`+t.slice(r)}return ho+`
|
|
44
|
+
`+t}function Dg(t){return/@Tag\b/.test(t)?t:t.replace(gc,"")}var kg,yo,ho,gc,vg,wg,Eg,Tg,Fg,pn,hc=d(()=>{"use strict";l();kg="// mokosh:tags",yo=/^\/\/ mokosh:tags\n(?:[ \t]*@Tag\("[^"]*"\)\n)*/m,ho="import org.junit.jupiter.api.Tag;",gc=/^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,wg=/^import\s+[^\n]+;\n(?![\s\S]*^import\s)/m,Eg=/^package\s+[^\n]+;\n/m,Tg=/\/src\/(test|androidTest|integrationTest|it)\//,Fg=/(Test|Tests|Spec|IT)\.(java|groovy)$/;pn=class{name="junit";canHandle(e){let n=e.replace(/\\/g,"/"),r=Cg.extname(n).toLowerCase();return r!==".java"&&r!==".groovy"?!1:Tg.test(n)||Fg.test(n)}apply(e,n,r){let o=Ng(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return o===null?n:Dg(n.replace(yo,""));let i=Pg(s);if(o!==null)return dc(n.replace(yo,i));let a=vg.exec(n);if(!a)return n;let c=n.slice(0,a.index)+i+n.slice(a.index);return dc(c)}}});import Rg from"path";var fn,yc=d(()=>{"use strict";l();We();fn=class{name="playwright";canHandle(e){return z.has(Rg.extname(e).toLowerCase())}apply(e,n,r){return on(e,n,r,"tag")}}});import Ig from"path";function Mg(t){let e=t.map(n=>`pytest.mark.${n}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Lg(t){let e=xo.exec(t);if(!e)return null;let n=e[0],r=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(n);for(;s!==null;)s[1]&&r.push(s[1]),s=o.exec(n);return r}function Og(t){let e=t.split(`
|
|
45
|
+
`),n=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(n=s)}),n<0?0:e.slice(0,n+1).reduce((o,s)=>o+s.length+1,0)}var xo,Ag,mn,xc=d(()=>{"use strict";l();xo=/^pytestmark\s*=\s*.+$/m,Ag=/^import pytest\s*$/m;mn=class{name="pytest";canHandle(e){return Ig.extname(e).toLowerCase()===".py"}apply(e,n,r){let o=Lg(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return n.replace(xo,"").replace(/\n{3,}/g,`
|
|
21
46
|
|
|
22
|
-
`);let i=
|
|
23
|
-
`,
|
|
47
|
+
`);let i=Mg(s);if(o!==null)return n.replace(xo,i);let a=Ag.test(n),c=Og(n),p=n.slice(0,c),f=n.slice(c),m=a?"":`import pytest
|
|
48
|
+
`,h=p.endsWith(`
|
|
24
49
|
|
|
25
50
|
`)?"":`
|
|
26
|
-
`;return`${p+
|
|
27
|
-
${f}`}}});import
|
|
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 bs(t){let e=new Map;try{let r=Hr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${hs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ys});xs(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=Hr("git",["-C",t,"log","--name-status","-M",`--format=${hs}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ys});xs(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var vt,hs,ys,Jr=m(()=>{"use strict";l();vt=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 Hr("git",s,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
29
|
-
`)
|
|
30
|
-
`&&r++;return r}var Qr=m(()=>{"use strict";l()});function Pp(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 Fs(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(f=>f.type.name==="Block");c&&(o+=ge(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+=Fs(f,e,!0,n):f&&(o+=1+ge(f,e+1,!1,n))}return o}function Es(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 Ip(t,e,r){let n=0,o=t.firstChild;for(;o;)n+=ge(o,e,!1,r),o=o.nextSibling;return n}function Dp(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 Fs(t,e,r,n);if(o==="ForStatement"||o==="SwitchStatement"||o==="SelectStatement")return Es(t,e,n);let s=o==="LogicOp"&&Dp(t,n)?1:0;return e>0&&o==="FunctionLiteral"?s+Es(t,e,n):s+Ip(t,e,n)}function Mp(t,e){return ge(t,0,!1,e)}function Tt(t,e){return{complexity:Pp(t,e),cognitiveComplexity:Mp(t,e)}}function Yr(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 Ns(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}=Tt(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=Yr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=Tt(n.node,e);r.push({name:a,line:Me(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var Ps=m(()=>{"use strict";l();Qr()});import Ap from"path";import{parser as Rp}from"@lezer/go";function Ds(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=Rp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),v=b.match(Lp);v?.[1]&&o.add(v[1]);let G=b.match(Op);G&&Is(G[1],s);let O=b.match(Gp);O&&Is(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"),f=Ap.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",g=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=Tt(a.topNode,e),w=Ns(a,e),E=f==="test"?[]:_p(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(g).map(b=>({name:b,kind:"comment-marker"})),category:f,rawCallEdges:E,complexity:y,cognitiveComplexity:x,...w.length>0?{functions:w}:{}}}function _p(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,g=p.getChild("FieldName");if(f?.type.name==="VariableName"&&g){let y=e.slice(f.from,f.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=Yr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function Is(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var Lp,Op,Gp,Ms=m(()=>{"use strict";l();Ps();Lp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Op=/^\/\/go:build\s+(.+)$/,Gp=/^\/\/\s*\+build\s+(.+)$/});import jp 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 Wp(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 zp(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 Wp(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 Bp(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 Xr(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=Bp(t,e);o&&n.push(o),r.push(...zp(t));for(let s in t){if($p.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...Xr(a,e,r));else n.push(...Xr(i,e,r))}return n}function As(t,e){let r=me(e),n=de(t,r),o=[],s=[];try{o=Xr(jp.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 $p,Rs=m(()=>{"use strict";l();B();wt();$p=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Up from"luaparse";function Hp(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 Jp(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 Kp(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 Vp(t){let e=t.body,r=Jp(e),n=Kp(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=me(e),n=de(t,r),o=[],s=[];try{let i=Up.parse(e);o=Hp(i,t),s=Vp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Os=m(()=>{"use strict";l();B();wt()});async function qp(){return Gs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Gs}function Zp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Qp.some(r=>e.startsWith(r))}function ef(t,e){let r=t.match(Xp);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function _s(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Zp(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(...ef(t.value,e)),Array.isArray(t.children))for(let n of t.children)_s(n,e,r)}async function js(t,e){let n=(await qp()).parse(e),o=[];_s(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 Qp,Yp,Xp,Gs,Ws=m(()=>{"use strict";l();Qp=["http://","https://","mailto:","//"],Yp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Xp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Yp})\\b`,"g")});function tf(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 rf(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],f=n[s+2];p&&(r+=j(p,c)),f&&(r+=j(f,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 nf(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 zs(t,e){let r=1+e,n=t.firstChild;for(;n;)r+=j(n,e+1),n=n.nextSibling;return r}function of(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 rf(t,e);if(r==="TryStatement")return nf(t,e);if(r==="ForStatement"||r==="WhileStatement")return zs(t,e);let n=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?n+zs(t,e):n+of(t,e)}function sf(t){return j(t,0)}function qr(t){return{complexity:tf(t),cognitiveComplexity:sf(t)}}function $s(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=qr(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 f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let g=f.getChild("VariableName"),y=g?e.slice(g.from,g.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=m(()=>{"use strict";l();Qr()});import af from"path";import{parser as cf}from"@lezer/python";function Us(t,e){let r=[],n=[],o=new Set,s=af.basename(t).toLowerCase(),i=cf.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 pf(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=hf(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=qr(i.topNode),g=$s(i,e),y=c==="test"?[]:gf(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,...g.length>0?{functions:g}:{}}}function pf(t,e,r){let n=t.firstChild;return n?n.name==="from"?ff(t,e,r):uf(t,e,r):[]}function ff(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=mf(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(f=>Ae(r,p+f,[f],!1))}function uf(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 mf(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 df(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),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?f+p.replace(/\./g,"/"):f+y;r.set(x,w)}g=g.nextSibling}}while(n.next());return r}function gf(t,e){let r=df(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,g=e.slice(f.from,f.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,f=a.getChild("Body");if(f){let g=f.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 hf(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=>lf.has(n.rawSpecifier))?"test":"logic"}var lf,Hs=m(()=>{"use strict";l();Bs();lf=new Set(["pytest","unittest","nose","hypothesis"])});import S from"typescript";function yf(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 Ks(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+=Ks(t.elseStatement,e,!0):n+=1+te(t.elseStatement,e+1,!1)),n}function Js(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e+1,!1)}),r}function xf(t,e){let r=1+e;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function bf(t,e){let r=0;return S.forEachChild(t,n=>{r+=te(n,e,!1)}),r}function Sf(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 Ks(t,e,r);if(S.isForStatement(t)||S.isForInStatement(t)||S.isForOfStatement(t)||S.isWhileStatement(t)||S.isDoStatement(t)||S.isSwitchStatement(t))return Js(t,e);if(S.isCatchClause(t))return xf(t,e);let n=0;return S.isConditionalExpression(t)&&(n+=1),S.isBinaryExpression(t)&&Sf(t)&&(n+=1),e>0&&(S.isFunctionDeclaration(t)||S.isFunctionExpression(t)||S.isArrowFunction(t))?n+Js(t,e):n+bf(t,e)}function Cf(t){return te(t,0,!1)}function Zr(t){return{complexity:yf(t),cognitiveComplexity:Cf(t)}}var Vs=m(()=>{"use strict";l()});import T from"typescript";function Qs(t,e){kf(t,e),wf(t,e),Tf(t,e),Ef(t,e)}function kf(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&vf(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 vf(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function wf(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 Tf(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 Ef(t,e){if(T.isCallExpression(t)&&Ff(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&Nf(r,e)}function Ff(t){return T.isIdentifier(t)?en.has(t.text):!!(T.isPropertyAccessExpression(t)&&(en.has(t.name.text)||T.isIdentifier(t.expression)&&en.has(t.expression.text)))}function Nf(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 en,Ys=m(()=>{"use strict";l();en=new Set(["test","describe","it"])});import Xs from"path";import h from"typescript";function tn(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=>{Mf(E,a),h.forEachChild(E,c)};c(i);let p=Bf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&Uf(a,i);let f=i.statements[0],g=f?Zs(f):void 0,{complexity:y,cognitiveComplexity:x}=Zr(i),w=Pf(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 Pf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Zr(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 qs(t,e,r,n){let o={name:t},s=Zs(r);s!==void 0&&(o.doc=s);let i=If(e);i!==void 0&&(o.flags=i);let a=Df(e,n);return a!==void 0&&(o.signature=a),o}function Zs(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 If(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 Df(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 Mf(t,e){Af(t,e),Rf(t,e),Of(t,e),Gf(t,e),$f(t,e),Qs(t,e)}function Af(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)||rn(n)).length}function Rf(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)&&!Lf(t)&&(e.hasTypesOnly=!1)}function Lf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Of(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 Gf(t,e){h.isExportDeclaration(t)?_f(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):rn(t)&&zf(t,e)}function _f(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))jf(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 jf(t,e,r){let n=Wf(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 Wf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function zf(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,qs(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,qs(o,n,t,e.sourceFile))}}}function $f(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 Bf(t,e){let r=Xs.basename(t).toLowerCase(),n=Xs.extname(t).toLowerCase();return ye().some(s=>r.includes(s))?"test":Rn(r)?"config":e.imports.some(s=>Gt().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>Wt()?"barrel":"logic"}function rn(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function Uf(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=Jf(o);if(s){let i=Kf(o);i&&Et(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&Hf(o,o.name.text,n,r)}}function Hf(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 Jf(t){if(rn(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 Kf(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 ei=m(()=>{"use strict";l();se();Vs();B();Ys()});function Ft(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 ti=m(()=>{"use strict";l()});function ri(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 ni(t,e){if(e.length===0)return"ui";try{let r=At("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 oi=m(()=>{"use strict";l()});function Re(t,e){let r=$(t);if(r==="stylus"){let s=ri(e,t);return{imports:s,exports:[],tags:[],category:ni(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Ze(e,t);return{imports:s,exports:a,tags:c,category:Ft(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=qe(e,t);return{imports:s,exports:a,tags:c,category:Ft(i,s)}}let{imports:n,root:o}=Xe(e,t);return{imports:n,exports:[],tags:[],category:Ft(o,n)}}var si=m(()=>{"use strict";l();B();ti();rr();nr();oi()});async function ii(t,e){let r=$(t),n=Jo(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var ai=m(()=>{"use strict";l();B();ws();Ts();Ms();Rs();Os();Ws();Hs();ei();Ie();si();se();B();Ie();for(let[t,e]of[["javascript",(r,n)=>tn(r,n,"javascript")],["typescript",(r,n)=>tn(r,n,"typescript")],["css",Re],["scss",Re],["less",Re],["stylus",Re],["coffeescript",vs],["livescript",As],["lua",Ls],["python",Us],["go",Ds],["gherkin",Vr],["markdown",js]])fe(t,e)});import ci from"path";function Vf(t,e){let r=e.get(t.path);r!==void 0&&(t.coveragePct=r)}function pi(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 Qf(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 Yf(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 li(t){return Math.round(t*1e4)/1e4}function Xf(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=li(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(t.avgExportUsage=li(r.reduce((n,o)=>n+o,0)/r.length),t.maxExportUsage=Math.max(...r))}function nn(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function qf(t,e){let r=e.toPath,n=ci.basename(r,ci.extname(r)).replace(/\.(test|spec)$/,"");nn(t.tags,n,"import")}function Zf(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)nn(t.tags,r,"import")}function eu(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&nn(t.tags,o.name,"comment-marker")}function tu(t,e,r){!e.toPath||e.isExternal||(qf(t,e),Zf(t,e),eu(t,e,r))}function fi(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(Xf(r,t),e.size>0&&Vf(r,e),r.category==="test")for(let n of r.imports)Qf(r,n,t),tu(r,n,t);Yf(r,t)}}var ui=m(()=>{"use strict";l()});import gi from"fs";import he from"path";function ru(t,e){let r=t.split(`
|
|
31
|
-
`)
|
|
32
|
-
|
|
33
|
-
`)
|
|
34
|
-
|
|
35
|
-
`)
|
|
36
|
-
|
|
37
|
-
`),
|
|
38
|
-
Warning: failed to parse ${r}: ${o}
|
|
39
|
-
`),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):ii(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:f,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,...f!==void 0?{description:f}:{},...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 Ei=m(()=>{"use strict";l();Vt();Ti();Yt();Zt();ir();nt();ot();we();an();xr();it();kr();Fr();Nr()});var cn=m(()=>{"use strict";l();Ei()});function Fi(t,e){return{identifier:e?.identifier??new kt,featureMap:e?.featureDetection===!1?new Map:V(t.nodes,e?.featureDetection??void 0)}}function Ni(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,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let g=r.get(c.path);if(g)return n(g),!1}return o(c),!0},{direction:"incoming"})}}function ln(t,e,r){let{identifier:n,featureMap:o}=Fi(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return Ni(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 pn(t,e,r){let{identifier:n,featureMap:o}=Fi(t,r),s=new Set;return Ni(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var Pi=m(()=>{"use strict";l();cn();Ur()});var Ii=m(()=>{"use strict";l();gs();Ur();Pi()});import fu 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 Di(t,e={}){let r=$e.resolve(t),n=Er(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`)},f=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,f)}return i}function L(t,e={}){let r=[],n=new Set([...e.ignoreDirs??K,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Ut,...e.additionalExtensions??[]]);function s(i){try{let a=fu.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();Bt();be();jn();zn();Vt();Yt();Zt();ir();nt();ot();cr();we();hr();xr();To();it();kr();Fr();pt();Nr();se();Ie();Xo();Ii();be();cn()});var fn=m(()=>{"use strict";l();be()});import Be from"path";import{parseArgs as uu}from"util";function mu(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 Mi(t){return t?t.split(",").map(e=>e.trim()):void 0}function gu(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(du.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in un&&e.push(n)}return e}function hu(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 yu(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 xu(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 bu(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 Ai(t){let e=mu(t),r=Be.join(Be.resolve(e,ae),ce),{values:n,positionals:o}=uu({args:gu(t),allowPositionals:!0,options:un}),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:Mi(n.paths),featureThreshold:H(n["feature-threshold"]),minOutDegree:H(n["min-out-degree"]),...hu(c),...yu(c),help:t.length===0||(n.help??!1),...xu(c),changedSymbols:Mi(n["changed-symbols"]),depth:H(n.depth),...bu(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"]),base:n.base,entryPoints:o}}var un,du,Ri=m(()=>{"use strict";l();fn();un={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"}},du=new Set(Object.entries(un).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function mn(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(g=>({path:g,...Y(e,g)})):f;if(s){let f=Xt(e),g=qt(f,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=pr(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var Li=m(()=>{"use strict";l();k()});import dn from"path";function ne(t){return t.filter(e=>{let r=dn.basename(e).toLowerCase();return Su.some(n=>r.includes(n))})}function Pt(t,e){return new vt().getChangedFiles(t,e).map(r=>dn.relative(t,dn.resolve(t,r)))}var Su,It=m(()=>{"use strict";l();Jr();Su=[".test.",".spec.","-test.","-spec."]});async function Oi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s,base:i}=t,a=Pt(r,i);if(![...e.nodes.values()].some(f=>ne([f.path]).length>0)){let f=L(r,n);e=await R(r,ne(f),e,N(s))}let p=pn(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
|
|
40
|
-
`))}var Gi=m(()=>{"use strict";l();k();It()});async function _i(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:Jt(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=Kt(e,o);console.log(JSON.stringify(s,null,2))}var ji=m(()=>{"use strict";l();k()});async function Wi(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 Br(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var zi=m(()=>{"use strict";l();k();It()});async function $i(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Qt(e,r);console.log(JSON.stringify(n,null,2))}var Bi=m(()=>{"use strict";l();k()});async function gn(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=fr(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 Ui=m(()=>{"use strict";l();k()});async function hn(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
|
|
42
|
-
`);for(let n of r)process.stderr.write(` ${n.join(" \u2192 ")}
|
|
43
|
-
`);process.exit(1)}console.log("No cycles detected.")}var Hi=m(()=>{"use strict";l()});async function yn(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
|
-
`);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 Ji=m(()=>{"use strict";l()});import Ki from"fs";import Vi from"path";function Qi(t){let e=Vi.join(Vi.dirname(t),xe),r=!1;for(let n of[t,e])Ki.existsSync(n)&&(Ki.unlinkSync(n),console.log(`Cache cleared: ${n}`),r=!0);r||console.log(`No cache file present at ${t}`)}var Yi=m(()=>{"use strict";l();k()});async function xn(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=lr(e,r,n??1),i=o?s.map(a=>({...a,...Y(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var Xi=m(()=>{"use strict";l();k()});async function bn(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=Te(e,r),s=n?o.map(i=>({...i,...Y(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var qi=m(()=>{"use strict";l();k()});async function Zi(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 R(r,c,e,N(s))}let i=V(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 ea=m(()=>{"use strict";l();k()});async function ta(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 R(r,c,e,N(s))}let i=ke(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 ra=m(()=>{"use strict";l();k()});async function Sn(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=ur(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var na=m(()=>{"use strict";l();k()});import oa from"path";async function Cn(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s,cachePath:i}=t,a=o??6,c=[...n.ignoreDirs??K,...n.additionalIgnoreDirs??[]],p=oa.join(oa.dirname(i),xe),f=et(p),{groups:g}=await sr(e,r,{minLines:a,limit:s,ignoreDirs:c,tokenCache:f});tt(f,p),console.log(JSON.stringify({minLines:a,groups:g,count:g.length},null,2))}var sa=m(()=>{"use strict";l();k()});async function kn(t){let{graph:e,metric:r,complexityThreshold:n,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!Ee(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:g,churnDataAvailable:y}=gr(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:g},null,2))}var ia=m(()=>{"use strict";l();k()});async function aa(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=br(e,r);console.log(n?o.map(s=>s.path).join(`
|
|
46
|
-
`):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var ca=m(()=>{"use strict";l();k()});async function vn(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!Ee(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(`
|
|
47
|
-
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var la=m(()=>{"use strict";l();k()});import Cu from"path";function vu(t){let e=Cu.basename(t).toLowerCase();return ku.some(r=>e.includes(r))}async function pa(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=L(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!vu(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var ku,fa=m(()=>{"use strict";l();k();ku=[".test.",".spec.","-test.","-spec.",".stories."]});async function wn(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=ut(r);s=ft(s,c)}if(n){let c=D.deserialize(s);console.log(Qe.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=ar(e);console.log(JSON.stringify(o?{...mr(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var ua=m(()=>{"use strict";l();k()});import wu from"fs";import Tn from"path";function Dt(t,e,r){let n=t;for(let o=0;o<6;o++){let s=Tn.join(n,"templates",...e);if(wu.existsSync(Tn.join(s,r)))return s;let i=Tn.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var En=m(()=>{"use strict";l()});import ma from"fs";import da from"path";function ga(t,e=process.cwd()){let r=Dt(u,["config"],"mokosh.config.js"),n=da.join(r,"mokosh.config.js"),o=da.join(e,"mokosh.config.js");if(ma.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}ma.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var ha=m(()=>{"use strict";l();En()});import Fn from"fs";import Mt from"path";function ya(t,e=process.cwd()){let r=Dt(u,["skill"],"SKILL.md");for(let n of Tu){let o=Mt.join(r,n.templateFile),s=Mt.join(e,...n.destPath),i=Mt.join(...n.destPath);if(Fn.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Fn.mkdirSync(Mt.dirname(s),{recursive:!0}),Fn.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Tu,xa=m(()=>{"use strict";l();En();Tu=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function Nn(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(`
|
|
48
|
-
`):JSON.stringify({tags:o,count:o.length},null,2))}var ba=m(()=>{"use strict";l()});async function Sa(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=yr(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 Ca=m(()=>{"use strict";l();k()});async function ka(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=Pt(r,a);if(e.nodes.size===0){let f=L(r,n);e=await R(r,ne(f),e,N(i))}let p=ln(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?p.join(" "):JSON.stringify({proposedTags:p},null,2))}var va=m(()=>{"use strict";l();k();It()});async function wa(t){let{graph:e,typeFilter:r}=t,n=Sr(e);if(r){let o=Cr(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 Ta=m(()=>{"use strict";l();k()});function Ea(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var Fa=m(()=>{"use strict";l()});function Na(t){console.log(JSON.stringify(dr(t),null,2))}var Pa=m(()=>{"use strict";l();k()});import Pn from"path";function Eu(t,e,r,n){return t!==e?t:r?Pn.resolve(n,r):e}function Ia(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?ie(o,{isExplicitPath:!0}):ie(e),i=Pn.join(Pn.resolve(e,ae),ce),a=r.length>0?r:s.entryPoints??[],c=Eu(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 Da=m(()=>{"use strict";l();k();fn()});import Ue from"fs";import Fu from"path";function Ma(t){if(!Ue.existsSync(t))return null;let e=Ue.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}function In(t,e){let r=Fu.dirname(e);Ue.existsSync(r)||Ue.mkdirSync(r,{recursive:!0}),Ue.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Dn(t,e,r,n={silent:!1,...N(void 0)}){return R(t,e,r,n)}var Aa=m(()=>{"use strict";l();k()});var Ra,La,Oa=m(()=>{"use strict";l();Ra=`
|
|
51
|
+
`;return`${p+h+m+i}
|
|
52
|
+
${f}`}}});import _g from"path";function Wg(t){let e=bo.exec(t);return e?e[0].replace(/^\/\/ mokosh:tags /,"").trim().split(/\s*,\s*/).filter(Boolean):null}var bo,Gg,jg,$g,un,bc=d(()=>{"use strict";l();bo=/^\/\/ mokosh:tags .*\n/m,Gg=/^(?:sealed\s+|abstract\s+|final\s+|private\s+|implicit\s+|case\s+)*(?:class|object|trait)\s+\w+/m,jg=/\/src\/(test|it)\//,$g=/(Spec|Suite|Test|Props)\.scala$/;un=class{name="scalatest";canHandle(e){let n=e.replace(/\\/g,"/");return _g.extname(n).toLowerCase()!==".scala"?!1:jg.test(n)||$g.test(n)}apply(e,n,r){let o=Wg(n),s=[...r].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return n;if(r.length===0)return o===null?n:n.replace(bo,"");let i=`// mokosh:tags ${s.join(", ")}
|
|
53
|
+
`;if(o!==null)return n.replace(bo,i);let a=Gg.exec(n);return a?n.slice(0,a.index)+i+n.slice(a.index):n}}});import Sc from"path";import Cc from"typescript";var zg,dn,kc=d(()=>{"use strict";l();We();zg=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,dn=class{name="vitest";canHandle(e){return z.has(Sc.extname(e).toLowerCase())}apply(e,n,r){let o=n.replace(zg,""),s=Cc.createSourceFile(Sc.basename(e),o,Cc.ScriptTarget.Latest,!0),i=so(s),[a]=i;if(!a)return o;let c=io(a,"tags",s),p=[...r].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(m=>{let h=r.length===0?co(m,"tags",s):ao(m,"tags",po(p),s);return h?[h]:[]});return f.length>0?lo(o,f):o}}});import So from"path";import gn from"typescript";function Hg(t){let e=gn.createSourceFile("detect.ts",t,gn.ScriptTarget.Latest,!0);for(let n of e.statements){if(!gn.isImportDeclaration(n)||!gn.isStringLiteral(n.moduleSpecifier))continue;let r=Bg[n.moduleSpecifier.text];if(r)return r}return null}function wc(t="vitest",e={},n=process.cwd()){return[new an,new mn,new cn,new pn,new un,new Co(n,t,Object.entries(e))]}function Ec(t,e){return e.find(n=>n.canHandle(t))??null}var vc,Bg,Co,Tc=d(()=>{"use strict";l();cc();lc();fc();mc();uc();hc();yc();xc();bc();We();kc();vc={vitest:()=>new dn,playwright:()=>new fn,cypress:()=>new sn,jest:()=>new ln},Bg={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Co=class{constructor(e,n,r){this.rootDir=e;this.defaultFramework=n;this.frameworkOverrides=r}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return z.has(So.extname(e).toLowerCase())}apply(e,n,r){let o=Hg(n)??this.matchOverride(e)??this.defaultFramework;return(vc[o]??vc.vitest)().apply(e,n,r)}matchOverride(e){let n=So.relative(this.rootDir,e).split(So.sep).join("/");for(let[r,o]of this.frameworkOverrides)if(pc(r,n))return o;return null}}});import Fc from"fs/promises";import Ug from"path";async function qg(t,e,n,r){let o;try{o=await Fc.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=Ec(t,r);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(n||await Fc.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function ko(t,e,n){let r=Se(e),o=r.tagApplier?.framework??"vitest",s=r.tagApplier?.frameworkOverrides??{},i=wc(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 y of c.tags)Kg.has(y.kind)&&Jg.test(y.name)&&(Vg.has(y.name.toLowerCase())||p.has(y.name)||(p.add(y.name),f.push(y.name)));f.sort();let m=Ug.resolve(e,c.path),h=await qg(m,f,n.dryRun,i);h.path=c.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var Jg,Kg,Vg,Nc=d(()=>{"use strict";l();In();Tc();Jg=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Kg=new Set(["import"]),Vg=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var hn,vo=d(()=>{"use strict";l();hn=class{isTestNode(e){return e.category==="test"||e.tags.some(n=>n.name==="test")}}});var Pc=d(()=>{"use strict";l();St();_n();Rr();jn();zn();Bt();Vt();qt();ve();Wt();Ur();Ht();qr();no();ro()});var wo=d(()=>{"use strict";l();Pc()});function Dc(t,e){return{identifier:e?.identifier??new hn,featureMap:e?.featureDetection===!1?new Map:de(t.nodes,e?.featureDetection??void 0)}}function Rc(t,e,n,r,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new fe(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let m=n.get(c.path);if(m)return r(m),!1}return o(c),!0},{direction:"incoming"})}}function Eo(t,e,n){let{identifier:r,featureMap:o}=Dc(t,n),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return Rc(t,e,o,i=>s.add(i.tag),i=>{if(r.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function To(t,e,n){let{identifier:r,featureMap:o}=Dc(t,n),s=new Set;return Rc(t,e,o,()=>{},i=>{r.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var Ic=d(()=>{"use strict";l();wo();vo()});var Ac=d(()=>{"use strict";l();Nc();vo();Ic()});import iT from"crypto";import Yg from"fs";import Qg from"os";import he from"path";async function _(t,e,n=null,r={}){let o=r.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=he.resolve(t);return await new pe(s,n,r.pathAliases?new K(s,{pathAliases:r.pathAliases}):void 0,o,r.gitStats??!1,r.coverageMap??new Map,r.parallelParsing??!0,r.additionalIgnoreDirs??[],r.docFiles??null).build(e)}function Xg(t){let e=Number.parseInt(process.env.MOKOSH_WORKSPACE_CONCURRENCY??"",10),n=Number.isFinite(e)&&e>0?e:Qg.cpus().length||1;return Math.max(1,Math.min(n,Math.max(1,t)))}function Zg(t,e,n){let r=new Map(e.map(s=>[s.name,[]])),o=[...e].sort((s,i)=>i.root.length-s.root.length);for(let s of n){if(!s.endsWith(".md")&&!s.endsWith(".mdx"))continue;let i=he.join(t,s),a=o.find(c=>i===c.root||i.startsWith(`${c.root}${he.sep}`));a&&r.get(a.name)?.push(i)}return r}async function Mc(t,e={}){let n=he.resolve(t),r=e.layout??to(n),o=e.projectFiles??O(n),s=e.additionalIgnoreDirs??[],i=e.packages?r.packages.filter(C=>e.packages?.includes(C.name)||e.packages?.includes(C.relativeRoot)):r.packages,a=new Map(r.packages.map(C=>[C.name,C.root])),c=new pt(n,r.type),p=new le(s),f=Zg(n,i,o),m=Xg(i.length),h=m>1?!1:e.parallelParsing??!0,y=new Array(i.length),b=0,v=async()=>{for(let C=b++;C<i.length;C=b++){let E=i[C],G=e.silent?void 0:F=>{process.stderr.write(`[${E.name}] Processed ${F} files...\r`)},S=new pe(n,e.previousWorkspace?.packages.get(E.name)?.graph??null,new K(n,{workspaceMap:a,tsconfigSearchPaths:[E.root,n],pathAliases:e.pathAliases,langResolvers:jt({jvm:p})}),G,e.gitStats??!1,new Map,h,s,f.get(E.name)??[]);y[C]=await S.build(E.entryPoints)}};return await Promise.all(Array.from({length:m},v)),i.forEach((C,E)=>{c.addPackage(C,y[E])}),c.annotateCrossPackageEdges(),c}function O(t,e={}){let n=[],r=new Set([...e.ignoreDirs??A,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??An,...e.additionalExtensions??[]]);function s(i){try{let a=Yg.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=he.join(i,c.name);c.isDirectory()?r.has(c.name)||s(p):c.isFile()&&o.has(he.extname(c.name).toLowerCase())&&n.push(he.relative(t,p))}}catch{}}return s(t),n}var w=d(()=>{"use strict";l();In();j();os();is();St();_n();jn();zn();Ea();Bt();Vt();qt();Ot();ve();Ut();Ur();Na();Ht();qr();no();tn();ro();be();Ke();ic();Ac();j();wo();Dr()});var Fo=d(()=>{"use strict";l();j()});import mt from"path";import{parseArgs as eh}from"util";function th(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return mt.resolve(t[e+1]);return process.cwd()}function V(t){return t?parseInt(t,10):void 0}function Lc(t){return t?t.split(",").map(e=>e.trim()):void 0}function rh(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r!==void 0)if(!r.startsWith("--"))e.push(r);else if(nh.has(r)){let o=t[n+1];o!==void 0&&!o.startsWith("--")&&(e.push(r,o),n++)}else r.slice(2)in No&&e.push(r)}return e}function oh(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 sh(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 ih(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 ah(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 Oc(t){let e=th(t),n=mt.join(mt.resolve(e,Q),Ce),{values:r,positionals:o}=eh({args:rh(t),allowPositionals:!0,options:No}),s=r.cache,i=r.config,a=r.metric,c=r;return{rootDir:e,cachePath:s?mt.resolve(e,s):n,configPath:i?mt.resolve(e,i):void 0,query:r.query,file:r.file,typeFilter:r.type,functionName:r.function,filterPaths:Lc(r.paths),featureThreshold:V(r["feature-threshold"]),minOutDegree:V(r["min-out-degree"]),...oh(c),...sh(c),help:t.length===0||(r.help??!1),...ih(c),changedSymbols:Lc(r["changed-symbols"]),depth:V(r.depth),...ah(c),metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:V(r["complexity-threshold"]),limit:V(r.limit),minDuplicateLines:V(r["min-duplicate-lines"]),includeGenerated:r["include-generated"]??!1,maxCoveragePct:V(r["max-coverage-pct"]),minChurn:V(r["min-churn"]),base:r.base,compareBranches:r["compare-branches"],compareFull:r["compare-full"]??!1,compareMaxItems:V(r["compare-max-items"]),entryPoints:o}}var No,nh,_c=d(()=>{"use strict";l();Fo();No={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"},"include-generated":{type:"boolean"},"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"}},nh=new Set(Object.entries(No).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function Po(t){let{graph:e,file:n,testsOnly:r,changedSymbols:o,cached:s,withMeta:i}=t;n||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(m=>({path:m,...me(e,m)})):f;if(s){let f=$n(e),m=Wn(f,n),h=r?m.filter(b=>e.nodes.get(b)?.category==="test"):m,y=a(h);console.log(JSON.stringify({file:n,affected:y,count:y.length},null,2));return}let c=Lr(e,n,{testsOnly:r,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:n,affected:p,count:p.length},null,2))}var Gc=d(()=>{"use strict";l();w()});import Do from"path";function ye(t){return t.filter(e=>{let n=Do.basename(e).toLowerCase();return ch.some(r=>n.includes(r))})}function yn(t,e){return new kt().getChangedFiles(t,e).map(n=>Do.relative(t,Do.resolve(t,n)))}var ch,xn=d(()=>{"use strict";l();Hn();ch=[".test.",".spec.","-test.","-spec."]});async function jc(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s,base:i}=t,a=yn(n,i);if(![...e.nodes.values()].some(f=>ye([f.path]).length>0)){let f=O(n,r);e=await _(n,ye(f),e,N(s))}let p=To(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(p.join(`
|
|
54
|
+
`))}var $c=d(()=>{"use strict";l();w();xn()});async function Wc(t){let{graph:e,rootDir:n,entryPoints:r}=t,o=r.length?r:Ln(e,n);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=On(e,o);console.log(JSON.stringify(s,null,2))}var zc=d(()=>{"use strict";l();w()});async function Bc(t){let{graph:e}=t,{rootDir:n,scanOptions:r,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=O(n,r);e=await _(n,ye(c),e,N(i))}let a=await ko(e,n,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Hc=d(()=>{"use strict";l();w();xn()});async function Uc(t){let{graph:e,functionName:n}=t;n||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let r=Gn(e,n);console.log(JSON.stringify(r,null,2))}var Jc=d(()=>{"use strict";l();w()});async function Ro(t){let{graph:e,file:n,plain:r,depth:o,withEdgeDetail:s}=t;n||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=Or(e,n,{depth:o??1,withEdgeDetail:s});console.log(r?i.map(a=>a.file).join(`
|
|
55
|
+
`):JSON.stringify({file:n,callers:i,count:i.length},null,2))}var Kc=d(()=>{"use strict";l();w()});async function Io(t){let{graph:e}=t,n=e.findCycles();if(n.length>0){process.stderr.write(`Found ${n.length} cycle(s):
|
|
56
|
+
`);for(let r of n)process.stderr.write(` ${r.join(" \u2192 ")}
|
|
57
|
+
`);process.exit(1)}console.log("No cycles detected.")}var Vc=d(()=>{"use strict";l()});async function Ao(t){let{graph:e}=t,n=[...e.nodes.values()].filter(r=>r.type==="markdown"&&r.staleFor&&r.staleFor.length>0).map(r=>({doc:r.path,staleFor:r.staleFor}));if(n.length>0){process.stderr.write(`Found ${n.length} doc(s) that may be out of date:
|
|
58
|
+
`);for(let{doc:r,staleFor:o}of n)process.stderr.write(` ${r} \u2014 references changed more recently: ${o.join(", ")}
|
|
59
|
+
`);process.exit(1)}console.log("No doc drift detected.")}var qc=d(()=>{"use strict";l()});import bn from"fs";import Mo from"path";function Yc(t){let e=Mo.dirname(t),n=Mo.join(e,re),r=Mo.join(e,Be),o=!1;for(let s of[t,n])bn.existsSync(s)&&(bn.unlinkSync(s),console.log(`Cache cleared: ${s}`),o=!0);bn.existsSync(r)&&(bn.rmSync(r,{recursive:!0,force:!0}),console.log(`Cache cleared: ${r}`),o=!0),o||console.log(`No cache file present at ${t}`)}var Qc=d(()=>{"use strict";l();w()});async function Xc(t){let{graph:e,rootDir:n,compareBranches:r,rawConfig:o}=t;if(!r){console.error("Error: --compare-branches requires a base ref, e.g. --compare-branches main"),process.exit(1);return}let s=await Br(n,r,e,{entryPoints:t.entryPoints,minDuplicateLines:t.minDuplicateLines,complexityMetric:t.metric,complexityThreshold:t.complexityThreshold,maxCoveragePct:t.maxCoveragePct,...N(o)}),i=t.compareFull?s:zr(s,{metric:t.metric,maxItems:t.compareMaxItems});console.log(JSON.stringify(i,null,2))}var Zc=d(()=>{"use strict";l();w()});async function Lo(t){let{graph:e,file:n,depth:r,withMeta:o}=t;n||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=Mr(e,n,r??1),i=o?s.map(a=>({...a,...me(e,a.path)})):s;console.log(JSON.stringify({file:n,dependencies:i},null,2))}var el=d(()=>{"use strict";l();w()});async function Oo(t){let{graph:e,file:n,withMeta:r}=t;n||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=st(e,n),s=r?o.map(i=>({...i,...me(e,i.path)})):o;console.log(JSON.stringify({file:n,dependents:s},null,2))}var tl=d(()=>{"use strict";l();w()});async function nl(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=O(n,r);e=await _(n,c,e,N(s))}let i=de(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 rl=d(()=>{"use strict";l();w()});async function ol(t){let{graph:e}=t,{rootDir:n,scanOptions:r,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=O(n,r);e=await _(n,c,e,N(s))}let i=it(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 sl=d(()=>{"use strict";l();w()});async function _o(t){let{graph:e,metric:n,complexityThreshold:r,limit:o}=t,s=r??10,i=_e(e,{metric:n,threshold:s,limit:o});console.log(JSON.stringify({metric:n??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var il=d(()=>{"use strict";l();w()});import al from"path";async function Go(t){let{graph:e,rootDir:n,scanOptions:r,minDuplicateLines:o,includeGenerated:s,limit:i,cachePath:a}=t,c=o??6,p=[...r.ignoreDirs??A,...r.additionalIgnoreDirs??[]],f=al.join(al.dirname(a),re),m=Me(f),{groups:h}=await Oe(e,n,{minLines:c,limit:i,ignoreDirs:p,includeGenerated:s||t.rawConfig.duplication?.includeGenerated||!1,ignoreGlobs:t.rawConfig.duplication?.ignoreGlobs??[],tokenCache:m});Le(m,f),console.log(JSON.stringify({minLines:c,groups:h,count:h.length},null,2))}var cl=d(()=>{"use strict";l();w()});async function jo(t){let{graph:e,metric:n,complexityThreshold:r,maxCoveragePct:o,minChurn:s,limit:i}=t;if(!ne(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let a=r??10,c=o??50,p=s??0,{hotspots:f,count:m,churnDataAvailable:h}=Ge(e,{metric:n,minComplexity:a,maxCoveragePct:c,minChurn:p,limit:i});console.log(JSON.stringify({metric:n??"cognitiveComplexity",minComplexity:a,maxCoveragePct:c,minChurn:p,churnDataAvailable:h,hotspots:f,count:m},null,2))}var ll=d(()=>{"use strict";l();w()});async function pl(t){let{graph:e,functionName:n,plain:r}=t;n||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=Jr(e,n);console.log(r?o.map(s=>s.path).join(`
|
|
60
|
+
`):JSON.stringify({name:n,matches:o,count:o.length},null,2))}var fl=d(()=>{"use strict";l();w()});async function $o(t){let{graph:e,featureThreshold:n,rawConfig:r,plain:o}=t,s=n??r.coverageThreshold??80;if(!ne(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(`
|
|
61
|
+
`):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var ml=d(()=>{"use strict";l();w()});import lh from"path";function fh(t){let e=lh.basename(t).toLowerCase();return ph.some(n=>e.includes(n))}async function ul(t){let{graph:e,rootDir:n,scanOptions:r,excludeTests:o}=t,s=O(n,r),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!fh(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var ph,dl=d(()=>{"use strict";l();w();ph=[".test.",".spec.","-test.","-spec.",".stories."]});async function Wo(t){let{graph:e,queryStr:n,mermaidOutput:r,slim:o}=t,s=e.serialize();if(n){let c=rn(n);s=nn(s,c)}if(r){let c=I.deserialize(s);console.log(bt.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=Sr(e);console.log(JSON.stringify(o?{..._r(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var gl=d(()=>{"use strict";l();w()});import mh from"fs";import zo from"path";function Sn(t,e,n){let r=t;for(let o=0;o<6;o++){let s=zo.join(r,"templates",...e);if(mh.existsSync(zo.join(s,n)))return s;let i=zo.dirname(r);if(i===r)break;r=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var Bo=d(()=>{"use strict";l()});import hl from"fs";import yl from"path";function xl(t,e=process.cwd()){let n=Sn(u,["config"],"mokosh.config.js"),r=yl.join(n,"mokosh.config.js"),o=yl.join(e,"mokosh.config.js");if(hl.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}hl.copyFileSync(r,o),console.log("wrote mokosh.config.js")}var bl=d(()=>{"use strict";l();Bo()});import Ho from"fs";import Cn from"path";function Sl(t,e=process.cwd()){let n=Sn(u,["skill"],"SKILL.md");for(let r of uh){let o=Cn.join(n,r.templateFile),s=Cn.join(e,...r.destPath),i=Cn.join(...r.destPath);if(Ho.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}Ho.mkdirSync(Cn.dirname(s),{recursive:!0}),Ho.copyFileSync(o,s),console.log(`wrote ${i}`)}}var uh,Cl=d(()=>{"use strict";l();Bo();uh=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function Uo(t){let{graph:e,plain:n}=t,r=new Map;for(let s of e.nodes.values())for(let i of s.tags)r.set(i.name,(r.get(i.name)??0)+1);let o=[...r.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(n?o.map(s=>s.name).join(`
|
|
62
|
+
`):JSON.stringify({tags:o,count:o.length},null,2))}var kl=d(()=>{"use strict";l()});async function vl(t){let{graph:e,filterPaths:n,minOutDegree:r}=t,o=Hr(e,r!==void 0?{minOutDegree:r}:void 0);if(n?.length){let s=n.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var wl=d(()=>{"use strict";l();w()});async function El(t){let{graph:e}=t,{rootDir:n,scanOptions:r,featureThreshold:o,plain:s,rawConfig:i,base:a}=t;s||console.log("Proposing test tags based on git diff...");let c=yn(n,a);if(e.nodes.size===0){let f=O(n,r);e=await _(n,ye(f),e,N(i))}let p=Eo(e,c,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?p.join(" "):JSON.stringify({proposedTags:p},null,2))}var Tl=d(()=>{"use strict";l();w();xn()});async function Fl(t){let{graph:e,typeFilter:n}=t,r=Kr(e);if(n){let o=Vr(r,n);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(r.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var Nl=d(()=>{"use strict";l();w()});function Pl(t,e){let n=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:n,count:n.length},null,2))}var Dl=d(()=>{"use strict";l()});function Rl(t){console.log(JSON.stringify(Gr(t),null,2))}var Il=d(()=>{"use strict";l();w()});import Jo from"path";function dh(t,e,n,r){return t!==e?t:n?Jo.resolve(r,n):e}function Al(t){let{rootDir:e,entryPoints:n,cachePath:r,configPath:o}=t,s=o?Se(o,{isExplicitPath:!0}):Se(e),i=Jo.join(Jo.resolve(e,Q),Ce),a=n.length>0?n:s.entryPoints??[],c=dh(r,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 Ml=d(()=>{"use strict";l();w();Fo()});import ut from"fs";import gh from"path";function Ll(t){if(!ut.existsSync(t))return null;let e=ut.readFileSync(t,"utf-8");return I.deserialize(JSON.parse(e))}function Ko(t,e){let n=gh.dirname(e);ut.existsSync(n)||ut.mkdirSync(n,{recursive:!0}),ut.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function Vo(t,e,n,r={silent:!1,...N(void 0)}){return _(t,e,n,r)}var Ol=d(()=>{"use strict";l();w()});var _l,Gl,jl=d(()=>{"use strict";l();_l=`
|
|
49
63
|
Usage: mokosh [options] <entry-point1> <entry-point2> ...
|
|
50
64
|
|
|
51
65
|
Options:
|
|
@@ -110,16 +124,26 @@ MCP parity (mirrors the MCP server's tools for use when MCP is unavailable):
|
|
|
110
124
|
--complexity-threshold <N> Minimum score to include (default: 10, use with --find-complex-functions)
|
|
111
125
|
--limit <N> Max results for --find-complex-functions/--find-duplicates
|
|
112
126
|
--find-duplicates Find duplicated code blocks (token-based, works for every parsed
|
|
113
|
-
language), largest-first. Lock files
|
|
114
|
-
directory (--config's ignoreDirs, merged with the defaults)
|
|
115
|
-
always excluded
|
|
127
|
+
language), largest-first. Lock files, files under an ignored
|
|
128
|
+
directory (--config's ignoreDirs, merged with the defaults), and
|
|
129
|
+
generated / vendored files are always excluded
|
|
116
130
|
--min-duplicate-lines <N> Minimum duplicated block size in lines to report (default: 6,
|
|
117
131
|
use with --find-duplicates)
|
|
132
|
+
--include-generated Scan generated / vendored files too (protobuf output, *.generated.*,
|
|
133
|
+
generated/ & __snapshots__/ dirs, *.snap, @generated-marked
|
|
134
|
+
files); use with --find-duplicates
|
|
118
135
|
--find-risk-hotspots List functions that are complex, undertested, and (if gitStats is
|
|
119
136
|
enabled) frequently changed \u2014 requires coverageReportPath in config
|
|
120
137
|
--max-coverage-pct <N> Max file coverage % to include (default: 50, use with --find-risk-hotspots)
|
|
121
138
|
--min-churn <N> Min 90-day commit count to include (default: 0, ignored if gitStats
|
|
122
139
|
is off; use with --find-risk-hotspots)
|
|
140
|
+
--compare-branches <ref> Review a PR/branch: diff the current graph against <ref> (via a
|
|
141
|
+
temporary git worktree) \u2014 file changes, stale post-rename
|
|
142
|
+
references, and duplication/complexity/doc-drift/coverage deltas
|
|
143
|
+
--compare-full Print the complete BranchComparison instead of the compact summary
|
|
144
|
+
(use with --compare-branches)
|
|
145
|
+
--compare-max-items <N> Entries kept per summary delta list (default: 8; true counts always
|
|
146
|
+
reported; use with --compare-branches)
|
|
123
147
|
--workspace-packages List monorepo packages and their cross-package dependencies
|
|
124
148
|
--workspace-affected Cross-package blast-radius for --file in a monorepo
|
|
125
149
|
--find-symbol Find every file that exports --function <name> by exact name, with
|
|
@@ -140,7 +164,7 @@ Notes:
|
|
|
140
164
|
server only loads JSON config (allowJs: false) for security. This is intentional.
|
|
141
165
|
--workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
|
|
142
166
|
which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
|
|
143
|
-
`,
|
|
167
|
+
`,Gl=`
|
|
144
168
|
Query filter reference (--query "key:value,key:value,...")
|
|
145
169
|
All keys are case-insensitive. Multiple keys are AND'd together.
|
|
146
170
|
|
|
@@ -263,5 +287,5 @@ COMMON PATTERNS
|
|
|
263
287
|
|
|
264
288
|
Large TypeScript logic files:
|
|
265
289
|
--query "type:typescript,category:logic,sort:size,limit:5"
|
|
266
|
-
`});var
|
|
290
|
+
`});var $l,Wl=d(()=>{"use strict";l();$l=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import hh from"fs";function zl(t,e,n){let r=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await n()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=hh.watch(t,{recursive:!0},(c,p)=>{!p||$l.test(p)||(r&&clearTimeout(r),r=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{r&&clearTimeout(r),a?.close(),process.exit(0)})}var Bl=d(()=>{"use strict";l();Wl()});function xh(t){t.help&&(console.log(_l),process.exit(0)),t.queryHelp&&(console.log(Gl),process.exit(0)),t.initSkill&&(Sl(t.force),process.exit(0)),t.initConfig&&(xl(t.force),process.exit(0)),t.clearCache&&(Yc(t.cachePath),process.exit(0))}async function bh(t,e,n){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let r=await Mc(n,N(e.rawConfig));return t.workspacePackages?Rl(r):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),Pl(r,t.file)),!0}function Sh(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 Ch(t){let n=[{name:"--propose-tags",flag:t.proposeTags,handler:El},{name:"--apply-tags",flag:t.applyTags,handler:Bc},{name:"--affected-tests",flag:t.affectedTests,handler:jc},{name:"--detect-features",flag:t.detectFeatures,handler:nl},{name:"--find-unused",flag:t.findUnused,handler:ul},{name:"--check-cycles",flag:t.checkCycles,handler:Io},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:Ao},{name:"--find-uncovered",flag:t.findUncovered,handler:$o},{name:"--list-tags",flag:t.listTags,handler:Uo},{name:"--callers",flag:t.callers,handler:Ro},{name:"--dependencies",flag:t.dependencies,handler:Lo},{name:"--dependents",flag:t.dependents,handler:Oo},{name:"--affected",flag:t.affected,handler:Po},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:_o},{name:"--find-duplicates",flag:t.findDuplicates,handler:Go},{name:"--find-risk-hotspots",flag:t.findRiskHotspots,handler:jo},{name:"--type-graph",flag:t.typeGraph,handler:Fl},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:vl},{name:"--feature-graph",flag:t.featureGraph,handler:ol},{name:"--call-graph",flag:t.callGraph,handler:Uc},{name:"--find-symbol",flag:t.findSymbol,handler:pl},{name:"--api-surface",flag:t.apiSurface,handler:Wc},{name:"--compare-branches",flag:!!t.compareBranches,handler:Xc}].filter(r=>r.flag);return n.length>1&&(console.error(`Error: conflicting flags: ${n.map(r=>r.name).join(", ")} (pass only one command flag)`),process.exit(1)),n[0]?.handler??Wo}async function kh(t,e,n,r,o,s,i){yh.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)),zl(n,300,async()=>{let a=await Vo(n,r,e.graph,{silent:s,...N(i)});Ko(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function Hl(){let t=process.argv.slice(2),e=Oc(t);xh(e);let n=Al(e);Rn(n.rawConfig);let{rootDir:r,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=n;if(await bh(e,n,r))return;let a=Sh(e),c=Ll(s)??new I(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 Vo(r,o,c,{silent:e.silent,...N(n.rawConfig)}),Ko(c,s));let p={graph:c,rootDir:r,cachePath:s,entryPoints:o.map(m=>m.replace(`${r}/`,"")),scanOptions:i,rawConfig:n.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines,includeGenerated:e.includeGenerated,maxCoveragePct:e.maxCoveragePct,minChurn:e.minChurn,base:e.base,compareBranches:e.compareBranches,compareFull:e.compareFull,compareMaxItems:e.compareMaxItems},f=Ch(e);if(e.watch){await kh(f,p,r,o,s,e.silent,n.rawConfig);return}await f(p)}var yh,Ul=d(()=>{"use strict";l();w();_c();Gc();$c();zc();Hc();Jc();Kc();Vc();qc();Qc();Zc();el();tl();rl();sl();il();cl();ll();fl();ml();dl();gl();bl();Cl();kl();wl();Tl();Nl();Dl();Il();Ml();Ol();jl();Bl();yh=new Set([Wo,Ro,Lo,Oo,Po,$o,_o,Go,jo,Io,Ao,Uo])});var vh=Kl(()=>{l();Ul();Hl().catch(t=>{console.error(t),process.exit(1)})});export default vh();
|
|
267
291
|
//# sourceMappingURL=cli.mjs.map
|