@omfalos/mokosh 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -1,30 +1,30 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var Dn=Object.create;var ve=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var On=Object.getPrototypeOf,jn=Object.prototype.hasOwnProperty;var Wn=(t,e)=>{for(var r in e)ve(t,r,{get:e[r],enumerable:!0})},ur=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ln(e))!jn.call(t,n)&&n!==r&&ve(t,n,{get:()=>e[n],enumerable:!(s=_n(e,n))||s.enumerable});return t};var f=(t,e,r)=>(r=t!=null?Dn(On(t)):{},ur(e||!t||!t.__esModule?ve(r,"default",{value:t,enumerable:!0}):r,t)),zn=t=>ur(ve({},"__esModule",{value:!0}),t);var Ka={};Wn(Ka,{createMcpServer:()=>Ye});module.exports=zn(Ka);var Gn=require("@modelcontextprotocol/sdk/server/stdio.js");var Nn=require("@modelcontextprotocol/sdk/server/index.js"),Xe=require("@modelcontextprotocol/sdk/types.js");var on=f(require("fs"));var Fe=f(require("fs")),st=f(require("path"));var $n=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],fr=[];function ke(t){fr.push(t)}function gr(t){return[...$n,...fr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Bn=[".test.",".spec.","-test.","-spec."],mr=[];function we(t){mr.push(t)}function Z(){return[...Bn,...mr]}var Un=["jest","vitest","playwright","cypress","@testing-library/"],dr=[];function Ce(t){dr.push(t)}function et(){return[...Un,...dr]}var hr=.8;function tt(t){hr=t}function rt(){return hr}var Kn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function ee(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=st.default.resolve(t);return Fe.default.existsSync(s)?s.endsWith(".json")?yr(s):e?xr(s):{}:{}}for(let s of Kn){let n=st.default.resolve(t,s);if(Fe.default.existsSync(n)){if(s.endsWith(".json"))return yr(n);if(e)return xr(n)}}return{}}function yr(t){return JSON.parse(Fe.default.readFileSync(t,"utf-8"))}function xr(t){let e=require(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function nt(t){for(let e of t.configMatchers??[])ke(e);for(let e of t.testPatterns??[])we(e);for(let e of t.testLibraries??[])Ce(e);t.barrelThreshold!==void 0&&tt(t.barrelThreshold)}function j(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var ot=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],it=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];var Sr=f(require("fs")),at=f(require("path"));function pt(t,e){let r=at.default.resolve(t,e);try{let s=Sr.default.readFileSync(r,"utf-8"),n=JSON.parse(s),o=new Map;for(let[i,a]of Object.entries(n)){if(i==="total")continue;let p=a?.lines?.pct;if(typeof p!="number")continue;let c=at.default.relative(t,i);o.set(c,p)}return o}catch{return new Map}}var Ee={serialize(t){let e=["graph TD"],r=new Set;for(let s of t.nodes.values()){let n=`"${s.path}"`;for(let o of s.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${s.path} -> ${o.toPath}`;if(!r.has(a)){let p=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${p} ${i}`),r.add(a)}}}return e.join(`
3
- `)}};var ct=f(require("fs")),br=f(require("path"));function lt(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function vr(t,e){if(typeof t=="string")return lt(t,e);if(t&&typeof t=="object"){let r=t;for(let s of["import","require","default"]){let n=vr(r[s],e);if(n)return n}}return null}function Hn(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 Qn(t,e){let r=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let c=t.nodes.get(a.toPath);if(c)for(let g of c.exports)r.add(g.name);n.push(a.toPath)}else for(let c of a.symbols)r.add(c)}}}return r}function ut(t,e){let r=[],s=br.default.join(e,"package.json");if(ct.default.existsSync(s))try{let n=JSON.parse(ct.default.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=vr(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof n.exports=="string"){let o=lt(n.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=lt(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(n)){r.push(n);break}}return r}function Vn(t,e){let r=new Set(e);for(let s of e)t.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function qn(t,e,r){let s=new Map;for(let n of e){if(r.includes(n))continue;let o=t.nodes.get(n);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let p=s.get(a.name),c=!!(a.signature||a.doc);(!p||c&&!i)&&s.set(a.name,{file:n,symbol:a})}}return s}function Xn(t,e,r,s){let n=[];for(let o of t){let i=e.get(o),a=s.flatMap(m=>r.nodes.get(m)?.exports??[]).find(m=>m.name===o),p=i?.symbol??a,c=i?.file??s.find(m=>r.nodes.get(m)?.exports.some(d=>d.name===o))??s[0],g={name:o,definedIn:c,kind:Hn(p?.signature)};p?.doc&&(g.doc=p.doc),p?.signature&&(g.signature=p.signature),n.push(g)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function Yn(t,e,r){let s=p=>t.nodes.get(p)?.category==="test",n=[...e].filter(p=>!r.includes(p)&&!s(p)),o=[...t.nodes.keys()].filter(p=>!e.has(p)),i=o.filter(p=>!s(p)),a=o.filter(p=>s(p));return{internalFiles:n,unreachableFromEntry:i,testFiles:a}}function ft(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let c of e)if(!t.nodes.has(c))throw new Error(`Entry point not found in graph: ${c}`);let r=Vn(t,e),s=qn(t,r,e),n=Qn(t,e),o=Xn(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=Yn(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}function gt(t,e){let r=null,s=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:s,callees:n}}var Zn=f(require("fs")),eo=f(require("path"));function kr(t){let e=[...t.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<e.length;s++)r^=e.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function mt(t){let e=new Map;for(let r of t.nodes.keys()){let s=[];t.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),e.set(r,s)}return{impact:e,graphHash:kr(t)}}function dt(t,e){return t.impact.get(e)??[]}var te=f(require("path"));function to(t){let e=new Map;for(let[r,s]of t){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(r,n)}return e}function ro(t,e,r){let s=new Map;for(let[n,o]of e){if(o<r)continue;let i=t.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=te.default.extname(n),p=te.default.basename(n,a),c=p==="index"?te.default.basename(te.default.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${c}`})}return s}function N(t,e){let r=e?.minOutDegree??5;return ro(t,to(t),r)}var so=(t,e)=>t.outDegree-e.outDegree;function no(t,e){let r=new Map;for(let s of e.values()){let n=new Set;t.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function oo(t,e,r,s){let n=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function io(t,e){let r=new Map;for(let s of t.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);r.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return r}function ao(t,e,r){let s=[];for(let n of t.keys())!e.has(n)&&!r.has(n)&&s.push(n);return s}function re(t,e){let r=e?.detectFn??N,s=e?.hubComparator??so,n=r(t.nodes,e),o=no(t,n),i=oo(t.nodes,n,o,s);return{features:io(n,i),unassigned:ao(t.nodes,n,i)}}var wr=new Set(["typescript","javascript","python","go"]),Pe=new Set(["typescript","javascript","python"]),Te=new Set(["typescript","javascript"]);function ht(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,s])=>({type:r,fileCount:s,exportsTracked:wr.has(r),importSymbolsTracked:Pe.has(r),callEdgesTracked:Te.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var se=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(s=>!r.has(s))}findHighExportUsage(e){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<e)continue;let n=s.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],r=new Set,s=new Set,n=[],o=i=>{r.add(i),s.add(i),n.push(i);let a=this.nodes.get(i);if(a){for(let p of a.imports)if(!(!p.toPath||p.isExternal))if(s.has(p.toPath)){let c=n.indexOf(p.toPath);e.push([...n.slice(c),p.toPath])}else r.has(p.toPath)||o(p.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}};var T=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 s of e.nodes)r.set(s.path,s);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(r.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,r,s,n){let o=new Set,i=s.maxDepth??1/0,a=(p,c,g)=>{if(c>i||o.has(p))return;let m=this.nodes.get(p);if(m&&(o.add(p),r(m,c,g)!==!1))for(let d of n(p))a(d,c+1,p)};a(e,0,null)}traverse(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=e.get(s.toFile)??[];n.push(r.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,s=>(s.path!==e&&r.push(s.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(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new se(this.nodes).findUnusedFiles(e)}findCycles(){return new se(this.nodes).findCycles()}};var G=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let s=this.affectedSymbols.get(r)||new Set,n=e.imports.find(p=>p.toPath===r);if(!n)return!1;let o=n.symbols||["*"],i=new Set;for(let p of o)(p==="*"||s.has("*")||s.has(p))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let p of i)a.add(p);return this.affectedSymbols.set(e.path,a),!0}};function ne(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function yt(t,e,r=1){let s=[];return t.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(p=>p.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function oe(t,e){let r=[];return t.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function xt(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new G(e,n):null,i=[];return t.traverse(e,(a,p,c)=>{if(a.path===e)return!0;if(o&&c&&!o.updateAffectedSymbols(a,c))return!1;let g=a.category==="test"||a.tags.some(m=>m.name==="test");return(!s||g)&&i.push(a.path),!0},{direction:"incoming"}),i}function St(t,e,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return n&&(a.edges=(i.callEdges??[]).filter(p=>p.toFile===e).map(p=>({from:p.from,to:p.to}))),o.push(a),!0},{direction:"incoming",maxDepth:s}),o}function bt(t,e={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,n)}function vt(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.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 kt(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function wt(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function Cr(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 x(e,"component")||x(e,"components")?"component":x(e,"controller")||x(e,"controllers")?"controller":x(e,"middleware")?"middleware":x(e,"router")||x(e,"routes")||x(e,"route")?"router":x(e,"store")||x(e,"stores")?"store":x(e,"service")||x(e,"services")?"service":x(e,"handler")||x(e,"handlers")?"handler":x(e,"adapter")||x(e,"adapters")?"adapter":x(e,"plugin")||x(e,"plugins")?"plugin":x(e,"api")?"api":x(e,"cli")||x(e,"commands")||ie(e)==="cli"?"cli":x(e,"util")||x(e,"utils")||x(e,"helper")||x(e,"helpers")?"util":x(e,"model")||x(e,"models")||ie(e)==="model"?"model":x(e,"parser")||x(e,"parsers")||ie(e)==="parser"?"parser":ie(e)==="builder"?"builder":ie(e)==="resolver"?"resolver":"other"}function x(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ie(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function Ct(t,e){let r=re(t,e),s=new Map;for(let[o,i]of r.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of t.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:Cr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}function Ft(t,e){let r=[];for(let s of t.nodes.values())if(s.exports.some(n=>n.name===e))if(Te.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from});r.push({path:s.path,category:s.category,precision:"call",callers:n})}else if(Pe.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.imports)i.toPath===s.path&&i.symbols?.includes(e)&&n.push({file:o.path,symbols:i.symbols});r.push({path:s.path,category:s.category,precision:"import-symbol",importers:n})}else{let n=oe(t,s.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return r}function po(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function co(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Et(t){let e=new Map;for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!co(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:po(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let o of n.symbols)e.has(`${n.toPath}::${o}`)&&r.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:r}}function Pt(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&s.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var jr=f(require("path"));var Me=f(require("fs")),Mt=f(require("path"));var W=f(require("fs")),C=f(require("path"));var Tt=f(require("fs")),lo=f(require("path"));function Fr(t){try{return Tt.default.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ae(t){try{return Tt.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function At(t,e){let r=C.default.join(e,"package.json");if(!W.default.existsSync(r))return null;let s={};try{s=JSON.parse(W.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:C.default.relative(t,e),entryPoints:uo(e,s)}:null}function uo(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(C.default.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(C.default.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(C.default.join(t,i))}}}e.main&&r.push(C.default.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(C.default.join(t,n));let s=r.filter(Ae);return s.length>0?s.slice(0,1):r.slice(0,1)}function z(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");fo(t,o,s,r)}return r}function fo(t,e,r,s){if(!e.includes("*")){go(t,e,r,s);return}let n=e.split("/");n.includes("**")?mo(t,n,r,s):ho(t,n,r,s)}function go(t,e,r,s){let n=C.default.join(t,e);if(r.has(n)||!Fr(n))return;r.add(n);let o=At(t,n);o&&s.push(o)}function mo(t,e,r,s){let n=C.default.join(t,e[0]==="**"?"":e[0]??"");Er(t,n,r,s)}function ho(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=C.default.join(t,...e.slice(0,n)),i;try{i=W.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let p=C.default.join(o,a.name);if(r.has(p))continue;r.add(p);let c=At(t,p);c&&s.push(c)}}function Er(t,e,r,s){let n;try{n=W.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=C.default.join(e,o.name);if(W.default.existsSync(C.default.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=At(t,i);a&&s.push(a)}else Er(t,i,r,s)}}var Pr={type:"npm",detect(t){let e=Mt.default.join(t,"package.json");if(!Me.default.existsSync(e))return null;let r;try{r=JSON.parse(Me.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||Me.default.existsSync(Mt.default.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:z(t,s)}};var D=f(require("fs")),v=f(require("path"));var Tr={type:"nx",detect(t){return D.default.existsSync(v.default.join(t,"nx.json"))?Ar(t,t,new Set,0).map(r=>yo(t,r,v.default.join(r,"project.json"))).filter(r=>r!==null):null}};function Ar(t,e,r,s){if(s>4)return[];let n;try{n=D.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of n){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let p=v.default.join(e,a);D.default.existsSync(v.default.join(p,"project.json"))&&!r.has(p)?(r.add(p),o.push(p)):o.push(...Ar(t,p,r,s+1))}return o}function yo(t,e,r){let s={};try{s=JSON.parse(D.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=v.default.join(e,"package.json");if(D.default.existsSync(a))try{let p=JSON.parse(D.default.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:v.default.relative(t,e),entryPoints:xo(e,s,o,i)}:null}function xo(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=v.default.resolve(t,"../..");n.push(v.default.resolve(a,o)),n.push(v.default.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(v.default.join(t,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(v.default.join(t,p))}}if(r&&n.push(v.default.join(t,r)),e.sourceRoot){let a=v.default.resolve(t,"../.."),p=v.default.resolve(a,e.sourceRoot);n.push(v.default.join(p,"index.ts"),v.default.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(v.default.join(t,a));let i=n.filter(Ae);return i.length>0?i.slice(0,1):n.slice(0,1)}var It=f(require("fs")),Mr=f(require("path")),Ir=require("js-yaml");var Rr={type:"pnpm",detect(t){let e=Mr.default.join(t,"pnpm-workspace.yaml");if(!It.default.existsSync(e))return null;let r=[];try{r=(0,Ir.load)(It.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return z(t,r)}};var Nr=f(require("fs")),Gr=f(require("path")),Dr={type:"turborepo",detect(t){return Nr.default.existsSync(Gr.default.join(t,"turbo.json"))?[]:null}};var Ie=f(require("fs")),Rt=f(require("path"));var _r={type:"yarn",detect(t){if(!Ie.default.existsSync(Rt.default.join(t,"yarn.lock")))return null;let e=Rt.default.join(t,"package.json");if(!Ie.default.existsSync(e))return null;let r;try{r=JSON.parse(Ie.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:z(t,s)}};var Lr=[];function M(t){Lr.push(t)}function Or(){return Lr}M(Dr);M(Tr);M(Rr);M(_r);M(Pr);function ae(t,e=Or()){let r=jr.default.resolve(t),s=new Map,n=[];for(let i of e){let a=i.detect(r);if(a!==null){n.push(i.type);for(let p of a)s.has(p.name)||s.set(p.name,p)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:r,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var 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:s}of this.packages.values()){let n=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&n.add(i.workspacePackage);e.set(s.name,[...n])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(c=>c.isWorkspace&&c.workspacePackage===r.name)&&n.push({file:a.path,package:i.name});return n}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:s,nodes:n}of e.packages){let o=new Map(n.map(a=>[a.path,a])),i=new T(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}};var Wr=new Map;function $(t,e){Wr.set(t,e)}function zr(t){return Wr.get(t)}function $r(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function So(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var bo=(t,e)=>!e.category||$r(t.category,e.category),vo=(t,e)=>!e.type||$r(t.type,e.type),ko=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,wo=(t,e)=>!e.path||So(t.path,e.path),Co=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,Fo=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>t.tags.some(o=>o.name===n))||s.some(n=>t.tags.some(o=>o.name===n)))},Eo=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),Po=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),To=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Ao=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Mo=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Io=(t,e)=>e.minSize===void 0||t.size>=e.minSize,Ro=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,No=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Go=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,Do=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,_o=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,Lo=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,Oo=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,jo=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Wo=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,zo=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,$o=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Bo=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Uo=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Ko=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,Jo=(t,e,r)=>!e.any?.length||e.any.some(s=>ce(t,s,r)),Ho=[bo,vo,ko,wo,Co,Fo,Eo,Po,To,Ao,Mo,Io,Ro,No,Go,Do,_o,Lo,Oo,jo,Wo,zo,$o,Bo,Uo,Ko,Jo];function ce(t,e,r){return Ho.every(s=>s(t,e,r))}function Re(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 p=r.get(a.toPath)??[];p.push(i.path),r.set(a.toPath,p)}}let s=t.nodes.filter(i=>ce(i,e,r)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,p)=>{let c=0;return e.sort==="size"?c=p.size-a.size:e.sort==="imports"?c=p.imports.length-a.imports.length:e.sort==="commitCount90d"?c=(p.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?c=(p.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?c=(p.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(c=(p.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),c*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}function Br(t,e){let r=e.indexOf(":");if(r===-1)return;let s=e.slice(0,r).trim().toLowerCase(),n=e.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":t.category=n;break;case"type":t.type=n;break;case"tag":case"tags":n.includes("+")?t.allTags=[...t.allTags??[],...n.split("+")]:t.tags=[...t.tags??[],n];break;case"path":t.path=n;break;case"external":t.isExternal=n.toLowerCase()==="true";break;case"importsfile":t.importsFile=n;break;case"importedby":t.importedBy=n;break;case"minimports":t.minImports=parseInt(n,10);break;case"maximports":t.maxImports=parseInt(n,10);break;case"minsize":t.minSize=parseInt(n,10);break;case"maxsize":t.maxSize=parseInt(n,10);break;case"sort":t.sort=n;break;case"sortdir":t.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(n,10);break;case"hasdocstring":t.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(n,10);break;case"maxcoverage":t.maxCoverage=parseInt(n,10);break;case"minexportusage":t.minExportUsage=parseFloat(n);break;case"maxexportusage":t.maxExportUsage=parseFloat(n);break;case"mincomplexity":t.minComplexity=parseInt(n,10);break;case"maxcomplexity":t.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":t.minCommits=parseInt(n,10);break;case"maxcommits":t.maxCommits=parseInt(n,10);break;case"isdocumented":t.isDocumented=n.toLowerCase()!=="false";break;case"isstale":t.isStale=n.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=n;break}}function Qo(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Br(n,s),Object.keys(n).length>0&&e.push(n)}return e}function Ne(t){let e={},r=t.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let o=n.slice(4,-1),i=Qo(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Br(e,s)}return e}var Kt=f(require("fs/promises")),Zr=f(require("path"));var ze=f(require("path")),le=f(require("typescript"));var Nt=f(require("path")),Gt=f(require("typescript"));var k=f(require("typescript")),Ur=new Set(["describe","test","it"]);function B(t){let e=[];for(let r of t.statements){if(!k.default.isExpressionStatement(r))continue;let s=r.expression;if(!k.default.isCallExpression(s))continue;let n=s.expression;k.default.isIdentifier(n)&&Ur.has(n.text)&&e.push(s),k.default.isPropertyAccessExpression(n)&&k.default.isIdentifier(n.expression)&&Ur.has(n.expression.text)&&e.push(s)}return e}function U(t,e,r){for(let s of t.arguments){if(!k.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>k.default.isPropertyAssignment(o)&&k.default.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!k.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(k.default.isStringLiteral).map(o=>o.text)}return null}function K(t,e,r,s){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=t.arguments[o];if(!k.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(c=>k.default.isPropertyAssignment(c)&&k.default.isIdentifier(c.name)&&c.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let p=i.getEnd()-1;return{start:p,end:p,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let n=t.arguments[t.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${r} }, `}}function J(t,e,r){let s=t.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!k.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(p=>k.default.isPropertyAssignment(p)&&k.default.isIdentifier(p.name)&&p.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:s[n-1].getEnd(),end:o.getEnd(),text:""};let a=o.properties[i];return i===o.properties.length-1?{start:o.properties[i-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:o.properties[i+1].getStart(r),text:""}}return null}function H(t,e){let r=[...e].sort((n,o)=>o.start-n.start),s=t;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function Q(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var P=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function Vo(t){return Q(t.map(e=>`@${e}`))}function qo(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Ge=class{name="cypress";canHandle(e){return P.has(Nt.default.extname(e).toLowerCase())}apply(e,r,s){let n=Gt.default.createSourceFile(Nt.default.basename(e),r,Gt.default.ScriptTarget.Latest,!0),o=B(n);if(o.length===0)return r;let i=U(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(qo(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(c=>{let g=s.length===0?J(c,"tags",n):K(c,"tags",Vo(a),n);return g?[g]:[]});return p.length>0?H(r,p):r}};var Kr=f(require("path")),Dt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,_t=/^@([a-zA-Z0-9_-]+)/gm;function Xo(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
2
+ "use strict";var jn=Object.create;var ke=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var $n=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty;var Un=(t,e)=>{for(var r in e)ke(t,r,{get:e[r],enumerable:!0})},fr=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zn(e))!Bn.call(t,n)&&n!==r&&ke(t,n,{get:()=>e[n],enumerable:!(s=Wn(e,n))||s.enumerable});return t};var f=(t,e,r)=>(r=t!=null?jn($n(t)):{},fr(e||!t||!t.__esModule?ke(r,"default",{value:t,enumerable:!0}):r,t)),Kn=t=>fr(ke({},"__esModule",{value:!0}),t);var tp={};Un(tp,{createMcpServer:()=>Ze});module.exports=Kn(tp);var On=require("@modelcontextprotocol/sdk/server/stdio.js");var Ln=require("@modelcontextprotocol/sdk/server/index.js"),Ye=require("@modelcontextprotocol/sdk/types.js");var ln=f(require("fs"));var Fe=f(require("fs")),nt=f(require("path"));var Jn=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],mr=[];function Ce(t){mr.push(t)}function gr(t){return[...Jn,...mr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Hn=[".test.",".spec.","-test.","-spec."],dr=[];function we(t){dr.push(t)}function ee(){return[...Hn,...dr]}var Qn=["jest","vitest","playwright","cypress","@testing-library/"],hr=[];function Ee(t){hr.push(t)}function tt(){return[...Qn,...hr]}var yr=.8;function rt(t){yr=t}function st(){return yr}var Vn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function te(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let s=nt.default.resolve(t);return Fe.default.existsSync(s)?s.endsWith(".json")?xr(s):e?Sr(s):{}:{}}for(let s of Vn){let n=nt.default.resolve(t,s);if(Fe.default.existsSync(n)){if(s.endsWith(".json"))return xr(n);if(e)return Sr(n)}}return{}}function xr(t){return JSON.parse(Fe.default.readFileSync(t,"utf-8"))}function Sr(t){let e=require(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function ot(t){for(let e of t.configMatchers??[])Ce(e);for(let e of t.testPatterns??[])we(e);for(let e of t.testLibraries??[])Ee(e);t.barrelThreshold!==void 0&&rt(t.barrelThreshold)}function z(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var it=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],at=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];var br=f(require("fs")),pt=f(require("path"));function ct(t,e){let r=pt.default.resolve(t,e);try{let s=br.default.readFileSync(r,"utf-8"),n=JSON.parse(s),o=new Map;for(let[i,a]of Object.entries(n)){if(i==="total")continue;let p=a?.lines?.pct;if(typeof p!="number")continue;let c=pt.default.relative(t,i);o.set(c,p)}return o}catch{return new Map}}var Te={serialize(t){let e=["graph TD"],r=new Set;for(let s of t.nodes.values()){let n=`"${s.path}"`;for(let o of s.imports){if(!o.toPath)continue;let i=`"${o.toPath}"`,a=`${s.path} -> ${o.toPath}`;if(!r.has(a)){let p=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${p} ${i}`),r.add(a)}}}return e.join(`
3
+ `)}};var lt=f(require("fs")),vr=f(require("path"));function ut(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let s=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function kr(t,e){if(typeof t=="string")return ut(t,e);if(t&&typeof t=="object"){let r=t;for(let s of["import","require","default"]){let n=kr(r[s],e);if(n)return n}}return null}function Xn(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 Yn(t,e){let r=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=t.nodes.get(o);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let c=t.nodes.get(a.toPath);if(c)for(let m of c.exports)r.add(m.name);n.push(a.toPath)}else for(let c of a.symbols)r.add(c)}}}return r}function ft(t,e){let r=[],s=vr.default.join(e,"package.json");if(lt.default.existsSync(s))try{let n=JSON.parse(lt.default.readFileSync(s,"utf8"));if(n.exports&&typeof n.exports=="object"&&!Array.isArray(n.exports))for(let o of Object.values(n.exports)){let i=kr(o,t);i&&!r.includes(i)&&r.push(i)}else if(typeof n.exports=="string"){let o=ut(n.exports,t);o&&r.push(o)}if(r.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=ut(o,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(n)){r.push(n);break}}return r}function Zn(t,e){let r=new Set(e);for(let s of e)t.traverse(s,n=>(r.add(n.path),!0),{direction:"outgoing"});return r}function eo(t,e,r){let s=new Map;for(let n of e){if(r.includes(n))continue;let o=t.nodes.get(n);if(!o)continue;let i=o.category==="barrel";for(let a of o.exports){let p=s.get(a.name),c=!!(a.signature||a.doc);(!p||c&&!i)&&s.set(a.name,{file:n,symbol:a})}}return s}function to(t,e,r,s){let n=[];for(let o of t){let i=e.get(o),a=s.flatMap(g=>r.nodes.get(g)?.exports??[]).find(g=>g.name===o),p=i?.symbol??a,c=i?.file??s.find(g=>r.nodes.get(g)?.exports.some(d=>d.name===o))??s[0],m={name:o,definedIn:c,kind:Xn(p?.signature)};p?.doc&&(m.doc=p.doc),p?.signature&&(m.signature=p.signature),n.push(m)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function ro(t,e,r){let s=p=>t.nodes.get(p)?.category==="test",n=[...e].filter(p=>!r.includes(p)&&!s(p)),o=[...t.nodes.keys()].filter(p=>!e.has(p)),i=o.filter(p=>!s(p)),a=o.filter(p=>s(p));return{internalFiles:n,unreachableFromEntry:i,testFiles:a}}function mt(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let c of e)if(!t.nodes.has(c))throw new Error(`Entry point not found in graph: ${c}`);let r=Zn(t,e),s=eo(t,r,e),n=Yn(t,e),o=to(n,s,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=ro(t,r,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}function gt(t,e){let r=null,s=[];for(let o of t.nodes.values()){o.exports.some(i=>i.name===e)&&(r=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(r){let o=t.nodes.get(r);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:s,callees:n}}var so=f(require("fs")),no=f(require("path"));function Cr(t){let e=[...t.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),r=2166136261;for(let s=0;s<e.length;s++)r^=e.charCodeAt(s),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function dt(t){let e=new Map;for(let r of t.nodes.keys()){let s=[];t.traverse(r,n=>(n.path!==r&&s.push(n.path),!0),{direction:"incoming"}),e.set(r,s)}return{impact:e,graphHash:Cr(t)}}function ht(t,e){return t.impact.get(e)??[]}var re=f(require("path"));function oo(t){let e=new Map;for(let[r,s]of t){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(r,n)}return e}function io(t,e,r){let s=new Map;for(let[n,o]of e){if(o<r)continue;let i=t.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=re.default.extname(n),p=re.default.basename(n,a),c=p==="index"?re.default.basename(re.default.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${c}`})}return s}function G(t,e){let r=e?.minOutDegree??5;return io(t,oo(t),r)}var ao=(t,e)=>t.outDegree-e.outDegree;function po(t,e){let r=new Map;for(let s of e.values()){let n=new Set;t.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),r.set(s.path,n)}return r}function co(t,e,r,s){let n=new Map;for(let[o]of t){if(e.has(o))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function lo(t,e){let r=new Map;for(let s of t.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);r.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return r}function uo(t,e,r){let s=[];for(let n of t.keys())!e.has(n)&&!r.has(n)&&s.push(n);return s}function se(t,e){let r=e?.detectFn??G,s=e?.hubComparator??ao,n=r(t.nodes,e),o=po(t,n),i=co(t.nodes,n,o,s);return{features:lo(n,i),unassigned:uo(t.nodes,n,i)}}var wr=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),Pe=new Set(["typescript","javascript","python"]),Ae=new Set(["typescript","javascript"]);function yt(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,s])=>({type:r,fileCount:s,exportsTracked:wr.has(r),importSymbolsTracked:Pe.has(r),callEdgesTracked:Ae.has(r)})).sort((r,s)=>s.fileCount-r.fileCount)}var ne=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(s=>!r.has(s))}findHighExportUsage(e){let r=[];for(let s of this.nodes.values()){if(s.maxExportUsage===void 0||s.maxExportUsage<e)continue;let n=s.imports.reduce((o,i)=>(i.exportUsageRatio??0)>(o?.exportUsageRatio??0)?i:o,null);r.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return r.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],r=new Set,s=new Set,n=[],o=i=>{r.add(i),s.add(i),n.push(i);let a=this.nodes.get(i);if(a){for(let p of a.imports)if(!(!p.toPath||p.isExternal))if(s.has(p.toPath)){let c=n.indexOf(p.toPath);e.push([...n.slice(c),p.toPath])}else r.has(p.toPath)||o(p.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())r.has(i)||o(i);return e}};var P=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 s of e.nodes)r.set(s.path,s);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(r.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,r,s,n){let o=new Set,i=s.maxDepth??1/0,a=(p,c,m)=>{if(c>i||o.has(p))return;let g=this.nodes.get(p);if(g&&(o.add(p),r(g,c,m)!==!1))for(let d of n(p))a(d,c+1,p)};a(e,0,null)}traverse(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:o?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let s of r.callEdges??[]){let n=e.get(s.toFile)??[];n.push(r.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,r,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,s=>(s.path!==e&&r.push(s.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(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new ne(this.nodes).findUnusedFiles(e)}findCycles(){return new ne(this.nodes).findCycles()}};var D=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let s=this.affectedSymbols.get(r)||new Set,n=e.imports.find(p=>p.toPath===r);if(!n)return!1;let o=n.symbols||["*"],i=new Set;for(let p of o)(p==="*"||s.has("*")||s.has(p))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let p of i)a.add(p);return this.affectedSymbols.set(e.path,a),!0}};function oe(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(s=>s.name)}}function xt(t,e,r=1){let s=[];return t.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(p=>p.toPath===n.path):void 0;return s.push({path:n.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),s}function ie(t,e){let r=[];return t.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return r.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function St(t,e,r={}){let{testsOnly:s=!1,changedSymbols:n}=r,o=n?new D(e,n):null,i=[];return t.traverse(e,(a,p,c)=>{if(a.path===e)return!0;if(o&&c&&!o.updateAffectedSymbols(a,c))return!1;let m=a.category==="test"||a.tags.some(g=>g.name==="test");return(!s||m)&&i.push(a.path),!0},{direction:"incoming"}),i}function bt(t,e,r={}){let{depth:s=1,withEdgeDetail:n=!1}=r,o=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return n&&(a.edges=(i.callEdges??[]).filter(p=>p.toFile===e).map(p=>({from:p.from,to:p.to}))),o.push(a),!0},{direction:"incoming",maxDepth:s}),o}function vt(t,e={}){let{metric:r="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...t.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[r]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[r]-o[r]).slice(0,n)}function kt(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(s=>s.name),tags:r.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:r.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.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 Ct(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function wt(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}function Er(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 x(e,"component")||x(e,"components")?"component":x(e,"controller")||x(e,"controllers")?"controller":x(e,"middleware")?"middleware":x(e,"router")||x(e,"routes")||x(e,"route")?"router":x(e,"store")||x(e,"stores")?"store":x(e,"service")||x(e,"services")?"service":x(e,"handler")||x(e,"handlers")?"handler":x(e,"adapter")||x(e,"adapters")?"adapter":x(e,"plugin")||x(e,"plugins")?"plugin":x(e,"api")?"api":x(e,"cli")||x(e,"commands")||ae(e)==="cli"?"cli":x(e,"util")||x(e,"utils")||x(e,"helper")||x(e,"helpers")?"util":x(e,"model")||x(e,"models")||ae(e)==="model"?"model":x(e,"parser")||x(e,"parsers")||ae(e)==="parser"?"parser":ae(e)==="builder"?"builder":ae(e)==="resolver"?"resolver":"other"}function x(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function ae(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function Et(t,e){let r=se(t,e),s=new Map;for(let[o,i]of r.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of t.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:Er(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}function Ft(t,e){let r=[];for(let s of t.nodes.values())if(s.exports.some(n=>n.name===e))if(Ae.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.callEdges??[])i.to===e&&n.push({file:o.path,callerFunction:i.from});r.push({path:s.path,category:s.category,precision:"call",callers:n})}else if(Pe.has(s.type)){let n=[];for(let o of t.nodes.values())for(let i of o.imports)i.toPath===s.path&&i.symbols?.includes(e)&&n.push({file:o.path,symbols:i.symbols});r.push({path:s.path,category:s.category,precision:"import-symbol",importers:n})}else{let n=ie(t,s.path).map(o=>({file:o.path,...o.symbols?{symbols:o.symbols}:{}}));r.push({path:s.path,category:s.category,precision:"file-level",importers:n})}return r}function fo(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function mo(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function Tt(t){let e=new Map;for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!mo(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:fo(n.signature),...n.doc?{doc:n.doc}:{}})}let r=[];for(let s of t.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript")){for(let n of s.imports)if(!(!n.toPath||n.isExternal||!n.symbols?.length))for(let o of n.symbols)e.has(`${n.toPath}::${o}`)&&r.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:r}}function Pt(t,e){let r=null;for(let o of t.types.values())if(o.name===e){r=o;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of t.edges)if(o.toType===e&&o.toFile===r.file&&s.add(o.fromFile),o.fromFile===r.file){let i=t.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var Wr=f(require("path"));var Ie=f(require("fs")),It=f(require("path"));var $=f(require("fs")),w=f(require("path"));var At=f(require("fs")),go=f(require("path"));function Fr(t){try{return At.default.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Me(t){try{return At.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function Mt(t,e){let r=w.default.join(e,"package.json");if(!$.default.existsSync(r))return null;let s={};try{s=JSON.parse($.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:w.default.relative(t,e),entryPoints:ho(e,s)}:null}function ho(t,e){let r=[];if(e.exports){let n=e.exports;if(typeof n=="string")r.push(w.default.join(t,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")r.push(w.default.join(t,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&r.push(w.default.join(t,i))}}}e.main&&r.push(w.default.join(t,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(w.default.join(t,n));let s=r.filter(Me);return s.length>0?s.slice(0,1):r.slice(0,1)}function B(t,e){let r=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");yo(t,o,s,r)}return r}function yo(t,e,r,s){if(!e.includes("*")){xo(t,e,r,s);return}let n=e.split("/");n.includes("**")?So(t,n,r,s):bo(t,n,r,s)}function xo(t,e,r,s){let n=w.default.join(t,e);if(r.has(n)||!Fr(n))return;r.add(n);let o=Mt(t,n);o&&s.push(o)}function So(t,e,r,s){let n=w.default.join(t,e[0]==="**"?"":e[0]??"");Tr(t,n,r,s)}function bo(t,e,r,s){let n=e.findIndex(a=>a.includes("*")),o=w.default.join(t,...e.slice(0,n)),i;try{i=$.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let p=w.default.join(o,a.name);if(r.has(p))continue;r.add(p);let c=Mt(t,p);c&&s.push(c)}}function Tr(t,e,r,s){let n;try{n=$.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){if(!o.isDirectory()||o.name==="node_modules"||o.name.startsWith("."))continue;let i=w.default.join(e,o.name);if($.default.existsSync(w.default.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=Mt(t,i);a&&s.push(a)}else Tr(t,i,r,s)}}var Pr={type:"npm",detect(t){let e=It.default.join(t,"package.json");if(!Ie.default.existsSync(e))return null;let r;try{r=JSON.parse(Ie.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||Ie.default.existsSync(It.default.join(t,"yarn.lock")))return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}};var _=f(require("fs")),v=f(require("path"));var Ar={type:"nx",detect(t){return _.default.existsSync(v.default.join(t,"nx.json"))?Mr(t,t,new Set,0).map(r=>vo(t,r,v.default.join(r,"project.json"))).filter(r=>r!==null):null}};function Mr(t,e,r,s){if(s>4)return[];let n;try{n=_.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of n){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let p=v.default.join(e,a);_.default.existsSync(v.default.join(p,"project.json"))&&!r.has(p)?(r.add(p),o.push(p)):o.push(...Mr(t,p,r,s+1))}return o}function vo(t,e,r){let s={};try{s=JSON.parse(_.default.readFileSync(r,"utf-8"))}catch{return null}let n=s.name,o,i,a=v.default.join(e,"package.json");if(_.default.existsSync(a))try{let p=JSON.parse(_.default.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:v.default.relative(t,e),entryPoints:ko(e,s,o,i)}:null}function ko(t,e,r,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=v.default.resolve(t,"../..");n.push(v.default.resolve(a,o)),n.push(v.default.resolve(t,o))}if(s){let a=s;if(typeof a=="string")n.push(v.default.join(t,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(v.default.join(t,p))}}if(r&&n.push(v.default.join(t,r)),e.sourceRoot){let a=v.default.resolve(t,"../.."),p=v.default.resolve(a,e.sourceRoot);n.push(v.default.join(p,"index.ts"),v.default.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(v.default.join(t,a));let i=n.filter(Me);return i.length>0?i.slice(0,1):n.slice(0,1)}var Nt=f(require("fs")),Ir=f(require("path")),Nr=require("js-yaml");var Rr={type:"pnpm",detect(t){let e=Ir.default.join(t,"pnpm-workspace.yaml");if(!Nt.default.existsSync(e))return null;let r=[];try{r=(0,Nr.load)(Nt.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return B(t,r)}};var Gr=f(require("fs")),Dr=f(require("path")),_r={type:"turborepo",detect(t){return Gr.default.existsSync(Dr.default.join(t,"turbo.json"))?[]:null}};var Ne=f(require("fs")),Rt=f(require("path"));var Lr={type:"yarn",detect(t){if(!Ne.default.existsSync(Rt.default.join(t,"yarn.lock")))return null;let e=Rt.default.join(t,"package.json");if(!Ne.default.existsSync(e))return null;let r;try{r=JSON.parse(Ne.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let s=Array.isArray(r)?r:r.packages??[];return s.length===0?null:B(t,s)}};var Or=[];function M(t){Or.push(t)}function jr(){return Or}M(_r);M(Ar);M(Rr);M(Lr);M(Pr);function pe(t,e=jr()){let r=Wr.default.resolve(t),s=new Map,n=[];for(let i of e){let a=i.detect(r);if(a!==null){n.push(i.type);for(let p of a)s.has(p.name)||s.set(p.name,p)}}if(n.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:r,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var ce=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:s}of this.packages.values()){let n=new Set;for(let o of r.nodes.values())for(let i of o.imports)i.isWorkspace&&i.workspacePackage&&n.add(i.workspacePackage);e.set(s.name,[...n])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let s=this.packages.get(r.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of o.nodes.values())a.imports.some(c=>c.isWorkspace&&c.workspacePackage===r.name)&&n.push({file:a.path,package:i.name});return n}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:s,nodes:n}of e.packages){let o=new Map(n.map(a=>[a.path,a])),i=new P(o);r.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return r}};var zr=new Map;function U(t,e){zr.set(t,e)}function $r(t){return zr.get(t)}function Br(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Co(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}var wo=(t,e)=>!e.category||Br(t.category,e.category),Eo=(t,e)=>!e.type||Br(t.type,e.type),Fo=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,To=(t,e)=>!e.path||Co(t.path,e.path),Po=(t,e)=>e.isExternal===void 0?!0:t.imports.some(s=>s.isExternal)===e.isExternal,Ao=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(r.length>0&&!r.some(n=>t.tags.some(o=>o.name===n))||s.some(n=>t.tags.some(o=>o.name===n)))},Mo=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(s=>s.name===r)),Io=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),No=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(n=>n.includes(e.importedBy)),Ro=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,Go=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,Do=(t,e)=>e.minSize===void 0||t.size>=e.minSize,_o=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,Lo=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,Oo=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,jo=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,Wo=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,zo=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,$o=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,Bo=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,Uo=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Ko=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Jo=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Ho=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Qo=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,Vo=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,qo=(t,e,r)=>!e.any?.length||e.any.some(s=>le(t,s,r)),Xo=[wo,Eo,Fo,To,Po,Ao,Mo,Io,No,Ro,Go,Do,_o,Lo,Oo,jo,Wo,zo,$o,Bo,Uo,Ko,Jo,Ho,Qo,Vo,qo];function le(t,e,r){return Xo.every(s=>s(t,e,r))}function Re(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 p=r.get(a.toPath)??[];p.push(i.path),r.set(a.toPath,p)}}let s=t.nodes.filter(i=>le(i,e,r)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;o.sort((a,p)=>{let c=0;return e.sort==="size"?c=p.size-a.size:e.sort==="imports"?c=p.imports.length-a.imports.length:e.sort==="commitCount90d"?c=(p.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?c=(p.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?c=(p.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(c=(p.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),c*i})}return e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:t.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}function Ur(t,e){let r=e.indexOf(":");if(r===-1)return;let s=e.slice(0,r).trim().toLowerCase(),n=e.slice(r+1).trim();if(!(!s||!n))switch(s){case"category":t.category=n;break;case"type":t.type=n;break;case"tag":case"tags":n.includes("+")?t.allTags=[...t.allTags??[],...n.split("+")]:t.tags=[...t.tags??[],n];break;case"path":t.path=n;break;case"external":t.isExternal=n.toLowerCase()==="true";break;case"importsfile":t.importsFile=n;break;case"importedby":t.importedBy=n;break;case"minimports":t.minImports=parseInt(n,10);break;case"maximports":t.maxImports=parseInt(n,10);break;case"minsize":t.minSize=parseInt(n,10);break;case"maxsize":t.maxSize=parseInt(n,10);break;case"sort":t.sort=n;break;case"sortdir":t.sortDir=n.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(n,10);break;case"hasdocstring":t.hasDocstring=n.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(n,10);break;case"maxcoverage":t.maxCoverage=parseInt(n,10);break;case"minexportusage":t.minExportUsage=parseFloat(n);break;case"maxexportusage":t.maxExportUsage=parseFloat(n);break;case"mincomplexity":t.minComplexity=parseInt(n,10);break;case"maxcomplexity":t.maxComplexity=parseInt(n,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(n,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(n,10);break;case"mincommits":t.minCommits=parseInt(n,10);break;case"maxcommits":t.maxCommits=parseInt(n,10);break;case"isdocumented":t.isDocumented=n.toLowerCase()!=="false";break;case"isstale":t.isStale=n.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=n;break}}function Yo(t){let e=[];for(let r of t.split("|")){let s=r.trim();if(!s)continue;let n={};Ur(n,s),Object.keys(n).length>0&&e.push(n)}return e}function Ge(t){let e={},r=t.split(",");for(let s of r){let n=s.trim();if(n.toLowerCase().startsWith("any(")&&n.endsWith(")")){let o=n.slice(4,-1),i=Yo(o);i.length>0&&(e.any=[...e.any??[],...i]);continue}Ur(e,s)}return e}var Jt=f(require("fs/promises")),es=f(require("path"));var $e=f(require("path")),ue=f(require("typescript"));var Gt=f(require("path")),Dt=f(require("typescript"));var k=f(require("typescript")),Kr=new Set(["describe","test","it"]);function K(t){let e=[];for(let r of t.statements){if(!k.default.isExpressionStatement(r))continue;let s=r.expression;if(!k.default.isCallExpression(s))continue;let n=s.expression;k.default.isIdentifier(n)&&Kr.has(n.text)&&e.push(s),k.default.isPropertyAccessExpression(n)&&k.default.isIdentifier(n.expression)&&Kr.has(n.expression.text)&&e.push(s)}return e}function J(t,e,r){for(let s of t.arguments){if(!k.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>k.default.isPropertyAssignment(o)&&k.default.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!k.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(k.default.isStringLiteral).map(o=>o.text)}return null}function H(t,e,r,s){if(t.arguments.length===0)return null;for(let o=1;o<t.arguments.length;o++){let i=t.arguments[o];if(!k.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(c=>k.default.isPropertyAssignment(c)&&k.default.isIdentifier(c.name)&&c.name.text===e);if(a)return{start:a.initializer.getStart(s),end:a.initializer.getEnd(),text:r};let p=i.getEnd()-1;return{start:p,end:p,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let n=t.arguments[t.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${r} }, `}}function Q(t,e,r){let s=t.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!k.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(p=>k.default.isPropertyAssignment(p)&&k.default.isIdentifier(p.name)&&p.name.text===e);if(i<0)continue;if(o.properties.length===1)return{start:s[n-1].getEnd(),end:o.getEnd(),text:""};let a=o.properties[i];return i===o.properties.length-1?{start:o.properties[i-1].getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:o.properties[i+1].getStart(r),text:""}}return null}function V(t,e){let r=[...e].sort((n,o)=>o.start-n.start),s=t;for(let n of r)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function q(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}var T=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function Zo(t){return q(t.map(e=>`@${e}`))}function ei(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var De=class{name="cypress";canHandle(e){return T.has(Gt.default.extname(e).toLowerCase())}apply(e,r,s){let n=Dt.default.createSourceFile(Gt.default.basename(e),r,Dt.default.ScriptTarget.Latest,!0),o=K(n);if(o.length===0)return r;let i=J(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(ei(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(c=>{let m=s.length===0?Q(c,"tags",n):H(c,"tags",Zo(a),n);return m?[m]:[]});return p.length>0?V(r,p):r}};var Jr=f(require("path")),_t=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Lt=/^@([a-zA-Z0-9_-]+)/gm;function ti(t){return["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
4
4
  `)+`
5
5
 
6
- `}function Yo(t){let e=new Set;_t.lastIndex=0;let r=_t.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=_t.exec(t);return e}var De=class{name="gherkin";canHandle(e){return Kr.default.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(Dt,""),o=Yo(n),i=s.filter(p=>!o.has(p)),a=i.length>0?Xo(i):"";return Dt.test(r)?r.replace(Dt,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function Jr(t,e){let r=t.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Hr=f(require("path")),Lt=/^\/\/go:build mokosh_[^\n]+\n/m,Zo=/^package\s+\S+/m;function ei(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
- `}function ti(t){let e=Lt.exec(t);if(!e)return null;let r=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var _e=class{name="go";canHandle(e){return Hr.default.basename(e).endsWith("_test.go")}apply(e,r,s){let n=ti(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Lt,"");let i=ei(o);if(n!==null)return r.replace(Lt,i);let a=Zo.exec(r);if(!a)return r;let p=a.index;return r.slice(0,p)+i+`
8
- `+r.slice(p)}};var Qr=f(require("path"));var ri=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Ot=/^ \* @group (.+)$/gm;function si(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
6
+ `}function ri(t){let e=new Set;Lt.lastIndex=0;let r=Lt.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Lt.exec(t);return e}var _e=class{name="gherkin";canHandle(e){return Jr.default.extname(e).toLowerCase()===".feature"}apply(e,r,s){let n=r.replace(_t,""),o=ri(n),i=s.filter(p=>!o.has(p)),a=i.length>0?ti(i):"";return _t.test(r)?r.replace(_t,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}};function Hr(t,e){let r=t.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<r.length;o++){let i=r[o];i==="*"?r[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Qr=f(require("path")),Ot=/^\/\/go:build mokosh_[^\n]+\n/m,si=/^package\s+\S+/m;function ni(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
7
+ `}function oi(t){let e=Ot.exec(t);if(!e)return null;let r=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(r);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(r);return n}var Le=class{name="go";canHandle(e){return Qr.default.basename(e).endsWith("_test.go")}apply(e,r,s){let n=oi(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(Ot,"");let i=ni(o);if(n!==null)return r.replace(Ot,i);let a=si.exec(r);if(!a)return r;let p=a.index;return r.slice(0,p)+i+`
8
+ `+r.slice(p)}};var Vr=f(require("path"));var ii=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,jt=/^ \* @group (.+)$/gm;function ai(t){return["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
9
9
  `)+`
10
10
 
11
- `}function ni(t){let e=[];Ot.lastIndex=0;let r=Ot.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Ot.exec(t);return e}var Le=class{name="jest";canHandle(e){return P.has(Qr.default.extname(e).toLowerCase())}apply(e,r,s){let n=ri.exec(r),o=n?ni(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:si(i)+a}};var jt=f(require("path")),Wt=f(require("typescript"));function oi(t){return Q(t.map(e=>`@${e}`))}function ii(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var Oe=class{name="playwright";canHandle(e){return P.has(jt.default.extname(e).toLowerCase())}apply(e,r,s){let n=Wt.default.createSourceFile(jt.default.basename(e),r,Wt.default.ScriptTarget.Latest,!0),o=B(n);if(o.length===0)return r;let i=U(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(ii(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(c=>{let g=s.length===0?J(c,"tag",n):K(c,"tag",oi(a),n);return g?[g]:[]});return p.length>0?H(r,p):r}};var Vr=f(require("path")),zt=/^pytestmark\s*=\s*.+$/m,ai=/^import pytest\s*$/m;function pi(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function ci(t){let e=zt.exec(t);if(!e)return null;let r=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}var je=class{name="pytest";canHandle(e){return Vr.default.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=ci(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace(zt,"").replace(/\n{3,}/g,`
11
+ `}function pi(t){let e=[];jt.lastIndex=0;let r=jt.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=jt.exec(t);return e}var Oe=class{name="jest";canHandle(e){return T.has(Vr.default.extname(e).toLowerCase())}apply(e,r,s){let n=ii.exec(r),o=n?pi(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return r;let a=n?r.slice(n[0].length):r;return s.length===0?a:ai(i)+a}};var Wt=f(require("path")),zt=f(require("typescript"));function ci(t){return q(t.map(e=>`@${e}`))}function li(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}var je=class{name="playwright";canHandle(e){return T.has(Wt.default.extname(e).toLowerCase())}apply(e,r,s){let n=zt.default.createSourceFile(Wt.default.basename(e),r,zt.default.ScriptTarget.Latest,!0),o=K(n);if(o.length===0)return r;let i=J(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(li(i).sort())===JSON.stringify(a))return r;let p=o.flatMap(c=>{let m=s.length===0?Q(c,"tag",n):H(c,"tag",ci(a),n);return m?[m]:[]});return p.length>0?V(r,p):r}};var qr=f(require("path")),$t=/^pytestmark\s*=\s*.+$/m,ui=/^import pytest\s*$/m;function fi(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function mi(t){let e=$t.exec(t);if(!e)return null;let r=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(r);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(r);return s}var We=class{name="pytest";canHandle(e){return qr.default.extname(e).toLowerCase()===".py"}apply(e,r,s){let n=mi(r),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return r;if(s.length===0)return r.replace($t,"").replace(/\n{3,}/g,`
12
12
 
13
- `);let i=pi(o);if(n!==null)return r.replace(zt,i);let a=ai.test(r),p=li(r),c=r.slice(0,p),g=r.slice(p),m=a?"":`import pytest
13
+ `);let i=fi(o);if(n!==null)return r.replace($t,i);let a=ui.test(r),p=gi(r),c=r.slice(0,p),m=r.slice(p),g=a?"":`import pytest
14
14
  `,d=c.endsWith(`
15
15
 
16
16
  `)?"":`
17
- `;return c+d+m+i+`
18
- `+g}};function li(t){let e=t.split(`
19
- `),r=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=e[n].length+1;return s}var $t=f(require("path")),Bt=f(require("typescript"));var ui=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,We=class{name="vitest";canHandle(e){return P.has($t.default.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(ui,""),o=Bt.default.createSourceFile($t.default.basename(e),n,Bt.default.ScriptTarget.Latest,!0),i=B(o);if(i.length===0)return n;let a=U(i[0],"tags",o),p=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(p))return n;let c=i.flatMap(g=>{let m=s.length===0?J(g,"tags",o):K(g,"tags",Q(p),o);return m?[m]:[]});return c.length>0?H(n,c):n}};var qr={vitest:()=>new We,playwright:()=>new Oe,cypress:()=>new Ge,jest:()=>new Le},fi={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function gi(t){let e=le.default.createSourceFile("detect.ts",t,le.default.ScriptTarget.Latest,!0);for(let r of e.statements){if(!le.default.isImportDeclaration(r)||!le.default.isStringLiteral(r.moduleSpecifier))continue;let s=fi[r.moduleSpecifier.text];if(s)return s}return null}var Ut=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return P.has(ze.default.extname(e).toLowerCase())}apply(e,r,s){let n=gi(r)??this.matchOverride(e)??this.defaultFramework;return(qr[n]??qr.vitest)().apply(e,r,s)}matchOverride(e){let r=ze.default.relative(this.rootDir,e).split(ze.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Jr(s,r))return n;return null}};function Xr(t="vitest",e={},r=process.cwd()){return[new De,new je,new _e,new Ut(r,t,Object.entries(e))]}function Yr(t,e){return e.find(r=>r.canHandle(t))??null}var mi=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,di=new Set(["import"]),hi=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function yi(t,e,r,s){let n;try{n=await Kt.default.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=Yr(t,s);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,n,e);return i===n?{path:t,status:"unchanged"}:(r||await Kt.default.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Jt(t,e,r){let s=ee(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=Xr(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let p of t.nodes.values()){if(p.category!=="test")continue;let c=new Set,g=[];for(let S of p.tags)di.has(S.kind)&&mi.test(S.name)&&(hi.has(S.name.toLowerCase())||c.has(S.name)||(c.add(S.name),g.push(S.name)));g.sort();let m=Zr.default.resolve(e,p.path),d=await yi(m,g,r.dryRun,i);d.path=p.path,a.files.push(d),d.status==="updated"?a.updated++:d.status==="unchanged"?a.unchanged++:a.errors++}return a}var $e=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}};var X=f(require("fs")),w=f(require("path")),Xs=f(require("piscina"));var Be=require("child_process"),Ue=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return(0,Be.execFileSync)("git",s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
20
- `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},es="%x00%H%x09%ae%x09%at",ts=256*1024*1024;function rs(t,e){let r="",s=0;for(let n of t.split(`
21
- `)){if(n.startsWith("\0")){let[,p,c]=n.slice(1).split(" ");r=p??"",s=c?Number(c)*1e3:0;continue}if(n==="")continue;let o=n.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,s)}}function ss(t){let e=new Map;try{let r=(0,Be.execFileSync)("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${es}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ts});rs(r,(s,n,o)=>{let i=e.get(s);if(i){i.commitCount90d+=1;return}e.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=(0,Be.execFileSync)("git",["-C",t,"log","--name-status","-M",`--format=${es}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:ts});rs(r,(s,n,o)=>{e.has(s)||e.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var ue=f(require("fs")),ns=f(require("path")),Ht=require("js-yaml");function os(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function xi(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),os(r)}).filter(Boolean)}function Si(t,e){let r=t.startsWith("/")?t.slice(1):t,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:e||r.substring(s+1)}:{name:r,version:e}}function bi(t){try{let e=(0,Ht.load)(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=os(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function vi(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let s=r.split(`
22
- `).filter(p=>p.trim().length>0&&!p.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let o=xi(n);if(o.length===0)continue;let a=s.find(p=>p.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let p of o)e.dependencies[p]={version:a}}return e}function ki(t){let e=ue.default.readFileSync(t,"utf-8"),r=JSON.parse(e),s={dependencies:{}};if(r.packages)for(let[n,o]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let i=n.replace("node_modules/","");i.includes("node_modules/")||(s.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[n,o]of Object.entries(r.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function wi(t){let e=ue.default.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=bi(e);if(r!==null)return r}return vi(e)}function Ci(t){let e=ue.default.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=(0,Ht.load)(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Si(n,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let i=typeof o=="string"?o:o.version;r.dependencies[n]={version:i||""}}}catch{}return r}function is(t){let e=[["package-lock.json",ki],["yarn.lock",wi],["pnpm-lock.yaml",Ci]];for(let[r,s]of e){let n=ns.default.join(t,r);if(ue.default.existsSync(n))return s(n)}return null}var Qt=f(require("path"));function I(t){switch(Qt.default.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function F(t){let e=Qt.default.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var as=f(require("coffeescript"));function Fi(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Ei(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Pi(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:F(r),type:"static"}:null}function Ti(t,e){let r=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:F(s),type:"require"}}function Ai(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=Pi(t,e);n&&r.push(n)}else if(s==="Call"){let n=Ti(t,e);n&&r.push(n)}}function Vt(t,e,r){if(!(!e||typeof e!="object")){Ai(t,e,r);for(let s in e){if(s==="locationData")continue;let n=e[s];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)Vt(t,o,r);else Vt(t,n,r)}}}function ps(t,e){let r=Fi(e),s=Ei(t,r),n=[];try{Vt(t,as.default.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var V=require("@cucumber/gherkin"),cs=require("@cucumber/messages");var Mi=cs.IdGenerator.uuid();function qt(t,e){let r=new Set;try{let s=new V.AstBuilder(Mi),n=new V.GherkinClassicTokenMatcher,i=new V.Parser(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)}),a.scenario.examples.forEach(p=>{p.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})),a.rule&&a.rule.children.forEach(p=>{p.scenario&&p.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}$("gherkin",qt);var us=f(require("path")),fs=require("@lezer/go"),Ii=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Ri=/^\/\/go:build\s+(.+)$/,Ni=/^\/\/\s*\+build\s+(.+)$/;function gs(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=fs.parser.parse(e).cursor();do switch(a.name){case"LineComment":{let m=e.slice(a.from,a.to),d=m.match(Ii);d?.[1]&&n.add(d[1]);let S=m.match(Ri);S&&ls(S[1],o);let E=m.match(Ni);E&&ls(E[1],o);break}case"ImportSpec":{let m=a.node.getChild("String");if(m){let S=e.slice(m.from,m.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:S,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let m=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(m){let d=e.slice(m.from,m.to);d!=="_"&&/^[A-Z]/.test(d)&&!s.has(d)&&s.set(d,{name:d})}break}}while(a.next());let p=r.some(m=>m.rawSpecifier==="testing"),c=us.default.basename(t).endsWith("_test.go")||n.has("test")||p?"test":"logic",g=new Set([...n,...o]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(g).map(m=>({name:m,kind:"comment-marker"})),category:c}}function ls(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var ms=f(require("livescript"));function q(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function Gi(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Di(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var _i=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Li(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=q(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:F(n),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=q(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:F(o),type:"require"}}}}return null}function Xt(t,e){if(!t||typeof t!="object")return[];let r=[],s=Li(t,e);s&&r.push(s);for(let n in t){if(_i.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...Xt(i,e));else r.push(...Xt(o,e))}return r}function ds(t,e){let r=Gi(e),s=Di(t,r),n=[];try{n=Xt(ms.default.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var hs=f(require("luaparse"));function Oi(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function ji(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Wi(t,e){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let o;if(n.type==="CallExpression"){let i=n.arguments?.[0];i?.type==="StringLiteral"&&(o=q(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=q(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:F(o),type:"require"})}for(let o in n){if(o==="loc")continue;let i=n[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)s(a);else s(i)}}}return s(t),r}function ys(t,e){let r=Oi(e),s=ji(t,r),n=[];try{let o=hs.default.parse(e);n=Wi(o,t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var zi=["http://","https://","mailto:","//"],$i="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Bi=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${$i})\\b`,"g"),xs;async function Ui(){return xs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),xs}function Ki(t){let e=t.trim();return e.length===0||e.startsWith("#")||zi.some(r=>e.startsWith(r))}function Ji(t,e){let r=t.match(Bi);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function Ss(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Ki(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(...Ji(t.value,e)),Array.isArray(t.children))for(let s of t.children)Ss(s,e,r)}async function bs(t,e){let s=(await Ui()).parse(e),n=[];Ss(s,t,n);let o=new Set;return{imports:n.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var vs=f(require("path")),ks=require("@lezer/python"),Hi=new Set(["pytest","unittest","nose","hypothesis"]);function ws(t,e){let r=[],s=[],n=new Set,o=vs.default.basename(t).toLowerCase(),a=ks.parser.parse(e).cursor();do switch(a.name){case"Comment":{let c=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);c?.[1]&&n.add(c[1]);break}case"ImportStatement":{for(let c of Qi(a.node,e,t))r.push(c);break}case"FunctionDefinition":case"ClassDefinition":{let c=a.node.parent;if(c?.name==="Script"||c?.name==="DecoratedStatement"&&c.parent?.name==="Script"){let m=a.node.getChild("VariableName");m&&s.push({name:e.slice(m.from,m.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let c=a.node.firstChild;c?.name==="VariableName"&&s.push({name:e.slice(c.from,c.to)})}break}}while(a.next());let p=Yi(o,r,n);return p==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:p}}function Qi(t,e,r){let s=t.firstChild;return s?s.name==="from"?Vi(t,e,r):qi(t,e,r):[]}function Vi(t,e,r){let s=t.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let o=e.slice(s.to,n.from).trim(),i=Xi(n.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let p=o.slice(a);if(a===0)return[fe(r,o,i,!0)];let c=a===1?"./":"../".repeat(a-1);return p?[fe(r,c+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[fe(r,c.slice(0,-1),["*"],!1)]:i.map(g=>fe(r,c+g,[g],!1))}function qi(t,e,r){let s=[],n=t.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let o=e.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,o+=`.${e.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(fe(r,o,["*"],!0))}n=n.nextSibling}return s}function Xi(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function fe(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Yi(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>Hi.has(s.rawSpecifier))?"test":"logic"}var er=f(require("path")),l=f(require("typescript"));var h=f(require("typescript"));function Zi(t){let e=1;function r(s){switch(s.kind){case h.default.SyntaxKind.IfStatement:case h.default.SyntaxKind.ConditionalExpression:case h.default.SyntaxKind.ForStatement:case h.default.SyntaxKind.ForInStatement:case h.default.SyntaxKind.ForOfStatement:case h.default.SyntaxKind.WhileStatement:case h.default.SyntaxKind.DoStatement:case h.default.SyntaxKind.CatchClause:case h.default.SyntaxKind.CaseClause:e++;break;case h.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===h.default.SyntaxKind.AmpersandAmpersandToken||n===h.default.SyntaxKind.BarBarToken||n===h.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}h.default.forEachChild(s,r)}return r(t),e}function ea(t){let e=0;function r(s,n,o){if(h.default.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(h.default.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(e+=1,r(s.elseStatement,n+1,!1)));return}if(h.default.isForStatement(s)||h.default.isForInStatement(s)||h.default.isForOfStatement(s)||h.default.isWhileStatement(s)||h.default.isDoStatement(s)||h.default.isSwitchStatement(s)){e+=1+n,h.default.forEachChild(s,a=>r(a,n+1,!1));return}if(h.default.isCatchClause(s)){e+=1+n,h.default.forEachChild(s,a=>r(a,n,!1));return}if(h.default.isConditionalExpression(s)&&(e+=1),h.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===h.default.SyntaxKind.AmpersandAmpersandToken||a===h.default.SyntaxKind.BarBarToken||a===h.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(h.default.isFunctionDeclaration(s)||h.default.isFunctionExpression(s)||h.default.isArrowFunction(s))){e+=1+n,h.default.forEachChild(s,a=>r(a,n+1,!1));return}h.default.forEachChild(s,a=>r(a,n,!1))}return r(t,0,!1),e}function Yt(t){return{complexity:Zi(t),cognitiveComplexity:ea(t)}}var b=f(require("typescript")),Zt=new Set(["test","describe","it"]);function Cs(t,e){ta(t,e),sa(t,e),na(t,e),oa(t,e)}function ta(t,e){if((b.default.isFunctionDeclaration(t)||b.default.isVariableDeclaration(t))&&t.name&&b.default.isIdentifier(t.name)&&ra(t)){let r;if(b.default.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(b.default.isArrowFunction(s)||b.default.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function ra(t){if(b.default.isFunctionDeclaration(t))return b.default.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&b.default.isSourceFile(e.parent)}function sa(t,e){if(!b.default.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function na(t,e){if(!b.default.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function oa(t,e){if(b.default.isCallExpression(t)&&ia(t.expression))for(let r of t.arguments)b.default.isObjectLiteralExpression(r)&&aa(r,e)}function ia(t){return b.default.isIdentifier(t)?Zt.has(t.text):!!(b.default.isPropertyAccessExpression(t)&&(Zt.has(t.name.text)||b.default.isIdentifier(t.expression)&&Zt.has(t.expression.text)))}function aa(t,e){for(let r of t.properties){if(!b.default.isPropertyAssignment(r)||!b.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=b.default.isArrayLiteralExpression(s)?s.elements.filter(b.default.isStringLiteral):r.name.text==="tag"&&b.default.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function tr(t,e,r){let s=[],n=new Map,o=new Set,i=l.default.createSourceFile(t,e,l.default.ScriptTarget.Latest,!0,r==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:t,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},p=R=>{ua(R,a),l.default.forEachChild(R,p)};p(i);let c=ka(t,a);(c==="test"||c==="barrel")&&o.add({name:c,kind:"comment-marker"}),c!=="test"&&wa(a,i);let g=i.statements[0],m=g?Es(g):void 0,{complexity:d,cognitiveComplexity:S}=Yt(i),E=pa(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:c,rawCallEdges:a.rawCallEdges??[],complexity:d,cognitiveComplexity:S,...E.length>0?{functions:E}:{},...m!==void 0?{description:m}:{}}}function pa(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Yt(o),p=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:n,line:p,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.default.isVariableDeclaration(n)&&l.default.isIdentifier(n.name)&&n.initializer&&(l.default.isArrowFunction(n.initializer)||l.default.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):o&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${o}.${n.name.text}`,n):o&&l.default.isConstructorDeclaration(n)&&n.body?r(`${o}.constructor`,n):o&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${o}.get ${n.name.text}`,n):o&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&r(`${o}.set ${n.name.text}`,n),l.default.isClassDeclaration(n)&&n.name){let i=n.name.text;l.default.forEachChild(n,a=>s(a,i));return}l.default.forEachChild(n,i=>s(i,o))};return s(t,void 0),e}function Fs(t,e,r,s){let n={name:t},o=Es(r);o!==void 0&&(n.doc=o);let i=ca(e);i!==void 0&&(n.flags=i);let a=la(e,s);return a!==void 0&&(n.signature=a),n}function Es(t){let e=l.default.getJSDocCommentsAndTags(t);for(let r of e)if(l.default.isJSDoc(r)&&r.comment)return l.default.getTextOfJSDocComment(r.comment)||void 0}function ca(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=l.default.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function la(t,e){let r=l.default.createPrinter({removeComments:!0}),s=n=>r.printNode(l.default.EmitHint.Unspecified,n,e);if(l.default.isFunctionDeclaration(t)||l.default.isMethodDeclaration(t)){let n=t.parameters.map(s).join(", "),o=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(l.default.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer))){let n=t.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(l.default.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(l.default.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(l.default.isTypeAliasDeclaration(t))return s(t.type);if(l.default.isEnumDeclaration(t))return`enum ${t.name.text}`}function ua(t,e){fa(t,e),ga(t,e),da(t,e),ha(t,e),va(t,e),Cs(t,e)}function fa(t,e){if(!l.default.isSourceFile(t))return;let r=t.statements.filter(s=>!l.default.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||rr(s)).length}function ga(t,e){if(l.default.isJsxElement(t)||l.default.isJsxSelfClosingElement(t)||l.default.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(t)||l.default.isMethodDeclaration(t)||l.default.isArrowFunction(t)||l.default.isClassDeclaration(t)||l.default.isVariableStatement(t)||l.default.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}l.default.isExportDeclaration(t)&&!ma(t)&&(e.hasTypesOnly=!1)}function ma(t){return t.isTypeOnly?!0:!t.exportClause||!l.default.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function da(t,e){if(!l.default.isImportDeclaration(t)||!t.moduleSpecifier||!l.default.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(l.default.isNamedImports(t.importClause.namedBindings))for(let n of t.importClause.namedBindings.elements)r.push(n.name.text);else l.default.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:F(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function ha(t,e){l.default.isExportDeclaration(t)?ya(t,e):l.default.isExportAssignment(t)?e.exports.set("default",{name:"default"}):rr(t)&&ba(t,e)}function ya(t,e){if(t.moduleSpecifier&&l.default.isStringLiteral(t.moduleSpecifier))xa(t,t.moduleSpecifier.text,e);else if(t.exportClause&&l.default.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function xa(t,e,r){let s=Sa(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:F(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Sa(t){return t.exportClause?l.default.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ba(t,e){if((l.default.isFunctionDeclaration(t)||l.default.isClassDeclaration(t)||l.default.isInterfaceDeclaration(t)||l.default.isTypeAliasDeclaration(t)||l.default.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Fs(s,t,t,e.sourceFile));return}if(l.default.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,Fs(n,s,t,e.sourceFile))}}}function va(t,e){if(!l.default.isCallExpression(t))return;let r=t.arguments[0];!r||!l.default.isStringLiteral(r)||(t.expression.kind===l.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:F(r.text),type:"dynamic"}):l.default.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:F(r.text),type:"require"}))}function ka(t,e){let r=er.default.basename(t).toLowerCase(),s=er.default.extname(t).toLowerCase();return Z().some(o=>r.includes(o))?"test":gr(r)?"config":e.imports.some(o=>et().some(i=>o.rawSpecifier.includes(i)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>rt()?"barrel":"logic"}function rr(t){return l.default.canHaveModifiers(t)&&l.default.getModifiers(t)?.some(e=>e.kind===l.default.SyntaxKind.ExportKeyword)===!0}function wa(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let n of e.statements){if(!l.default.isImportDeclaration(n)||!l.default.isStringLiteral(n.moduleSpecifier))continue;let o=n.moduleSpecifier.text,i=n.importClause;if(i&&(i.name&&s.set(i.name.text,o),i.namedBindings&&l.default.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)s.set(a.name.text,o)}if(s.size!==0)for(let n of e.statements){let o=Fa(n);if(o){let i=Ea(n);i&&Ke(i,o,s,r);continue}l.default.isClassDeclaration(n)&&n.name&&Ca(n,s,r)}}function Ca(t,e,r){let s=t.name.text;for(let n of t.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?Ke(n.body,`${s}.${n.name.text}`,e,r):l.default.isConstructorDeclaration(n)&&n.body&&Ke(n.body,`${s}.constructor`,e,r)}function Fa(t){if(rr(t)){if(l.default.isFunctionDeclaration(t)&&t.name)return t.name.text;if(l.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(l.default.isIdentifier(e.name)&&e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.name.text}}}function Ea(t){if(l.default.isFunctionDeclaration(t))return t.body;if(l.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.initializer}}function Ke(t,e,r,s){if(l.default.isCallExpression(t)&&l.default.isIdentifier(t.expression)){let n=t.expression.text,o=r.get(n);o&&!s.some(i=>i.from===e&&i.to===n&&i.toSpecifier===o)&&s.push({from:e,to:n,toSpecifier:o})}l.default.forEachChild(t,n=>Ke(n,e,r,s))}function Je(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var sr=f(require("postcss")),Pa=f(require("postcss-less")),Ta=Pa,Ts=new Set(["reference","inline"]);function Ps(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Aa(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Ma(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Ts.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Ps(i)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...Ps(n)?{isExternal:!0}:{}}:null}function Ia(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";Aa(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function As(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Ma(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...Ia(s.value,e))}),r}function Ra(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Na(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=Ts.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function Ms(t,e){let r=sr.default.parse(Ra(t));return{imports:As(r,e),root:r}}function Is(t,e){try{let r=Ta.parse(t);return{imports:As(r,e),root:r}}catch{return{imports:Na(t,e),root:sr.default.parse("")}}}var Rs=require("postcss-scss");function Ga(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Da(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],n=t.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function Ns(t,e){let r=(0,Rs.parse)(t),s=[];return r.walk(n=>{if(n.type!=="atrule")return;let{name:o,params:i}=n;if(o!=="import"&&o!=="use"&&o!=="forward")return;let{specifier:a,alias:p}=Da(i);if(!a)return;let c={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...Ga(a)?{isExternal:!0}:{}};p&&(c.symbols=[p]),s.push(c)}),{imports:s,root:r}}function Gs(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(t);n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(t)}return r}function Ds(t,e){if(e.length===0)return"ui";try{let r=require("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function ge(t,e){let r=I(t);if(r==="stylus"){let o=Gs(e,t);return{imports:o,exports:[],tags:[],category:Ds(e,o)}}if(r==="scss"){let{imports:o,root:i}=Ns(e,t);return{imports:o,exports:[],tags:[],category:Je(i,o)}}if(r==="less"){let{imports:o,root:i}=Is(e,t);return{imports:o,exports:[],tags:[],category:Je(i,o)}}let{imports:s,root:n}=Ms(e,t);return{imports:s,exports:[],tags:[],category:Je(n,s)}}for(let[t,e]of[["javascript",(r,s)=>tr(r,s,"javascript")],["typescript",(r,s)=>tr(r,s,"typescript")],["css",ge],["scss",ge],["less",ge],["stylus",ge],["coffeescript",ps],["livescript",ds],["lua",ys],["python",ws],["go",gs],["gherkin",qt],["markdown",bs]])$(t,e);async function _s(t,e){let r=I(t),s=zr(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var nr=f(require("path"));function Os(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function js(t,e){for(let r of t)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function Ws(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function zs(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);!s||s===e||(s.documentedBy??=[],s.documentedBy.includes(e.path)||s.documentedBy.push(e.path),s.category==="logic"&&(s.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(s.path)||e.staleFor.push(s.path)))}}function Ls(t){return Math.round(t*1e4)/1e4}function $s(t){for(let e of t.values()){let r=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=t.get(s.toPath);if(!n||n.exports.length===0)continue;let o;if(s.symbols===void 0){if(s.type==="side-effect")continue;o=1}else s.symbols.includes("*")?o=1:o=s.symbols.length/n.exports.length;s.exportUsageRatio=Ls(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=Ls(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function or(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function _a(t,e){let r=e.toPath,s=nr.default.basename(r,nr.default.extname(r)).replace(/\.(test|spec)$/,"");or(t.tags,s,"import")}function La(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)or(t.tags,r,"import")}function Oa(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&or(t.tags,n.name,"comment-marker")}function Bs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(_a(e,r),La(e,r),Oa(e,r,t))}var Se=f(require("fs")),A=f(require("path"));var ir=f(require("fs")),_=f(require("path")),me=class{extensions=[".go"];goModCache=new Map;resolve(e,r,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(r,i,s);if(a!==void 0)return Ks(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let p=r.slice(o.length).replace(/^\//,"");return p?Ks(_.default.join(s,p)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=ir.default.readFileSync(_.default.join(e,"go.mod"),"utf-8"),o=ja(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,r,s){for(let[n,o]of r){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return _.default.join(o,i)}}}};function ja(t,e){let r=t.split(`
23
- `),s=null,n=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){Us(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&Us(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function Us(t,e,r){let[s,n]=t.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=_.default.isAbsolute(n)?n:_.default.resolve(e,n);r.set(o,i)}function Ks(t){let e;try{e=ir.default.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:_.default.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var Js=f(require("fs")),He=f(require("path")),de=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,He.default.sep),i=[s,He.default.join(s,"lib")];for(let a of i){if(!Js.default.existsSync(a))continue;let p=n(He.default.join(a,"_dummy.lua"),o);if(p)return[p]}return null}};var Hs=f(require("path")),he=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(Hs.default.join(s,"_dummy"),`./${r}`);return o?[o]:null}};var Vs=f(require("fs")),Qe=f(require("path")),ye=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,Qe.default.sep),i=Qe.default.join(s,`${o}.py`);if(Qs(i))return[{path:i,isExternal:!1}];let a=Qe.default.join(s,o,"__init__.py");return Qs(a)?[{path:a,isExternal:!1}]:null}};function Qs(t){try{return Vs.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var ar=f(require("path")),Wa=["~","http://","https://","//","data:","sass:"],xe=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(Wa.some(g=>r.startsWith(g)))return null;let o=n(e,r);if(o)return[o];let i=ar.default.dirname(r),a=ar.default.basename(r),p=i==="."?`_${a}`:`${i}/_${a}`,c=n(e,p);return c?[c]:null}};var L=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new ye,new de,new me,new xe,new he]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(r);return o||{path:r,isExternal:!0}}resolveLocalPath(e,r){let s=A.default.dirname(e),n=r.startsWith("/")?r:A.default.resolve(s,r),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let p=n.slice(0,-a[0].length);for(let c of[".ts",".tsx"]){let g=this.tryExtensions(p,c,o);if(g)return g}}for(let p of i){let c=this.tryExtensions(n,p,o);if(c)return c}return o?{path:n,isExternal:!0}:null}tryExtensions(e,r,s){let n=e+r;if(this.isFile(n))return{path:n,isExternal:s};let o=A.default.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=A.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return Se.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,e),n=this.pathAliases[r];if(s&&n){let o=this.tryAliasSubstitutions(n,s[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let s=A.default.join(r,"tsconfig.json");if(Se.default.existsSync(s))try{let o=JSON.parse(Se.default.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let p=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(p)return p}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return r.match(s)}tryAliasSubstitutions(e,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=A.default.resolve(s,i);for(let p of n){let c=this.tryExtensions(a,p,!1);if(c)return c}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let n=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let p=A.default.join(s,a);try{if(Se.default.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(A.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var za=["tests","test","__tests__","specs","spec"],qs=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),$a=20;function Ba(t,e){if(t.length===0)return e;let r=t.map(i=>w.default.dirname(i).split(w.default.sep)),s=r[0];for(let i of r.slice(1)){let a=0;for(;a<s.length&&a<i.length&&s[a]===i[a];)a++;s=s.slice(0,a)}let n=s.join(w.default.sep)||w.default.sep,o=w.default.relative(e,n);return o.startsWith("..")||w.default.isAbsolute(o)?e:n}var be=class{constructor(e,r=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new L(e),this.lockFile=is(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(s=>w.default.isAbsolute(s)?s:w.default.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ss(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(Ba(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
17
+ `;return c+d+g+i+`
18
+ `+m}};function gi(t){let e=t.split(`
19
+ `),r=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(r=n)}if(r<0)return 0;let s=0;for(let n=0;n<=r;n++)s+=e[n].length+1;return s}var Bt=f(require("path")),Ut=f(require("typescript"));var di=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,ze=class{name="vitest";canHandle(e){return T.has(Bt.default.extname(e).toLowerCase())}apply(e,r,s){let n=r.replace(di,""),o=Ut.default.createSourceFile(Bt.default.basename(e),n,Ut.default.ScriptTarget.Latest,!0),i=K(o);if(i.length===0)return n;let a=J(i[0],"tags",o),p=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(p))return n;let c=i.flatMap(m=>{let g=s.length===0?Q(m,"tags",o):H(m,"tags",q(p),o);return g?[g]:[]});return c.length>0?V(n,c):n}};var Xr={vitest:()=>new ze,playwright:()=>new je,cypress:()=>new De,jest:()=>new Oe},hi={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function yi(t){let e=ue.default.createSourceFile("detect.ts",t,ue.default.ScriptTarget.Latest,!0);for(let r of e.statements){if(!ue.default.isImportDeclaration(r)||!ue.default.isStringLiteral(r.moduleSpecifier))continue;let s=hi[r.moduleSpecifier.text];if(s)return s}return null}var Kt=class{constructor(e,r,s){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return T.has($e.default.extname(e).toLowerCase())}apply(e,r,s){let n=yi(r)??this.matchOverride(e)??this.defaultFramework;return(Xr[n]??Xr.vitest)().apply(e,r,s)}matchOverride(e){let r=$e.default.relative(this.rootDir,e).split($e.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Hr(s,r))return n;return null}};function Yr(t="vitest",e={},r=process.cwd()){return[new _e,new We,new Le,new Kt(r,t,Object.entries(e))]}function Zr(t,e){return e.find(r=>r.canHandle(t))??null}var xi=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Si=new Set(["import"]),bi=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function vi(t,e,r,s){let n;try{n=await Jt.default.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let o=Zr(t,s);if(!o)return{path:t,status:"unchanged"};let i=o.apply(t,n,e);return i===n?{path:t,status:"unchanged"}:(r||await Jt.default.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Ht(t,e,r){let s=te(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=Yr(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let p of t.nodes.values()){if(p.category!=="test")continue;let c=new Set,m=[];for(let S of p.tags)Si.has(S.kind)&&xi.test(S.name)&&(bi.has(S.name.toLowerCase())||c.has(S.name)||(c.add(S.name),m.push(S.name)));m.sort();let g=es.default.resolve(e,p.path),d=await vi(g,m,r.dryRun,i);d.path=p.path,a.files.push(d),d.status==="updated"?a.updated++:d.status==="unchanged"?a.unchanged++:a.errors++}return a}var Be=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}};var Y=f(require("fs")),C=f(require("path")),tn=f(require("piscina"));var Ue=require("child_process"),Ke=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(s=>{try{return(0,Ue.execFileSync)("git",s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
20
+ `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},ts="%x00%H%x09%ae%x09%at",rs=256*1024*1024;function ss(t,e){let r="",s=0;for(let n of t.split(`
21
+ `)){if(n.startsWith("\0")){let[,p,c]=n.slice(1).split(" ");r=p??"",s=c?Number(c)*1e3:0;continue}if(n==="")continue;let o=n.split(" "),i=o[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?o[2]:o[1];a&&e(a,r,s)}}function ns(t){let e=new Map;try{let r=(0,Ue.execFileSync)("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${ts}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:rs});ss(r,(s,n,o)=>{let i=e.get(s);if(i){i.commitCount90d+=1;return}e.set(s,{commitCount90d:1,lastAuthor:n||void 0,lastCommitAt:o||void 0})})}catch{return e}try{let r=(0,Ue.execFileSync)("git",["-C",t,"log","--name-status","-M",`--format=${ts}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:rs});ss(r,(s,n,o)=>{e.has(s)||e.set(s,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:o||void 0})})}catch{}return e}var fe=f(require("fs")),os=f(require("path")),Qt=require("js-yaml");function is(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function ki(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),is(r)}).filter(Boolean)}function Ci(t,e){let r=t.startsWith("/")?t.slice(1):t,s=r.lastIndexOf("@");return s>0?{name:r.substring(0,s),version:e||r.substring(s+1)}:{name:r,version:e}}function wi(t){try{let e=(0,Qt.load)(t),r={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=is(o);i&&(r.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return r}catch{return null}}function Ei(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let s=r.split(`
22
+ `).filter(p=>p.trim().length>0&&!p.trim().startsWith("#"));if(s.length<2)continue;let n=s[0];if(!n||n.startsWith(" "))continue;let o=ki(n);if(o.length===0)continue;let a=s.find(p=>p.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let p of o)e.dependencies[p]={version:a}}return e}function Fi(t){let e=fe.default.readFileSync(t,"utf-8"),r=JSON.parse(e),s={dependencies:{}};if(r.packages)for(let[n,o]of Object.entries(r.packages)){if(!n.startsWith("node_modules/"))continue;let i=n.replace("node_modules/","");i.includes("node_modules/")||(s.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}else if(r.dependencies)for(let[n,o]of Object.entries(r.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Ti(t){let e=fe.default.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=wi(e);if(r!==null)return r}return Ei(e)}function Pi(t){let e=fe.default.readFileSync(t,"utf-8"),r={dependencies:{}};try{let s=(0,Qt.load)(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Ci(n,o.version);i&&(r.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(r.dependencies[n])continue;let i=typeof o=="string"?o:o.version;r.dependencies[n]={version:i||""}}}catch{}return r}function as(t){let e=[["package-lock.json",Fi],["yarn.lock",Ti],["pnpm-lock.yaml",Pi]];for(let[r,s]of e){let n=os.default.join(t,r);if(fe.default.existsSync(n))return s(n)}return null}var Vt=f(require("path"));function I(t){switch(Vt.default.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function E(t){let e=Vt.default.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var cs=f(require("coffeescript"));function N(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function ls(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return N(t.value)}}function L(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Ai(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Mi(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Ii(t,e){let r=ls(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:E(r),type:"static"}:null}function Ni(t,e){let r=e.variable?.base?.value==="require",s=ls(e.args?.[0]?.base);return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:E(s),type:"require"}}function ps(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let n=L(r.variable);return n?[{name:n}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(n=>L(n.variable)??L(n)).filter(n=>!!n).map(n=>({name:n}));let s=L(r);return s?[{name:s}]:[]}function Ri(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=L(t.variable)??L(t.variable?.base);return e?[{name:e}]:[]}function Gi(t,e,r,s){let n=e.constructor?.name;if(n==="ImportDeclaration"){let o=Ii(t,e);o&&r.push(o)}else if(n==="Call"){let o=Ni(t,e);o&&r.push(o)}else if(n==="Assign"){let o=L(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;o==="module"&&i==="exports"?s.push(...ps(e,void 0)):o==="exports"&&typeof i=="string"&&s.push(...ps(e,i))}else n==="ExportNamedDeclaration"&&e.clause?s.push(...Ri(e.clause)):n==="ExportDefaultDeclaration"&&s.push({name:"default"})}function qt(t,e,r,s){if(!(!e||typeof e!="object")){Gi(t,e,r,s);for(let n in e){if(n==="locationData")continue;let o=e[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)qt(t,i,r,s);else qt(t,o,r,s)}}}function us(t,e){let r=Ai(e),s=Mi(t,r),n=[],o=[];try{qt(t,cs.default.nodes(e),n,o)}catch{}let i=new Set,a=o.filter(p=>i.has(p.name)?!1:(i.add(p.name),!0));return{imports:n,exports:a,tags:Array.from(r).map(p=>({name:p,kind:"comment-marker"})),category:s}}var X=require("@cucumber/gherkin"),fs=require("@cucumber/messages");var Di=fs.IdGenerator.uuid();function Xt(t,e){let r=new Set;try{let s=new X.AstBuilder(Di),n=new X.GherkinClassicTokenMatcher,i=new X.Parser(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)}),a.scenario.examples.forEach(p=>{p.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})),a.rule&&a.rule.children.forEach(p=>{p.scenario&&p.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}U("gherkin",Xt);var gs=f(require("path")),ds=require("@lezer/go"),_i=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Li=/^\/\/go:build\s+(.+)$/,Oi=/^\/\/\s*\+build\s+(.+)$/;function hs(t,e){let r=[],s=new Map,n=new Set,o=new Set,a=ds.parser.parse(e).cursor();do switch(a.name){case"LineComment":{let g=e.slice(a.from,a.to),d=g.match(_i);d?.[1]&&n.add(d[1]);let S=g.match(Li);S&&ms(S[1],o);let F=g.match(Oi);F&&ms(F[1],o);break}case"ImportSpec":{let g=a.node.getChild("String");if(g){let S=e.slice(g.from,g.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:S,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let g=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(g){let d=e.slice(g.from,g.to);d!=="_"&&/^[A-Z]/.test(d)&&!s.has(d)&&s.set(d,{name:d})}break}}while(a.next());let p=r.some(g=>g.rawSpecifier==="testing"),c=gs.default.basename(t).endsWith("_test.go")||n.has("test")||p?"test":"logic",m=new Set([...n,...o]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(m).map(g=>({name:g,kind:"comment-marker"})),category:c}}function ms(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var ys=f(require("livescript"));function ji(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Wi(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var zi=new Set(["first_line","first_column","last_line","last_column","line","column"]);function $i(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let n=N(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:E(n),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=N(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:E(o),type:"require"}}}}return null}function Yt(t,e){if(!t||typeof t!="object")return[];let r=[],s=$i(t,e);s&&r.push(s);for(let n in t){if(zi.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)r.push(...Yt(i,e));else r.push(...Yt(o,e))}return r}function xs(t,e){let r=ji(e),s=Wi(t,r),n=[];try{n=Yt(ys.default.ast(e),t)}catch{}return{imports:n,exports:[],tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Ss=f(require("luaparse"));function Bi(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Ui(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Ki(t,e){let r=[];function s(n){if(!(!n||typeof n!="object")){if((n.type==="CallExpression"||n.type==="StringCallExpression")&&n.base?.type==="Identifier"&&n.base?.name==="require"){let o;if(n.type==="CallExpression"){let i=n.arguments?.[0];i?.type==="StringLiteral"&&(o=N(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=N(i.raw))}o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:E(o),type:"require"})}for(let o in n){if(o==="loc")continue;let i=n[o];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)s(a);else s(i)}}}return s(t),r}function Ji(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((s,n)=>{r.init[n]?.type==="TableConstructorExpression"&&e.add(s.name)});return e}function Hi(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let s=[];for(let n of r.fields)n.type==="TableKeyString"&&s.push({name:n.key.name});return s}function Qi(t){let e=t.body,r=Ji(e),s=Hi(e);for(let o of e)if(o.type==="FunctionDeclaration")o.identifier?.type==="MemberExpression"?o.identifier.base.type==="Identifier"&&r.has(o.identifier.base.name)&&s.push({name:o.identifier.identifier.name}):o.identifier?.type==="Identifier"&&!o.isLocal&&s.push({name:o.identifier.name});else if(o.type==="AssignmentStatement")for(let i of o.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&s.push({name:i.identifier.name});let n=new Set;return s.filter(o=>n.has(o.name)?!1:(n.add(o.name),!0))}function bs(t,e){let r=Bi(e),s=Ui(t,r),n=[],o=[];try{let i=Ss.default.parse(e);n=Ki(i,t),o=Qi(i)}catch{}return{imports:n,exports:o,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:s}}var Vi=["http://","https://","mailto:","//"],qi="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Xi=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${qi})\\b`,"g"),vs;async function Yi(){return vs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),vs}function Zi(t){let e=t.trim();return e.length===0||e.startsWith("#")||Vi.some(r=>e.startsWith(r))}function ea(t,e){let r=t.match(Xi);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function ks(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Zi(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(...ea(t.value,e)),Array.isArray(t.children))for(let s of t.children)ks(s,e,r)}async function Cs(t,e){let s=(await Yi()).parse(e),n=[];ks(s,t,n);let o=new Set;return{imports:n.filter(a=>o.has(a.rawSpecifier)?!1:(o.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var ws=f(require("path")),Es=require("@lezer/python"),ta=new Set(["pytest","unittest","nose","hypothesis"]);function Fs(t,e){let r=[],s=[],n=new Set,o=ws.default.basename(t).toLowerCase(),a=Es.parser.parse(e).cursor();do switch(a.name){case"Comment":{let c=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);c?.[1]&&n.add(c[1]);break}case"ImportStatement":{for(let c of ra(a.node,e,t))r.push(c);break}case"FunctionDefinition":case"ClassDefinition":{let c=a.node.parent;if(c?.name==="Script"||c?.name==="DecoratedStatement"&&c.parent?.name==="Script"){let g=a.node.getChild("VariableName");g&&s.push({name:e.slice(g.from,g.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let c=a.node.firstChild;c?.name==="VariableName"&&s.push({name:e.slice(c.from,c.to)})}break}}while(a.next());let p=ia(o,r,n);return p==="test"&&n.add("test"),{imports:r,exports:s,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:p}}function ra(t,e,r){let s=t.firstChild;return s?s.name==="from"?sa(t,e,r):na(t,e,r):[]}function sa(t,e,r){let s=t.firstChild;if(!s)return[];let n=s.nextSibling;for(;n&&n.name!=="import";)n=n.nextSibling;if(!n)return[];let o=e.slice(s.to,n.from).trim(),i=oa(n.nextSibling,e);if(!i.length)return[];let a=0;for(;a<o.length&&o[a]===".";)a++;let p=o.slice(a);if(a===0)return[me(r,o,i,!0)];let c=a===1?"./":"../".repeat(a-1);return p?[me(r,c+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[me(r,c.slice(0,-1),["*"],!1)]:i.map(m=>me(r,c+m,[m],!1))}function na(t,e,r){let s=[],n=t.firstChild?.nextSibling??null;for(;n;){if(n.name==="VariableName"){let o=e.slice(n.from,n.to);for(;n.nextSibling?.name==="."&&n.nextSibling.nextSibling?.name==="VariableName";)n=n.nextSibling.nextSibling,o+=`.${e.slice(n.from,n.to)}`;n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling),s.push(me(r,o,["*"],!0))}n=n.nextSibling}return s}function oa(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function me(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function ia(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>ta.has(s.rawSpecifier))?"test":"logic"}var tr=f(require("path")),l=f(require("typescript"));var h=f(require("typescript"));function aa(t){let e=1;function r(s){switch(s.kind){case h.default.SyntaxKind.IfStatement:case h.default.SyntaxKind.ConditionalExpression:case h.default.SyntaxKind.ForStatement:case h.default.SyntaxKind.ForInStatement:case h.default.SyntaxKind.ForOfStatement:case h.default.SyntaxKind.WhileStatement:case h.default.SyntaxKind.DoStatement:case h.default.SyntaxKind.CatchClause:case h.default.SyntaxKind.CaseClause:e++;break;case h.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===h.default.SyntaxKind.AmpersandAmpersandToken||n===h.default.SyntaxKind.BarBarToken||n===h.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}h.default.forEachChild(s,r)}return r(t),e}function pa(t){let e=0;function r(s,n,o){if(h.default.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;r(s.expression,a,!1),r(s.thenStatement,a,!1),s.elseStatement&&(h.default.isIfStatement(s.elseStatement)?r(s.elseStatement,n,!0):(e+=1,r(s.elseStatement,n+1,!1)));return}if(h.default.isForStatement(s)||h.default.isForInStatement(s)||h.default.isForOfStatement(s)||h.default.isWhileStatement(s)||h.default.isDoStatement(s)||h.default.isSwitchStatement(s)){e+=1+n,h.default.forEachChild(s,a=>r(a,n+1,!1));return}if(h.default.isCatchClause(s)){e+=1+n,h.default.forEachChild(s,a=>r(a,n,!1));return}if(h.default.isConditionalExpression(s)&&(e+=1),h.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===h.default.SyntaxKind.AmpersandAmpersandToken||a===h.default.SyntaxKind.BarBarToken||a===h.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(h.default.isFunctionDeclaration(s)||h.default.isFunctionExpression(s)||h.default.isArrowFunction(s))){e+=1+n,h.default.forEachChild(s,a=>r(a,n+1,!1));return}h.default.forEachChild(s,a=>r(a,n,!1))}return r(t,0,!1),e}function Zt(t){return{complexity:aa(t),cognitiveComplexity:pa(t)}}var b=f(require("typescript")),er=new Set(["test","describe","it"]);function Ts(t,e){ca(t,e),ua(t,e),fa(t,e),ma(t,e)}function ca(t,e){if((b.default.isFunctionDeclaration(t)||b.default.isVariableDeclaration(t))&&t.name&&b.default.isIdentifier(t.name)&&la(t)){let r;if(b.default.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(b.default.isArrowFunction(s)||b.default.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function la(t){if(b.default.isFunctionDeclaration(t))return b.default.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&b.default.isSourceFile(e.parent)}function ua(t,e){if(!b.default.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function fa(t,e){if(!b.default.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),n=r.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=r.exec(s)}function ma(t,e){if(b.default.isCallExpression(t)&&ga(t.expression))for(let r of t.arguments)b.default.isObjectLiteralExpression(r)&&da(r,e)}function ga(t){return b.default.isIdentifier(t)?er.has(t.text):!!(b.default.isPropertyAccessExpression(t)&&(er.has(t.name.text)||b.default.isIdentifier(t.expression)&&er.has(t.expression.text)))}function da(t,e){for(let r of t.properties){if(!b.default.isPropertyAssignment(r)||!b.default.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,n=b.default.isArrayLiteralExpression(s)?s.elements.filter(b.default.isStringLiteral):r.name.text==="tag"&&b.default.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function rr(t,e,r){let s=[],n=new Map,o=new Set,i=l.default.createSourceFile(t,e,l.default.ScriptTarget.Latest,!0,r==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:t,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},p=R=>{Sa(R,a),l.default.forEachChild(R,p)};p(i);let c=Ma(t,a);(c==="test"||c==="barrel")&&o.add({name:c,kind:"comment-marker"}),c!=="test"&&Ia(a,i);let m=i.statements[0],g=m?As(m):void 0,{complexity:d,cognitiveComplexity:S}=Zt(i),F=ha(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:c,rawCallEdges:a.rawCallEdges??[],complexity:d,cognitiveComplexity:S,...F.length>0?{functions:F}:{},...g!==void 0?{description:g}:{}}}function ha(t){let e=[],r=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Zt(o),p=t.getLineAndCharacterOfPosition(o.getStart(t)).line+1;e.push({name:n,line:p,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?r(n.name.text,n):l.default.isVariableDeclaration(n)&&l.default.isIdentifier(n.name)&&n.initializer&&(l.default.isArrowFunction(n.initializer)||l.default.isFunctionExpression(n.initializer))?r(n.name.text,n.initializer):o&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${o}.${n.name.text}`,n):o&&l.default.isConstructorDeclaration(n)&&n.body?r(`${o}.constructor`,n):o&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?r(`${o}.get ${n.name.text}`,n):o&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&r(`${o}.set ${n.name.text}`,n),l.default.isClassDeclaration(n)&&n.name){let i=n.name.text;l.default.forEachChild(n,a=>s(a,i));return}l.default.forEachChild(n,i=>s(i,o))};return s(t,void 0),e}function Ps(t,e,r,s){let n={name:t},o=As(r);o!==void 0&&(n.doc=o);let i=ya(e);i!==void 0&&(n.flags=i);let a=xa(e,s);return a!==void 0&&(n.signature=a),n}function As(t){let e=l.default.getJSDocCommentsAndTags(t);for(let r of e)if(l.default.isJSDoc(r)&&r.comment)return l.default.getTextOfJSDocComment(r.comment)||void 0}function ya(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=l.default.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function xa(t,e){let r=l.default.createPrinter({removeComments:!0}),s=n=>r.printNode(l.default.EmitHint.Unspecified,n,e);if(l.default.isFunctionDeclaration(t)||l.default.isMethodDeclaration(t)){let n=t.parameters.map(s).join(", "),o=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(l.default.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(l.default.isArrowFunction(t.initializer)||l.default.isFunctionExpression(t.initializer))){let n=t.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(l.default.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(l.default.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(l.default.isTypeAliasDeclaration(t))return s(t.type);if(l.default.isEnumDeclaration(t))return`enum ${t.name.text}`}function Sa(t,e){ba(t,e),va(t,e),Ca(t,e),wa(t,e),Aa(t,e),Ts(t,e)}function ba(t,e){if(!l.default.isSourceFile(t))return;let r=t.statements.filter(s=>!l.default.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||sr(s)).length}function va(t,e){if(l.default.isJsxElement(t)||l.default.isJsxSelfClosingElement(t)||l.default.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(t)||l.default.isMethodDeclaration(t)||l.default.isArrowFunction(t)||l.default.isClassDeclaration(t)||l.default.isVariableStatement(t)||l.default.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}l.default.isExportDeclaration(t)&&!ka(t)&&(e.hasTypesOnly=!1)}function ka(t){return t.isTypeOnly?!0:!t.exportClause||!l.default.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Ca(t,e){if(!l.default.isImportDeclaration(t)||!t.moduleSpecifier||!l.default.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(l.default.isNamedImports(t.importClause.namedBindings))for(let n of t.importClause.namedBindings.elements)r.push(n.name.text);else l.default.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:E(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function wa(t,e){l.default.isExportDeclaration(t)?Ea(t,e):l.default.isExportAssignment(t)?e.exports.set("default",{name:"default"}):sr(t)&&Pa(t,e)}function Ea(t,e){if(t.moduleSpecifier&&l.default.isStringLiteral(t.moduleSpecifier))Fa(t,t.moduleSpecifier.text,e);else if(t.exportClause&&l.default.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function Fa(t,e,r){let s=Ta(t),n={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:E(e),type:"re-export"};s.length>0&&(n.symbols=s),r.imports.push(n)}function Ta(t){return t.exportClause?l.default.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Pa(t,e){if((l.default.isFunctionDeclaration(t)||l.default.isClassDeclaration(t)||l.default.isInterfaceDeclaration(t)||l.default.isTypeAliasDeclaration(t)||l.default.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Ps(s,t,t,e.sourceFile));return}if(l.default.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,Ps(n,s,t,e.sourceFile))}}}function Aa(t,e){if(!l.default.isCallExpression(t))return;let r=t.arguments[0];!r||!l.default.isStringLiteral(r)||(t.expression.kind===l.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"dynamic"}):l.default.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:E(r.text),type:"require"}))}function Ma(t,e){let r=tr.default.basename(t).toLowerCase(),s=tr.default.extname(t).toLowerCase();return ee().some(o=>r.includes(o))?"test":gr(r)?"config":e.imports.some(o=>tt().some(i=>o.rawSpecifier.includes(i)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>st()?"barrel":"logic"}function sr(t){return l.default.canHaveModifiers(t)&&l.default.getModifiers(t)?.some(e=>e.kind===l.default.SyntaxKind.ExportKeyword)===!0}function Ia(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let n of e.statements){if(!l.default.isImportDeclaration(n)||!l.default.isStringLiteral(n.moduleSpecifier))continue;let o=n.moduleSpecifier.text,i=n.importClause;if(i&&(i.name&&s.set(i.name.text,o),i.namedBindings&&l.default.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)s.set(a.name.text,o)}if(s.size!==0)for(let n of e.statements){let o=Ra(n);if(o){let i=Ga(n);i&&Je(i,o,s,r);continue}l.default.isClassDeclaration(n)&&n.name&&Na(n,s,r)}}function Na(t,e,r){let s=t.name.text;for(let n of t.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?Je(n.body,`${s}.${n.name.text}`,e,r):l.default.isConstructorDeclaration(n)&&n.body&&Je(n.body,`${s}.constructor`,e,r)}function Ra(t){if(sr(t)){if(l.default.isFunctionDeclaration(t)&&t.name)return t.name.text;if(l.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(l.default.isIdentifier(e.name)&&e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.name.text}}}function Ga(t){if(l.default.isFunctionDeclaration(t))return t.body;if(l.default.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.initializer}}function Je(t,e,r,s){if(l.default.isCallExpression(t)&&l.default.isIdentifier(t.expression)){let n=t.expression.text,o=r.get(n);o&&!s.some(i=>i.from===e&&i.to===n&&i.toSpecifier===o)&&s.push({from:e,to:n,toSpecifier:o})}l.default.forEachChild(t,n=>Je(n,e,r,s))}function He(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var nr=f(require("postcss")),Da=f(require("postcss-less")),_a=Da,Is=new Set(["reference","inline"]);function Ms(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function La(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Oa(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let o=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Is.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Ms(i)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...Ms(n)?{isExternal:!0}:{}}:null}function ja(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"";La(o)&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(t)}return r}function Ns(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Oa(s.params,e);n&&r.push(n)}s.type==="decl"&&r.push(...ja(s.value,e))}),r}function Wa(t){return t.replace(/(?<!:)\/\/.*/g,"")}function za(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=Is.has(o)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(t)}return r}function Rs(t,e){let r=nr.default.parse(Wa(t));return{imports:Ns(r,e),root:r}}function $a(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type!=="atrule")continue;let{value:n}=s;if(n===void 0)continue;let o=s.name;o&&(e.push({name:o}),r.push({name:o,kind:"variable"}))}return{exports:e,tags:r}}function Gs(t,e){try{let r=_a.parse(t),{exports:s,tags:n}=$a(r);return{imports:Ns(r,e),root:r,exports:s,tags:n}}catch{return{imports:za(t,e),root:nr.default.parse(""),exports:[],tags:[]}}}var _s=require("postcss-scss");function Ds(t){return t.startsWith("_")||t.startsWith("-")}function Ba(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Ua(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],n=t.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:r,alias:n}:{specifier:r}}function Ka(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type==="decl"&&s.prop.startsWith("$")){let n=s.prop.slice(1);if(!n||Ds(n))continue;e.push({name:n}),r.push({name:n,kind:"variable"});continue}if(s.type==="atrule"&&(s.name==="mixin"||s.name==="function")){let o=s.params.match(/^([\w-]+)/)?.[1];if(!o||Ds(o))continue;let i=s.params.trim();e.push(i.includes("(")?{name:o,signature:i}:{name:o}),r.push({name:o,kind:"function"})}}return{exports:e,tags:r}}function Ls(t,e){let r=(0,_s.parse)(t),s=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:p}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:c,alias:m}=Ua(p);if(!c)return;let g={fromPath:e,toPath:"",rawSpecifier:c,isStyle:!0,type:a==="forward"?"re-export":"static",...Ba(c)?{isExternal:!0}:{}};m&&(g.symbols=[m]),s.push(g)});let{exports:n,tags:o}=Ka(r);return{imports:s,root:r,exports:n,tags:o}}function Os(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(t);for(;n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(t)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(t);n!==null;){let i=n[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(t)}return r}function js(t,e){if(e.length===0)return"ui";try{let r=require("stylus");return new r.Parser(t).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function ge(t,e){let r=I(t);if(r==="stylus"){let o=Os(e,t);return{imports:o,exports:[],tags:[],category:js(e,o)}}if(r==="scss"){let{imports:o,root:i,exports:a,tags:p}=Ls(e,t);return{imports:o,exports:a,tags:p,category:He(i,o)}}if(r==="less"){let{imports:o,root:i,exports:a,tags:p}=Gs(e,t);return{imports:o,exports:a,tags:p,category:He(i,o)}}let{imports:s,root:n}=Rs(e,t);return{imports:s,exports:[],tags:[],category:He(n,s)}}for(let[t,e]of[["javascript",(r,s)=>rr(r,s,"javascript")],["typescript",(r,s)=>rr(r,s,"typescript")],["css",ge],["scss",ge],["less",ge],["stylus",ge],["coffeescript",us],["livescript",xs],["lua",bs],["python",Fs],["go",hs],["gherkin",Xt],["markdown",Cs]])U(t,e);async function Ws(t,e){let r=I(t),s=$r(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}var or=f(require("path"));function $s(t,e){for(let r of t.values()){let s=e.get(r.path);s!==void 0&&(r.coveragePct=s)}}function Bs(t,e){for(let r of t)if(r.isExternal){let s=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function Us(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function Ks(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let s=t.get(r.toPath);!s||s===e||(s.documentedBy??=[],s.documentedBy.includes(e.path)||s.documentedBy.push(e.path),s.category==="logic"&&(s.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(s.path)||e.staleFor.push(s.path)))}}function zs(t){return Math.round(t*1e4)/1e4}function Js(t){for(let e of t.values()){let r=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=t.get(s.toPath);if(!n||n.exports.length===0)continue;let o;if(s.symbols===void 0){if(s.type==="side-effect")continue;o=1}else s.symbols.includes("*")?o=1:o=s.symbols.length/n.exports.length;s.exportUsageRatio=zs(Math.min(1,o)),r.push(s.exportUsageRatio)}r.length>0&&(e.avgExportUsage=zs(r.reduce((s,n)=>s+n,0)/r.length),e.maxExportUsage=Math.max(...r))}}function ir(t,e,r){e&&(t.some(s=>s.name===e&&s.kind===r)||t.push({name:e,kind:r}))}function Ja(t,e){let r=e.toPath,s=or.default.basename(r,or.default.extname(r)).replace(/\.(test|spec)$/,"");ir(t.tags,s,"import")}function Ha(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)ir(t.tags,r,"import")}function Qa(t,e,r){let s=r.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&ir(t.tags,n.name,"comment-marker")}function Hs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(Ja(e,r),Ha(e,r),Qa(e,r,t))}var be=f(require("fs")),A=f(require("path"));var ar=f(require("fs")),O=f(require("path")),de=class{extensions=[".go"];goModCache=new Map;resolve(e,r,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(r,i,s);if(a!==void 0)return Vs(a);if(r!==o&&!r.startsWith(`${o}/`))return null;let p=r.slice(o.length).replace(/^\//,"");return p?Vs(O.default.join(s,p)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let s={mod:null,replaces:new Map};try{let n=ar.default.readFileSync(O.default.join(e,"go.mod"),"utf-8"),o=Va(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,r,s){for(let[n,o]of r){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return O.default.join(o,i)}}}};function Va(t,e){let r=t.split(`
23
+ `),s=null,n=new Map,o=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){s=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){o=!0;continue}if(o&&a===")"){o=!1;continue}if(o&&a.includes("=>")){Qs(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&Qs(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function Qs(t,e,r){let[s,n]=t.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=O.default.isAbsolute(n)?n:O.default.resolve(e,n);r.set(o,i)}function Vs(t){let e;try{e=ar.default.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:O.default.join(t,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return r.length>0?r:null}var qs=f(require("fs")),Qe=f(require("path")),he=class{extensions=[".lua"];resolve(e,r,s,n){let o=r.replace(/\./g,Qe.default.sep),i=[s,Qe.default.join(s,"lib")];for(let a of i){if(!qs.default.existsSync(a))continue;let p=n(Qe.default.join(a,"_dummy.lua"),o);if(p)return[p]}return null}};var Xs=f(require("path")),ye=class{extensions=[".md",".mdx"];resolve(e,r,s,n){let o=n(Xs.default.join(s,"_dummy"),`./${r}`);return o?[o]:null}};var Zs=f(require("fs")),Ve=f(require("path")),xe=class{extensions=[".py"];resolve(e,r,s,n){let o=r.replace(/\./g,Ve.default.sep),i=Ve.default.join(s,`${o}.py`);if(Ys(i))return[{path:i,isExternal:!1}];let a=Ve.default.join(s,o,"__init__.py");return Ys(a)?[{path:a,isExternal:!1}]:null}};function Ys(t){try{return Zs.default.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var pr=f(require("path")),qa=["~","http://","https://","//","data:","sass:"],Se=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,s,n){if(qa.some(m=>r.startsWith(m)))return null;let o=n(e,r);if(o)return[o];let i=pr.default.dirname(r),a=pr.default.basename(r),p=i==="."?`_${a}`:`${i}/_${a}`,c=n(e,p);return c?[c]:null}};var j=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new xe,new he,new de,new Se,new ye]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let s=this.resolvePathAlias(r);if(s)return[s];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(r);return o?[o]:[{path:r,isExternal:!0}]}resolve(e,r){let s=this.resolvePathAlias(r);if(s)return s;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let n=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(r);return o||{path:r,isExternal:!0}}resolveLocalPath(e,r){let s=A.default.dirname(e),n=r.startsWith("/")?r:A.default.resolve(s,r),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=n.match(/\.(js|mjs|cjs)$/);if(a){let p=n.slice(0,-a[0].length);for(let c of[".ts",".tsx"]){let m=this.tryExtensions(p,c,o);if(m)return m}}for(let p of i){let c=this.tryExtensions(n,p,o);if(c)return c}return o?{path:n,isExternal:!0}:null}tryExtensions(e,r,s){let n=e+r;if(this.isFile(n))return{path:n,isExternal:s};let o=A.default.join(e,`index${r}`);if(this.isFile(o))return{path:o,isExternal:s};if(r===".py"){let i=A.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return be.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let s=this.matchAliasPattern(r,e),n=this.pathAliases[r];if(s&&n){let o=this.tryAliasSubstitutions(n,s[1]||"");if(o)return o}}for(let r of this.tsconfigSearchPaths){let s=A.default.join(r,"tsconfig.json");if(be.default.existsSync(s))try{let o=JSON.parse(be.default.readFileSync(s,"utf-8")).compilerOptions?.paths;if(!o)continue;for(let i in o){let a=this.matchAliasPattern(i,e);if(a){let p=this.tryAliasSubstitutions(o[i],a[1]||"",r);if(p)return p}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return r.match(s)}tryAliasSubstitutions(e,r,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",r),a=A.default.resolve(s,i);for(let p of n){let c=this.tryExtensions(a,p,!1);if(c)return c}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,s]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let n=e.slice(r.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let p=A.default.join(s,a);try{if(be.default.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(A.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var Xa=["tests","test","__tests__","specs","spec"],en=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Ya=20;function Za(t,e){if(t.length===0)return e;let r=t.map(i=>C.default.dirname(i).split(C.default.sep)),s=r[0];for(let i of r.slice(1)){let a=0;for(;a<s.length&&a<i.length&&s[a]===i[a];)a++;s=s.slice(0,a)}let n=s.join(C.default.sep)||C.default.sep,o=C.default.relative(e,n);return o.startsWith("..")||C.default.isAbsolute(o)?e:n}var ve=class{constructor(e,r=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=s||new j(e),this.lockFile=as(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(s=>C.default.isAbsolute(s)?s:C.default.resolve(this.rootDir,s));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=ns(this.rootDir));try{for(let s of r)this.enqueue(s);return await this.drain(),await this.processTestFiles(Za(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
24
24
  Done. Total processed: ${this.visited.size} nodes.
25
- `),Bs(this.graph.nodes),Ws(this.graph.nodes),$s(this.graph.nodes),zs(this.graph.nodes),this.coverageMap.size>0&&Os(this.graph.nodes,this.coverageMap),new T(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??$a;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=w.default.join(__dirname,"parse-worker.js");this.pool=new Xs.default({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
25
+ `),Hs(this.graph.nodes),Us(this.graph.nodes),Js(this.graph.nodes),Ks(this.graph.nodes),this.coverageMap.size>0&&$s(this.graph.nodes,this.coverageMap),new P(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??Ya;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let s=C.default.join(__dirname,"parse-worker.js");this.pool=new tn.default({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
26
26
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${s}
27
- `),this.pool=null}}hasAtLeastFiles(e,r){let s=0,n=[e];for(;n.length>0;){let o=n.pop(),i;try{i=X.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())qs.has(a.name)||n.push(w.default.join(o,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(e){let r=Z(),s=o=>r.some(i=>o.name.includes(i));this.walkProject(e,s);let n=e;for(;n!==this.rootDir;){let o=w.default.dirname(n);if(o===n)break;for(let i of za){let a=w.default.join(o,i);try{X.default.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=o}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let s;try{s=X.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=w.default.join(e,n.name);n.isDirectory()?qs.has(n.name)||this.walkProject(o,r):n.isFile()&&r(n)&&this.enqueue(o)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=X.default.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=w.default.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),js(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,s,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let s=X.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,s)}catch(n){return process.stderr.write(`
27
+ `),this.pool=null}}hasAtLeastFiles(e,r){let s=0,n=[e];for(;n.length>0;){let o=n.pop(),i;try{i=Y.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())en.has(a.name)||n.push(C.default.join(o,a.name));else if(a.isFile()&&(s++,s>=r))return!0}return s>=r}async processTestFiles(e){let r=ee(),s=o=>r.some(i=>o.name.includes(i));this.walkProject(e,s);let n=e;for(;n!==this.rootDir;){let o=C.default.dirname(n);if(o===n)break;for(let i of Xa){let a=C.default.join(o,i);try{Y.default.statSync(a).isDirectory()&&this.walkProject(a,s)}catch{}}n=o}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let s;try{s=Y.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=C.default.join(e,n.name);n.isDirectory()?en.has(n.name)||this.walkProject(o,r):n.isFile()&&r(n)&&this.enqueue(o)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=Y.default.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let s=C.default.relative(this.rootDir,e),n=await this.getNode(e,s,r);n.imports=await this.resolveImports(e,n.imports),Bs(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,r,s){let n=this.previousGraph?.nodes.get(r);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,r);if(!o)return this.makeStubNode(e,r,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,r,s,o,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let s=Y.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,s)}catch(n){return process.stderr.write(`
28
28
  Warning: failed to parse ${r}: ${n}
29
- `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):_s(e,r)}makeStubNode(e,r,s){return{path:r,type:I(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,r){let s=[];for(let n of r??[])try{let o=this.resolver.resolve(e,n.toSpecifier);o&&!o.isExternal&&s.push({from:n.from,to:n.to,toFile:w.default.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,r,s,n,o){let{imports:i,exports:a,tags:p,category:c,description:g,complexity:m,cognitiveComplexity:d,functions:S}=n;return{path:r,type:I(e),category:c,imports:i,exports:a,tags:p,mtime:s.mtimeMs,size:s.size,...g!==void 0?{description:g}:{},...o.length>0?{callEdges:o}:{},...m!==void 0?{complexity:m}:{},...d!==void 0?{cognitiveComplexity:d}:{},...S!==void 0?{functions:S}:{}}}attachGitStats(e,r){let s=this.gitStatsMap?.get(r);s&&(e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt))}async resolveImports(e,r){let s=[];for(let n of r){let o=this.resolver.resolveAll(e,n.rawSpecifier);if(o.length!==0)for(let i of o){let a={...n,toPath:i.isExternal?i.path:w.default.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),s.push(a)}}return s}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function Ys(t,e){return{identifier:e?.identifier??new $e,featureMap:e?.featureDetection===!1?new Map:N(t.nodes,e?.featureDetection??void 0)}}function Zs(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new G(o,["*",...i.exports.map(p=>p.name)]);t.traverse(o,(p,c,g)=>{if(!g)return!0;if(!a.updateAffectedSymbols(p,g))return!1;if(c>0){let m=r.get(p.path);if(m)return s(m),!1}return n(p),!0},{direction:"incoming"})}}function pr(t,e,r){let{identifier:s,featureMap:n}=Ys(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return Zs(t,e,n,i=>o.add(i.tag),i=>{if(s.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function cr(t,e,r){let{identifier:s,featureMap:n}=Ys(t,r),o=new Set;return Zs(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var en=f(require("fs")),Y=f(require("path"));async function tn(t,e,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=Y.default.resolve(t);return await new be(o,r,s.pathAliases?new L(o,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function rn(t,e={}){let r=Y.default.resolve(t),s=ae(r),n=e.packages?s.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):s.packages,o=new Map(s.packages.map(a=>[a.name,a.root])),i=new pe(r,s.type);for(let a of n){let p=e.silent?void 0:m=>{process.stderr.write(`[${a.name}] Processed ${m} files...\r`)},g=await new be(r,null,new L(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,g)}return i}function sn(t,e={}){let r=[],s=new Set([...e.ignoreDirs??ot,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??it,...e.additionalExtensions??[]]);function o(i){try{let a=en.default.readdirSync(i,{withFileTypes:!0});for(let p of a){let c=Y.default.join(i,p.name);p.isDirectory()?s.has(p.name)||o(c):p.isFile()&&n.has(Y.default.extname(p.name).toLowerCase())&&r.push(Y.default.relative(t,c))}}catch{}}return o(t),r}var nn=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var Ve=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,r){this.configs.set(e,r)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,r,s=new Map){let n=this.configs.get(e),o=await tn(e,r,this.graphs.get(e)??null,{...j(n),coverageMap:s});return this.graphs.set(e,o),o}require(e){let r=this.graphs.get(e);if(!r)throw new Error('No graph cached for this root. Call "analyze" first.');return r}async getOrBuildWorkspace(e,r={}){let s=this.workspaceGraphs.get(e);if(s)return s;let n=await rn(e,r);return this.workspaceGraphs.set(e,n),n}requireWorkspace(e){let r=this.workspaceGraphs.get(e);if(!r)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return r}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let r=this.changeImpactCaches.get(e);if(r)return r;let s=this.require(e),n=mt(s);return this.changeImpactCaches.set(e,n),n}storeLastAnalyze(e,r){this.lastAnalyze.set(e,r)}startWatching(e){if(!this.watchers.has(e))try{let r=on.default.watch(e,{recursive:!0},(s,n)=>{!n||nn.test(n)||this.dirtyRoots.add(e)});r.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,r)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.lastAnalyze.get(e);return r?.kind==="single"?this.getOrBuild(e,r.entryPoints,r.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e))return this.requireWorkspace(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e),this.workspaceGraphs.delete(e);let r=this.configs.get(e);return this.getOrBuildWorkspace(e,j(r))}invalidate(e){let r=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),r}};var O=f(require("path"));var an=f(require("fs")),pn=f(require("os")),qe=f(require("path"));function y(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function cn(t){if(!qe.default.isAbsolute(t))throw new Error("root must be an absolute path");let e=qe.default.resolve(t),r=pn.default.homedir();if(e!==r&&!e.startsWith(r+qe.default.sep))throw new Error("root must be within the user home directory");let s;try{s=an.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function ln(t,e){let{root:r,entryPoints:s}=e;if(!t.isConfigured(r)){let d=ee(r,{allowJs:!1});nt(d),t.storeConfig(r,d)}if(s.length===0){let d=ae(r);if(d.type!=="none"){let S=t.getConfig(r),E=await t.getOrBuildWorkspace(r,j(S));t.storeLastAnalyze(r,{kind:"workspace"}),t.startWatching(r);let R=Array.from(E.packages.values()).map(({graph:Ze,pkg:lr})=>({package:lr.name,relativeRoot:lr.relativeRoot,nodeCount:Ze.nodes.size}));return y({monorepoType:d.type,packageCount:E.packages.size,packages:R})}}let n=s.map(d=>O.default.resolve(r,d)),o=t.getConfig(r),i=o?.coverageReportPath?pt(r,o.coverageReportPath):new Map,a=await t.getOrBuild(r,n,i);t.storeLastAnalyze(r,{kind:"single",entryPoints:n,coverageMap:i}),t.startWatching(r);let p=a.serialize(),c=p.nodes.reduce((d,S)=>(d[S.category]=(d[S.category]??0)+1,d),{}),g=a.findCycles(),m=ht(a);return y({nodeCount:p.nodes.length,categories:c,cycles:g,languageCoverage:m})}async function un(t,e){let{root:r,file:s,depth:n=1,withMeta:o=!1}=e,i=await t.ensureFresh(r),a=yt(i,s,n),p=o?a.map(c=>({...c,...ne(i,c.path)})):a;return y({file:s,dependencies:p})}async function fn(t,e){let{root:r,file:s,withMeta:n=!1}=e,o=await t.ensureFresh(r),i=oe(o,s),a=n?i.map(p=>({...p,...ne(o,p.path)})):i;return y({file:s,dependents:a})}async function gn(t,e){let{root:r,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,p=await t.ensureFresh(r),c=d=>a?d.map(S=>({path:S,...ne(p,S)})):d;if(o){let d=t.getOrBuildChangeImpact(r),S=dt(d,s),E=n?S.filter(Ze=>p.nodes.get(Ze)?.category==="test"):S,R=c(E);return y({file:s,affected:R,count:R.length})}let g=xt(p,s,{testsOnly:n,changedSymbols:i}),m=c(g);return y({file:s,affected:m,count:m.length})}async function mn(t,e){let{root:r,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await t.ensureFresh(r),a=St(i,s,{depth:n,withEdgeDetail:o});return y({file:s,callers:a,count:a.length})}async function dn(t,e){let{root:r,entryPoints:s}=e,n=s.map(p=>O.default.resolve(r,p)),o=await t.getOrBuild(r,n),i=sn(r),a=o.findUnusedFiles(i);return y({unusedFiles:a,count:a.length})}async function hn(t,e){let{root:r,coverageThreshold:s}=e,n=await t.ensureFresh(r),o=t.getConfig(r),i=s??o?.coverageThreshold??80;if(!wt(n))return y({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...n.nodes.values()].filter(p=>p.category!=="test"&&p.category!=="config").filter(p=>p.coveragePct!==void 0&&p.coveragePct<i).map(p=>({file:p.path,coveragePct:p.coveragePct}));return y({threshold:i,uncovered:a,count:a.length})}async function yn(t,e){let{root:r}=e,n=[...(await t.ensureFresh(r)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return y({staleDocs:n,count:n.length})}async function xn(t,e){let{root:r,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,i=await t.ensureFresh(r),a=bt(i,{metric:s,threshold:n,limit:o});return y({metric:s,threshold:n,functions:a,count:a.length})}async function Sn(t,e){let{root:r,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await t.ensureFresh(r),a=s??new Ue().getChangedFiles().map(g=>O.default.relative(r,O.default.resolve(r,g))),p=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let g=cr(i,a,p);return y({changedFiles:a,affectedTests:g,count:g.length})}let c=pr(i,a,p);return y({changedFiles:a,proposedTags:c})}async function bn(t,e){let{root:r,entryPoints:s,featureThreshold:n}=e,o=s?await t.getOrBuild(r,s.map(p=>O.default.resolve(r,p))):await t.ensureFresh(r),i=N(o.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((p,c)=>c.outDegree-p.outDegree);return y({features:a,count:a.length})}async function vn(t,e){let{root:r,entryPoints:s,filter:n,mermaid:o=!1,slim:i=!0}=e,a=s?await t.getOrBuild(r,s.map(c=>O.default.resolve(r,c))):await t.ensureFresh(r),p=Re(a.serialize(),Ne(n));return o?y(Ee.serialize(T.deserialize(p))):i?y(vt(p)):y(p)}async function kn(t,e){let{root:r}=e,s=await t.ensureFreshWorkspace(r);return y(kt(s))}async function wn(t,e){let{root:r,file:s}=e,o=(await t.ensureFreshWorkspace(r)).getAffectedAcrossPackages(s);return y({file:s,affected:o,count:o.length})}function Cn(t,e){let{root:r}=e,s=t.invalidate(r);return y({root:r,cleared:s,message:s?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function Fn(t,e){let{root:r,type:s}=e,n=await t.ensureFresh(r),o=Et(n);if(s)return y(Pt(o,s));let i=Array.from(o.types.values());return y({count:i.length,types:i})}async function En(t,e){let{root:r,paths:s,minOutDegree:n}=e,o=await t.ensureFresh(r),i=Ct(o,n!==void 0?{minOutDegree:n}:void 0);if(s?.length){let p=s.map(c=>i.get(c)).filter(Boolean);return y({count:p.length,modules:p})}let a=Array.from(i.values());return y({count:a.length,modules:a})}async function Pn(t,e){let{root:r,minOutDegree:s}=e,n=await t.ensureFresh(r),o=re(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return y({features:i,unassigned:o.unassigned})}async function Tn(t,e){let{root:r,function:s}=e,n=await t.ensureFresh(r);return y(gt(n,s))}async function An(t,e){let{root:r,name:s}=e,n=await t.ensureFresh(r),o=Ft(n,s);return y({name:s,matches:o,count:o.length})}async function Mn(t,e){let{root:r,entryPoints:s}=e,n=await t.ensureFresh(r),o=s?.length?s:ut(n,r);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return y(ft(n,o))}async function In(t,e){let r=await t.ensureFresh(e.root),s=await Jt(r,e.root,{dryRun:e.dryRun??!1});return y(s)}var Rn=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo) and build per-package graphs \u2014 use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. Set testsOnly=true to get only test files. Set cached=true to use a pre-computed O(1) lookup cache instead of graph traversal \u2014 faster on repeated calls for the same root. Pass changedSymbols to restrict blast-radius to files that actually import those symbols \u2014 omit to treat the whole file as changed. Set withMeta=true to get { path, category, exports } objects instead of bare path strings.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"}}},required:["root","entryPoints"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. TypeScript/JavaScript only.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, or path. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Pass false only when full edge metadata is needed."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo, with their node counts and inter-package dependencies. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 typically 85\u201395% fewer tokens than a full graph query.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language: TypeScript/JavaScript gets function-level callers (via call edges); Python gets named-import tracking (which files import this exact symbol); everything else (Go, CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) falls back to whole-file dependents, which is import-level only \u2014 a listed importer might not even use this specific export. Files whose parser never records exports (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) never appear as matches, so a name that only exists in one of those returns an empty result, same as a typo. Each match's `precision` field is 'call' | 'import-symbol' | 'file-level' \u2014 check it before trusting caller/importer results as symbol-exact.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project. Expands export* chains so every symbol accessible to consumers is listed (not just those directly declared in the entry file). Each export is resolved to its defining file and tagged with a kind (function/class/interface/type/enum/const). The graph is partitioned into: internalFiles (implementation reachable from entry points), unreachableFromEntry (non-test files not reachable from any entry point \u2014 may be separate consumers like CLI/MCP, config, or dead code), and testFiles (test suite). Supports multiple public entry points for libraries with sub-path exports. Requires a prior analyze() call. When entryPoints is omitted, auto-detects all entry points from package.json exports/main/module.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph for a project root, forcing the next analyze() call to rebuild from disk. Call this after editing source files mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph. Tags of kind 'import' (filename-derived) and 'comment-marker' (domain semantic, propagated from source files) are written as an idempotent block. Re-running is safe: the existing block is replaced in place. Tags already present in the file are excluded from the block to avoid duplication. Supports TypeScript/JavaScript (// <mokosh-tags> block with // @tag lines) and Gherkin .feature files (# <mokosh-tags> block with @tagname lines). Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function Ye(){let t=new Ve,e=new Nn.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(Xe.ListToolsRequestSchema,async()=>({tools:Rn})),e.setRequestHandler(Xe.CallToolRequestSchema,async r=>{let{name:s,arguments:n}=r.params,o=n,a={analyze:p=>ln(t,p),get_dependencies:p=>un(t,p),get_dependents:p=>fn(t,p),get_affected:p=>gn(t,p),get_callers:p=>mn(t,p),find_symbol:p=>An(t,p),find_unused:p=>dn(t,p),find_uncovered:p=>hn(t,p),check_doc_drift:p=>yn(t,p),find_complex_functions:p=>xn(t,p),propose_tags:p=>Sn(t,p),detect_features:p=>bn(t,p),get_type_graph:p=>Fn(t,p),get_module_responsibility:p=>En(t,p),get_feature_graph:p=>Pn(t,p),get_call_graph:p=>Tn(t,p),get_api_surface:p=>Mn(t,p),query:p=>vn(t,p),get_workspace_packages:p=>kn(t,p),get_workspace_affected:p=>wn(t,p),clear_cache:p=>Cn(t,p),apply_tags:p=>In(t,p)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return cn(o.root),await a(o)}catch(p){return{content:[{type:"text",text:`Error: ${p instanceof Error?p.message:String(p)}`}],isError:!0}}}),e}async function Ua(){let t=Ye(),e=new Gn.StdioServerTransport;await t.connect(e)}Ua().catch(console.error);0&&(module.exports={createMcpServer});
29
+ `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):Ws(e,r)}makeStubNode(e,r,s){return{path:r,type:I(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,r){let s=[];for(let n of r??[])try{let o=this.resolver.resolve(e,n.toSpecifier);o&&!o.isExternal&&s.push({from:n.from,to:n.to,toFile:C.default.relative(this.rootDir,o.path)})}catch{}return s}buildNode(e,r,s,n,o){let{imports:i,exports:a,tags:p,category:c,description:m,complexity:g,cognitiveComplexity:d,functions:S}=n;return{path:r,type:I(e),category:c,imports:i,exports:a,tags:p,mtime:s.mtimeMs,size:s.size,...m!==void 0?{description:m}:{},...o.length>0?{callEdges:o}:{},...g!==void 0?{complexity:g}:{},...d!==void 0?{cognitiveComplexity:d}:{},...S!==void 0?{functions:S}:{}}}attachGitStats(e,r){let s=this.gitStatsMap?.get(r);s&&(e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt))}async resolveImports(e,r){let s=[];for(let n of r){let o=this.resolver.resolveAll(e,n.rawSpecifier);if(o.length!==0)for(let i of o){let a={...n,toPath:i.isExternal?i.path:C.default.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),s.push(a)}}return s}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=r?this.lockFile.dependencies[r]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function rn(t,e){return{identifier:e?.identifier??new Be,featureMap:e?.featureDetection===!1?new Map:G(t.nodes,e?.featureDetection??void 0)}}function sn(t,e,r,s,n){for(let o of e){let i=t.nodes.get(o);if(!i)continue;let a=new D(o,["*",...i.exports.map(p=>p.name)]);t.traverse(o,(p,c,m)=>{if(!m)return!0;if(!a.updateAffectedSymbols(p,m))return!1;if(c>0){let g=r.get(p.path);if(g)return s(g),!1}return n(p),!0},{direction:"incoming"})}}function cr(t,e,r){let{identifier:s,featureMap:n}=rn(t,r),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return sn(t,e,n,i=>o.add(i.tag),i=>{if(s.isTestNode(i))for(let a of i.tags)o.add(a.name)}),Array.from(o)}function lr(t,e,r){let{identifier:s,featureMap:n}=rn(t,r),o=new Set;return sn(t,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var nn=f(require("fs")),Z=f(require("path"));async function on(t,e,r=null,s={}){let n=s.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},o=Z.default.resolve(t);return await new ve(o,r,s.pathAliases?new j(o,{pathAliases:s.pathAliases}):void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function an(t,e={}){let r=Z.default.resolve(t),s=pe(r),n=e.packages?s.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):s.packages,o=new Map(s.packages.map(a=>[a.name,a.root])),i=new ce(r,s.type);for(let a of n){let p=e.silent?void 0:g=>{process.stderr.write(`[${a.name}] Processed ${g} files...\r`)},m=await new ve(r,null,new j(r,{workspaceMap:o,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,m)}return i}function pn(t,e={}){let r=[],s=new Set([...e.ignoreDirs??it,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??at,...e.additionalExtensions??[]]);function o(i){try{let a=nn.default.readdirSync(i,{withFileTypes:!0});for(let p of a){let c=Z.default.join(i,p.name);p.isDirectory()?s.has(p.name)||o(c):p.isFile()&&n.has(Z.default.extname(p.name).toLowerCase())&&r.push(Z.default.relative(t,c))}}catch{}}return o(t),r}var cn=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var qe=class{graphs=new Map;configs=new Map;workspaceGraphs=new Map;changeImpactCaches=new Map;dirtyRoots=new Set;watchers=new Map;lastAnalyze=new Map;isConfigured(e){return this.configs.has(e)}storeConfig(e,r){this.configs.set(e,r)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,r,s=new Map){let n=this.configs.get(e),o=await on(e,r,this.graphs.get(e)??null,{...z(n),coverageMap:s});return this.graphs.set(e,o),o}require(e){let r=this.graphs.get(e);if(!r)throw new Error('No graph cached for this root. Call "analyze" first.');return r}async getOrBuildWorkspace(e,r={}){let s=this.workspaceGraphs.get(e);if(s)return s;let n=await an(e,r);return this.workspaceGraphs.set(e,n),n}requireWorkspace(e){let r=this.workspaceGraphs.get(e);if(!r)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return r}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let r=this.changeImpactCaches.get(e);if(r)return r;let s=this.require(e),n=dt(s);return this.changeImpactCaches.set(e,n),n}storeLastAnalyze(e,r){this.lastAnalyze.set(e,r)}startWatching(e){if(!this.watchers.has(e))try{let r=ln.default.watch(e,{recursive:!0},(s,n)=>{!n||cn.test(n)||this.dirtyRoots.add(e)});r.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,r)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let r=this.lastAnalyze.get(e);return r?.kind==="single"?this.getOrBuild(e,r.entryPoints,r.coverageMap):this.require(e)}async ensureFreshWorkspace(e){if(!this.dirtyRoots.has(e))return this.requireWorkspace(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e),this.workspaceGraphs.delete(e);let r=this.configs.get(e);return this.getOrBuildWorkspace(e,z(r))}invalidate(e){let r=this.graphs.has(e)||this.workspaceGraphs.has(e);return this.graphs.delete(e),this.workspaceGraphs.delete(e),this.changeImpactCaches.delete(e),this.dirtyRoots.delete(e),r}};var W=f(require("path"));var un=f(require("fs")),fn=f(require("os")),Xe=f(require("path"));function y(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function mn(t){if(!Xe.default.isAbsolute(t))throw new Error("root must be an absolute path");let e=Xe.default.resolve(t),r=fn.default.homedir();if(e!==r&&!e.startsWith(r+Xe.default.sep))throw new Error("root must be within the user home directory");let s;try{s=un.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function gn(t,e){let{root:r,entryPoints:s}=e;if(!t.isConfigured(r)){let d=te(r,{allowJs:!1});ot(d),t.storeConfig(r,d)}if(s.length===0){let d=pe(r);if(d.type!=="none"){let S=t.getConfig(r),F=await t.getOrBuildWorkspace(r,z(S));t.storeLastAnalyze(r,{kind:"workspace"}),t.startWatching(r);let R=Array.from(F.packages.values()).map(({graph:et,pkg:ur})=>({package:ur.name,relativeRoot:ur.relativeRoot,nodeCount:et.nodes.size}));return y({monorepoType:d.type,packageCount:F.packages.size,packages:R})}}let n=s.map(d=>W.default.resolve(r,d)),o=t.getConfig(r),i=o?.coverageReportPath?ct(r,o.coverageReportPath):new Map,a=await t.getOrBuild(r,n,i);t.storeLastAnalyze(r,{kind:"single",entryPoints:n,coverageMap:i}),t.startWatching(r);let p=a.serialize(),c=p.nodes.reduce((d,S)=>(d[S.category]=(d[S.category]??0)+1,d),{}),m=a.findCycles(),g=yt(a);return y({nodeCount:p.nodes.length,categories:c,cycles:m,languageCoverage:g})}async function dn(t,e){let{root:r,file:s,depth:n=1,withMeta:o=!1}=e,i=await t.ensureFresh(r),a=xt(i,s,n),p=o?a.map(c=>({...c,...oe(i,c.path)})):a;return y({file:s,dependencies:p})}async function hn(t,e){let{root:r,file:s,withMeta:n=!1}=e,o=await t.ensureFresh(r),i=ie(o,s),a=n?i.map(p=>({...p,...oe(o,p.path)})):i;return y({file:s,dependents:a})}async function yn(t,e){let{root:r,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i,withMeta:a=!1}=e,p=await t.ensureFresh(r),c=d=>a?d.map(S=>({path:S,...oe(p,S)})):d;if(o){let d=t.getOrBuildChangeImpact(r),S=ht(d,s),F=n?S.filter(et=>p.nodes.get(et)?.category==="test"):S,R=c(F);return y({file:s,affected:R,count:R.length})}let m=St(p,s,{testsOnly:n,changedSymbols:i}),g=c(m);return y({file:s,affected:g,count:g.length})}async function xn(t,e){let{root:r,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await t.ensureFresh(r),a=bt(i,s,{depth:n,withEdgeDetail:o});return y({file:s,callers:a,count:a.length})}async function Sn(t,e){let{root:r,entryPoints:s}=e,n=s.map(p=>W.default.resolve(r,p)),o=await t.getOrBuild(r,n),i=pn(r),a=o.findUnusedFiles(i);return y({unusedFiles:a,count:a.length})}async function bn(t,e){let{root:r,coverageThreshold:s}=e,n=await t.ensureFresh(r),o=t.getConfig(r),i=s??o?.coverageThreshold??80;if(!wt(n))return y({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let a=[...n.nodes.values()].filter(p=>p.category!=="test"&&p.category!=="config").filter(p=>p.coveragePct!==void 0&&p.coveragePct<i).map(p=>({file:p.path,coveragePct:p.coveragePct}));return y({threshold:i,uncovered:a,count:a.length})}async function vn(t,e){let{root:r}=e,n=[...(await t.ensureFresh(r)).nodes.values()].filter(o=>o.type==="markdown"&&o.staleFor&&o.staleFor.length>0).map(o=>({doc:o.path,staleFor:o.staleFor}));return y({staleDocs:n,count:n.length})}async function kn(t,e){let{root:r,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,i=await t.ensureFresh(r),a=vt(i,{metric:s,threshold:n,limit:o});return y({metric:s,threshold:n,functions:a,count:a.length})}async function Cn(t,e){let{root:r,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await t.ensureFresh(r),a=s??new Ke().getChangedFiles().map(m=>W.default.relative(r,W.default.resolve(r,m))),p=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let m=lr(i,a,p);return y({changedFiles:a,affectedTests:m,count:m.length})}let c=cr(i,a,p);return y({changedFiles:a,proposedTags:c})}async function wn(t,e){let{root:r,entryPoints:s,featureThreshold:n}=e,o=s?await t.getOrBuild(r,s.map(p=>W.default.resolve(r,p))):await t.ensureFresh(r),i=G(o.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((p,c)=>c.outDegree-p.outDegree);return y({features:a,count:a.length})}async function En(t,e){let{root:r,entryPoints:s,filter:n,mermaid:o=!1,slim:i=!0}=e,a=s?await t.getOrBuild(r,s.map(c=>W.default.resolve(r,c))):await t.ensureFresh(r),p=Re(a.serialize(),Ge(n));return o?y(Te.serialize(P.deserialize(p))):i?y(kt(p)):y(p)}async function Fn(t,e){let{root:r}=e,s=await t.ensureFreshWorkspace(r);return y(Ct(s))}async function Tn(t,e){let{root:r,file:s}=e,o=(await t.ensureFreshWorkspace(r)).getAffectedAcrossPackages(s);return y({file:s,affected:o,count:o.length})}function Pn(t,e){let{root:r}=e,s=t.invalidate(r);return y({root:r,cleared:s,message:s?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function An(t,e){let{root:r,type:s}=e,n=await t.ensureFresh(r),o=Tt(n);if(s)return y(Pt(o,s));let i=Array.from(o.types.values());return y({count:i.length,types:i})}async function Mn(t,e){let{root:r,paths:s,minOutDegree:n}=e,o=await t.ensureFresh(r),i=Et(o,n!==void 0?{minOutDegree:n}:void 0);if(s?.length){let p=s.map(c=>i.get(c)).filter(Boolean);return y({count:p.length,modules:p})}let a=Array.from(i.values());return y({count:a.length,modules:a})}async function In(t,e){let{root:r,minOutDegree:s}=e,n=await t.ensureFresh(r),o=se(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return y({features:i,unassigned:o.unassigned})}async function Nn(t,e){let{root:r,function:s}=e,n=await t.ensureFresh(r);return y(gt(n,s))}async function Rn(t,e){let{root:r,name:s}=e,n=await t.ensureFresh(r),o=Ft(n,s);return y({name:s,matches:o,count:o.length})}async function Gn(t,e){let{root:r,entryPoints:s}=e,n=await t.ensureFresh(r),o=s?.length?s:ft(n,r);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return y(mt(n,o))}async function Dn(t,e){let r=await t.ensureFresh(e.root),s=await Ht(r,e.root,{dryRun:e.dryRun??!1});return y(s)}var _n=[{name:"analyze",description:"Build the dependency graph for a project from entry points. Returns a summary of node count, categories, and cycles. Must be called before get_dependencies, get_dependents, get_affected, or propose_tags. Pass an empty entryPoints array to auto-detect a monorepo (pnpm/npm/yarn/Nx/Turborepo) and build per-package graphs \u2014 use get_workspace_packages and get_workspace_affected for monorepo queries.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root (or monorepo root)"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root (e.g. ['src/index.ts']). Pass [] to trigger monorepo auto-detection."}},required:["root","entryPoints"]}},{name:"get_dependencies",description:"Get files that a given file imports (outgoing traversal). depth=1 returns immediate imports; omit for the full transitive tree. Each result includes the specific symbols imported from that file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_dependents",description:"Get files that directly import a given file (one-hop incoming edges). Each result includes the specific symbols that dependent file imports from this file (when known).",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},withMeta:{type:"boolean",description:"Include each result's category and export names alongside the path (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_affected",description:"Get all files transitively affected if a given file changes \u2014 full incoming traversal upward. Use before a refactor to understand blast radius. Set testsOnly=true to get only test files. Set cached=true to use a pre-computed O(1) lookup cache instead of graph traversal \u2014 faster on repeated calls for the same root. Pass changedSymbols to restrict blast-radius to files that actually import those symbols \u2014 omit to treat the whole file as changed. Set withMeta=true to get { path, category, exports } objects instead of bare path strings.",inputSchema:{type:"object",properties:{root:{type:"string"},file:{type:"string",description:"File path relative to root"},testsOnly:{type:"boolean",description:"Return only test/spec files (default: false)"},cached:{type:"boolean",description:"Use a pre-computed impact cache for O(1) lookup instead of graph traversal. Cache is built lazily on first use and reused for the session (default: false)."},changedSymbols:{type:"array",items:{type:"string"},description:"Restrict blast-radius to files that import at least one of these symbols. Omit to treat the whole file as changed (conservative, same as before)."},withMeta:{type:"boolean",description:"Return each affected file as { path, category, exports } instead of a bare path string (default: false). Set true when you need to decide what to do with a result without a follow-up lookup."}},required:["root","file"]}},{name:"get_callers",description:"Get files whose exported functions call into a given file (call-graph dependents). More precise than get_affected: only files with actual runtime call edges, not mere imports. Requires prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to project root"},file:{type:"string",description:"File path relative to root"},depth:{type:"number",description:"Max traversal depth (default: 1)"},withEdgeDetail:{type:"boolean",description:"Include from/to function names per edge (default: false)"}},required:["root","file"]}},{name:"find_unused",description:"Find files in the project that are not reachable from any entry point. Useful before cleanup passes.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"}}},required:["root","entryPoints"]}},{name:"find_uncovered",description:"Find non-test files whose line coverage is below the configured threshold. Requires a prior analyze() call and coverageReportPath set in mokosh.config. coverageThreshold overrides the config default (default: 80).",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},coverageThreshold:{type:"number",description:"Line-coverage % below which a file is considered uncovered. Overrides config value."}},required:["root"]}},{name:"check_doc_drift",description:"Find markdown docs whose referenced files changed more recently than the doc itself \u2014 a commit-recency heuristic for stale documentation, not a content diff. Requires a prior analyze() call with gitStats: true in mokosh.config (otherwise no file has commit-timestamp data and nothing is flagged). See docs/adr-009-markdown-parsing.md for known limitations.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"}},required:["root"]}},{name:"find_complex_functions",description:"Find individual functions/methods above a cognitive (or cyclomatic) complexity threshold, sorted worst-first. Requires a prior analyze() call. TypeScript/JavaScript only.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},metric:{type:"string",enum:["cognitiveComplexity","complexity"],description:"Which score to threshold/sort on (default: cognitiveComplexity)"},threshold:{type:"number",description:"Minimum score to include (default: 10)"},limit:{type:"number",description:"Max results to return, worst-first (default: 20)"}},required:["root"]}},{name:"propose_tags",description:"Propose what to run based on changed files. Pass changedFiles explicitly or omit to use git diff. format='tags' (default) returns test tags for CI tag-filtering; format='paths' returns test file paths ready to pipe directly to a test runner (e.g. vitest). Feature hubs act as traversal boundaries in both modes.",inputSchema:{type:"object",properties:{root:{type:"string"},changedFiles:{type:"array",items:{type:"string"},description:"Changed files relative to root. Omit to read from git diff."},featureThreshold:{type:"number",description:"Min importers for a file to be treated as a feature hub (default: 5). A hub short-circuits traversal and emits a feature:<name> tag instead of all downstream tags."},format:{type:"string",enum:["tags","paths"],description:"Output format: 'tags' returns test tag names for CI filtering (default); 'paths' returns test file paths to pipe to a test runner."}},required:["root"]}},{name:"detect_features",description:"Identify feature hub files \u2014 non-test files that import many other internal modules (orchestrators / aggregators like src/parser.ts or src/cli/runner.ts). Returns a list sorted by import count descending.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry point files relative to root. Omit to use the cached graph."},featureThreshold:{type:"number",description:"Min internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"query",description:"Filter the graph by category, tag, or path. Returns matching nodes as JSON or a Mermaid diagram. If entryPoints is omitted the cached graph from a prior 'analyze' call is used.",inputSchema:{type:"object",properties:{root:{type:"string"},entryPoints:{type:"array",items:{type:"string"},description:"Entry points to build the graph. Omit to reuse the cached graph from a prior 'analyze' call."},filter:{type:"string",description:"Query string e.g. 'category:logic' or 'category:logic,tag:auth'. Supports: category, type, tag, path, external, importsFile, importedBy, minImports, maxImports, minSize, maxSize, hasDocstring, minCoverage, maxCoverage, minExportUsage, maxExportUsage, minComplexity, maxComplexity, minCognitiveComplexity, maxCognitiveComplexity, minCommits, maxCommits, isDocumented, isStale, lastAuthor. OR logic: any(key:val|key:val) matches if any single-key clause holds, ANDed with the rest of the query. sort: size|imports|commitCount90d|exportUsage|complexity|cognitiveComplexity, with sortDir: asc|desc (default desc). limit: N."},mermaid:{type:"boolean",description:"Return a Mermaid diagram (default: false)"},slim:{type:"boolean",description:"Compact response mode (default: true). Returns export names, meaningful tags, and a flat importsFiles path list \u2014 no edge objects, no mtime/size. Pass false only when full edge metadata is needed."}},required:["root","filter"]}},{name:"get_workspace_packages",description:"List all workspace packages detected in a monorepo, with their node counts and inter-package dependencies. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"}},required:["root"]}},{name:"get_workspace_affected",description:"Cross-package blast-radius analysis. Returns every file that could be affected if a given file changes, annotated with the package it belongs to. Requires a prior analyze() call with empty entryPoints on a monorepo root.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the monorepo root"},file:{type:"string",description:"Monorepo-root-relative path of the changed file (e.g. 'packages/shared/src/utils.ts')"}},required:["root","file"]}},{name:"get_type_graph",description:"Return type-level relationships for the project. Without a type name, returns an inventory of all interfaces, classes, enums, and type aliases with their file and kind. With a type name, returns which files import that type (usedByFiles) and which types the defining file imports (uses). Requires a prior analyze() call. Only covers TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},type:{type:"string",description:"Exact exported name of the type to look up (e.g. 'FileNode'). Omit to get the full type inventory."}},required:["root"]}},{name:"get_module_responsibility",description:"Return what each file is responsible for: its semantic role, JSDoc description (when present), exported symbol names, and which feature hub it belongs to. Pass specific paths to filter, or omit paths to get all files. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},paths:{type:"array",items:{type:"string"},description:"Project-relative file paths to include. Omit to return all files."},minOutDegree:{type:"number",description:"Min imports for a file to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_feature_graph",description:"Group files by domain: returns which files each feature hub (high-import orchestrator) transitively owns. Each file is assigned to the most specific hub that can reach it (lowest out-degree wins). Use this instead of a full query when answering 'what files are in the X feature/module?' \u2014 typically 85\u201395% fewer tokens than a full graph query.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},minOutDegree:{type:"number",description:"Minimum internal imports a file must have to qualify as a feature hub (default: 5)."}},required:["root"]}},{name:"get_call_graph",description:"Look up callers and callees for a named function. Returns the file that defines the function, all files/functions that call it, and all files/functions it calls. Always requires a function name \u2014 never returns the full call graph unfiltered. Call edges are only populated for TypeScript/JavaScript files.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},function:{type:"string",description:"Exact name of the function to look up (e.g. 'parseFile')."}},required:["root","function"]}},{name:"find_symbol",description:"Find every file that exports a symbol by exact name, with the best available usage info per match. Precision varies by the defining file's language: TypeScript/JavaScript gets function-level callers (via call edges); Python gets named-import tracking (which files import this exact symbol); everything else (Go, CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) falls back to whole-file dependents, which is import-level only \u2014 a listed importer might not even use this specific export. Files whose parser never records exports (CoffeeScript, LiveScript, Lua, Gherkin, Markdown, CSS/SCSS/Stylus) never appear as matches, so a name that only exists in one of those returns an empty result, same as a typo. Each match's `precision` field is 'call' | 'import-symbol' | 'file-level' \u2014 check it before trusting caller/importer results as symbol-exact.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},name:{type:"string",description:"Exact export name to look up (e.g. 'parseFile')."}},required:["root","name"]}},{name:"get_api_surface",description:"Build the API surface report for a project. Expands export* chains so every symbol accessible to consumers is listed (not just those directly declared in the entry file). Each export is resolved to its defining file and tagged with a kind (function/class/interface/type/enum/const). The graph is partitioned into: internalFiles (implementation reachable from entry points), unreachableFromEntry (non-test files not reachable from any entry point \u2014 may be separate consumers like CLI/MCP, config, or dead code), and testFiles (test suite). Supports multiple public entry points for libraries with sub-path exports. Requires a prior analyze() call. When entryPoints is omitted, auto-detects all entry points from package.json exports/main/module.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root"},entryPoints:{type:"array",items:{type:"string"},description:"Project-relative paths of public entry points (e.g. ['src/index.ts', 'src/utils.ts']). Omit to auto-detect from package.json exports / main / module fields."}},required:["root"]}},{name:"clear_cache",description:"Drop the cached dependency graph for a project root, forcing the next analyze() call to rebuild from disk. Call this after editing source files mid-session \u2014 otherwise get_affected, get_dependencies, and other query tools will reason from stale data.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root to invalidate."}},required:["root"]}},{name:"apply_tags",description:"Write @tag annotations into test file source code based on the dependency graph. Tags of kind 'import' (filename-derived) and 'comment-marker' (domain semantic, propagated from source files) are written as an idempotent block. Re-running is safe: the existing block is replaced in place. Tags already present in the file are excluded from the block to avoid duplication. Supports TypeScript/JavaScript (// <mokosh-tags> block with // @tag lines) and Gherkin .feature files (# <mokosh-tags> block with @tagname lines). Use dryRun=true to preview changes without writing to disk. Requires a prior analyze() call.",inputSchema:{type:"object",properties:{root:{type:"string",description:"Absolute path to the project root."},dryRun:{type:"boolean",description:"When true, computes which files would change but does not write to disk (default: false)."}},required:["root"]}}];function Ze(){let t=new qe,e=new Ln.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(Ye.ListToolsRequestSchema,async()=>({tools:_n})),e.setRequestHandler(Ye.CallToolRequestSchema,async r=>{let{name:s,arguments:n}=r.params,o=n,a={analyze:p=>gn(t,p),get_dependencies:p=>dn(t,p),get_dependents:p=>hn(t,p),get_affected:p=>yn(t,p),get_callers:p=>xn(t,p),find_symbol:p=>Rn(t,p),find_unused:p=>Sn(t,p),find_uncovered:p=>bn(t,p),check_doc_drift:p=>vn(t,p),find_complex_functions:p=>kn(t,p),propose_tags:p=>Cn(t,p),detect_features:p=>wn(t,p),get_type_graph:p=>An(t,p),get_module_responsibility:p=>Mn(t,p),get_feature_graph:p=>In(t,p),get_call_graph:p=>Nn(t,p),get_api_surface:p=>Gn(t,p),query:p=>En(t,p),get_workspace_packages:p=>Fn(t,p),get_workspace_affected:p=>Tn(t,p),clear_cache:p=>Pn(t,p),apply_tags:p=>Dn(t,p)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return mn(o.root),await a(o)}catch(p){return{content:[{type:"text",text:`Error: ${p instanceof Error?p.message:String(p)}`}],isError:!0}}}),e}async function ep(){let t=Ze(),e=new On.StdioServerTransport;await t.connect(e)}ep().catch(console.error);0&&(module.exports={createMcpServer});
30
30
  //# sourceMappingURL=mcp.js.map