@omfalos/mokosh 0.1.5 → 0.1.6

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,28 +1,30 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var mn=Object.create;var he=Object.defineProperty;var dn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,xn=Object.prototype.hasOwnProperty;var Sn=(r,e)=>{for(var t in e)he(r,t,{get:e[t],enumerable:!0})},rr=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of hn(e))!xn.call(r,n)&&n!==t&&he(r,n,{get:()=>e[n],enumerable:!(s=dn(e,n))||s.enumerable});return r};var f=(r,e,t)=>(t=r!=null?mn(yn(r)):{},rr(e||!r||!r.__esModule?he(t,"default",{value:r,enumerable:!0}):t,r)),bn=r=>rr(he({},"__esModule",{value:!0}),r);var oa={};Sn(oa,{createMcpServer:()=>Ue});module.exports=bn(oa);var gn=require("@modelcontextprotocol/sdk/server/stdio.js");var fn=require("@modelcontextprotocol/sdk/server/index.js"),Be=require("@modelcontextprotocol/sdk/types.js");var Ws=f(require("fs"));var be=f(require("fs")),He=f(require("path"));var vn=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],sr=[];function ye(r){sr.push(r)}function nr(r){return[...vn,...sr].some(e=>typeof e=="string"?r.includes(e):e instanceof RegExp?e.test(r):e(r))}var kn=[".test.",".spec.","-test.","-spec."],or=[];function xe(r){or.push(r)}function V(){return[...kn,...or]}var wn=["jest","vitest","playwright","cypress","@testing-library/"],ir=[];function Se(r){ir.push(r)}function qe(){return[...wn,...ir]}var ar=.8;function Ke(r){ar=r}function Je(){return ar}var Cn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function X(r,{allowJs:e=!0,isExplicitPath:t=!1}={}){if(t){let s=He.default.resolve(r);return be.default.existsSync(s)?s.endsWith(".json")?pr(s):e?cr(s):{}:{}}for(let s of Cn){let n=He.default.resolve(r,s);if(be.default.existsSync(n)){if(s.endsWith(".json"))return pr(n);if(e)return cr(n)}}return{}}function pr(r){return JSON.parse(be.default.readFileSync(r,"utf-8"))}function cr(r){let e=require(r);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function Qe(r){for(let e of r.configMatchers??[])ye(e);for(let e of r.testPatterns??[])xe(e);for(let e of r.testLibraries??[])Se(e);r.barrelThreshold!==void 0&&Ke(r.barrelThreshold)}var Ve=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Xe=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature"];var lr=f(require("fs")),Ze=f(require("path"));function Ye(r,e){let t=Ze.default.resolve(r,e);try{let s=lr.default.readFileSync(t,"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=Ze.default.relative(r,i);o.set(c,p)}return o}catch{return new Map}}var ve={serialize(r){let e=["graph TD"],t=new Set;for(let s of r.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(!t.has(a)){let p=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${p} ${i}`),t.add(a)}}}return e.join(`
3
- `)}};var et=f(require("fs")),ur=f(require("path"));function tt(r,e){let t=r.replace(/^\.\//,"");if(e.nodes.has(t))return t;let s=t.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function fr(r,e){if(typeof r=="string")return tt(r,e);if(r&&typeof r=="object"){let t=r;for(let s of["import","require","default"]){let n=fr(t[s],e);if(n)return n}}return null}function En(r){if(!r)return"unknown";let e=r.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 Tn(r,e){let t=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=r.nodes.get(o);if(i){for(let a of i.exports)t.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=r.nodes.get(a.toPath);if(c)for(let m of c.exports)t.add(m.name);n.push(a.toPath)}else for(let c of a.symbols)t.add(c)}}}return t}function rt(r,e){let t=[],s=ur.default.join(e,"package.json");if(et.default.existsSync(s))try{let n=JSON.parse(et.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=fr(o,r);i&&!t.includes(i)&&t.push(i)}else if(typeof n.exports=="string"){let o=tt(n.exports,r);o&&t.push(o)}if(t.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=tt(o,r);i&&!t.includes(i)&&t.push(i)}}catch{}if(t.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(r.nodes.has(n)){t.push(n);break}}return t}function Pn(r,e){let t=new Set(e);for(let s of e)r.traverse(s,n=>(t.add(n.path),!0),{direction:"outgoing"});return t}function An(r,e,t){let s=new Map;for(let n of e){if(t.includes(n))continue;let o=r.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 In(r,e,t,s){let n=[];for(let o of r){let i=e.get(o),a=s.flatMap(g=>t.nodes.get(g)?.exports??[]).find(g=>g.name===o),p=i?.symbol??a,c=i?.file??s.find(g=>t.nodes.get(g)?.exports.some(h=>h.name===o))??s[0],m={name:o,definedIn:c,kind:En(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 Mn(r,e,t){let s=p=>r.nodes.get(p)?.category==="test",n=[...e].filter(p=>!t.includes(p)&&!s(p)),o=[...r.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 st(r,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let c of e)if(!r.nodes.has(c))throw new Error(`Entry point not found in graph: ${c}`);let t=Pn(r,e),s=An(r,t,e),n=Tn(r,e),o=In(n,s,r,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=Mn(r,t,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}function nt(r,e){let t=null,s=[];for(let o of r.nodes.values()){o.exports.some(i=>i.name===e)&&(t=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(t){let o=r.nodes.get(t);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:t,callers:s,callees:n}}var Rn=f(require("fs")),Nn=f(require("path"));function gr(r){let e=[...r.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),t=2166136261;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function ot(r){let e=new Map;for(let t of r.nodes.keys()){let s=[];r.traverse(t,n=>(n.path!==t&&s.push(n.path),!0),{direction:"incoming"}),e.set(t,s)}return{impact:e,graphHash:gr(r)}}function it(r,e){return r.impact.get(e)??[]}var Z=f(require("path"));function Gn(r){let e=new Map;for(let[t,s]of r){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(t,n)}return e}function Dn(r,e,t){let s=new Map;for(let[n,o]of e){if(o<t)continue;let i=r.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Z.default.extname(n),p=Z.default.basename(n,a),c=p==="index"?Z.default.basename(Z.default.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${c}`})}return s}function R(r,e){let t=e?.minOutDegree??5;return Dn(r,Gn(r),t)}var _n=(r,e)=>r.outDegree-e.outDegree;function jn(r,e){let t=new Map;for(let s of e.values()){let n=new Set;r.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),t.set(s.path,n)}return t}function Ln(r,e,t,s){let n=new Map;for(let[o]of r){if(e.has(o))continue;let i=null;for(let a of e.values())t.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function On(r,e){let t=new Map;for(let s of r.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);t.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return t}function Wn(r,e,t){let s=[];for(let n of r.keys())!e.has(n)&&!t.has(n)&&s.push(n);return s}function Y(r,e){let t=e?.detectFn??R,s=e?.hubComparator??_n,n=t(r.nodes,e),o=jn(r,n),i=Ln(r.nodes,n,o,s);return{features:On(n,i),unassigned:Wn(r.nodes,n,i)}}var ee=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let t=new Set(this.nodes.keys());return e.filter(s=>!t.has(s))}findHighExportUsage(e){let t=[];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);t.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return t.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],t=new Set,s=new Set,n=[],o=i=>{t.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 t.has(p.toPath)||o(p.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())t.has(i)||o(i);return e}};var T=class r{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let t=new Map;for(let s of e.nodes)t.set(s.path,s);return new r(t)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let t of this.nodes.values())for(let s of t.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(t.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,t,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),t(g,c,m)!==!1))for(let h of n(p))a(h,c+1,p)};a(e,0,null)}traverse(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,t,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 t of this.nodes.values())for(let s of t.callEdges??[]){let n=e.get(s.toFile)??[];n.push(t.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,t,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let t=[];return this.traverseCalls(e,s=>(s.path!==e&&t.push(s.path),!0),{direction:"incoming",maxDepth:1}),t}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let t=this.nodes.get(e);return t?t.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new ee(this.nodes).findUnusedFiles(e)}findCycles(){return new ee(this.nodes).findCycles()}};var N=class{affectedSymbols=new Map;constructor(e,t){this.affectedSymbols.set(e,new Set(["default",...t]))}updateAffectedSymbols(e,t){let s=this.affectedSymbols.get(t)||new Set,n=e.imports.find(p=>p.toPath===t);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 at(r,e,t=1){let s=[];return r.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?r.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:t}),s}function pt(r,e){let t=[];return r.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return t.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),t}function ct(r,e,t={}){let{testsOnly:s=!1,changedSymbols:n}=t,o=n?new N(e,n):null,i=[];return r.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 lt(r,e,t={}){let{depth:s=1,withEdgeDetail:n=!1}=t,o=[];return r.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 ut(r,e={}){let{metric:t="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...r.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[t]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[t]-o[t]).slice(0,n)}function ft(r){return{nodes:r.nodes.map(t=>({path:t.path,type:t.type,category:t.category,exports:t.exports.map(s=>s.name),tags:t.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:t.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...t.description!==void 0&&{description:t.description},...t.testedBy!==void 0&&{testedBy:t.testedBy},...t.coveragePct!==void 0&&{coveragePct:t.coveragePct},...t.avgExportUsage!==void 0&&{avgExportUsage:t.avgExportUsage},...t.maxExportUsage!==void 0&&{maxExportUsage:t.maxExportUsage}})),cycles:r.cycles}}function gt(r){let e=r.getPackageDependencies(),t=Array.from(r.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:r.type,packageCount:t.length,packages:t}}function mt(r){return[...r.nodes.values()].some(e=>e.coveragePct!==void 0)}function mr(r){if(r.category==="test")return"test";if(r.category==="config")return"config";if(r.category==="type-only")return"types";let e=r.path;return y(e,"component")||y(e,"components")?"component":y(e,"controller")||y(e,"controllers")?"controller":y(e,"middleware")?"middleware":y(e,"router")||y(e,"routes")||y(e,"route")?"router":y(e,"store")||y(e,"stores")?"store":y(e,"service")||y(e,"services")?"service":y(e,"handler")||y(e,"handlers")?"handler":y(e,"adapter")||y(e,"adapters")?"adapter":y(e,"plugin")||y(e,"plugins")?"plugin":y(e,"api")?"api":y(e,"cli")||y(e,"commands")||te(e)==="cli"?"cli":y(e,"util")||y(e,"utils")||y(e,"helper")||y(e,"helpers")?"util":y(e,"model")||y(e,"models")||te(e)==="model"?"model":y(e,"parser")||y(e,"parsers")||te(e)==="parser"?"parser":te(e)==="builder"?"builder":te(e)==="resolver"?"resolver":"other"}function y(r,e){return r.includes(`/${e}/`)||r.includes(`/${e}.`)}function te(r){let e=r.slice(r.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function dt(r,e){let t=Y(r,e),s=new Map;for(let[o,i]of t.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of r.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:mr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}function zn(r){return r?r.startsWith("interface ")?"interface":r.startsWith("class ")?"class":r.startsWith("enum ")?"enum":"type":"type"}function $n(r,e){if(e==="type-only")return!0;let t=r.signature??"";return t.startsWith("interface ")||t.startsWith("class ")||t.startsWith("enum ")}function ht(r){let e=new Map;for(let s of r.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!$n(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:zn(n.signature),...n.doc?{doc:n.doc}:{}})}let t=[];for(let s of r.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}`)&&t.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:t}}function yt(r,e){let t=null;for(let o of r.types.values())if(o.name===e){t=o;break}if(!t)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of r.edges)if(o.toType===e&&o.toFile===t.file&&s.add(o.fromFile),o.fromFile===t.file){let i=r.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:t,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var Ar=f(require("path"));var we=f(require("fs")),bt=f(require("path"));var j=f(require("fs")),C=f(require("path"));var xt=f(require("fs")),Bn=f(require("path"));function dr(r){try{return xt.default.statSync(r,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function ke(r){try{return xt.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function St(r,e){let t=C.default.join(e,"package.json");if(!j.default.existsSync(t))return null;let s={};try{s=JSON.parse(j.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:C.default.relative(r,e),entryPoints:Un(e,s)}:null}function Un(r,e){let t=[];if(e.exports){let n=e.exports;if(typeof n=="string")t.push(C.default.join(r,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")t.push(C.default.join(r,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&t.push(C.default.join(r,i))}}}e.main&&t.push(C.default.join(r,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])t.push(C.default.join(r,n));let s=t.filter(ke);return s.length>0?s.slice(0,1):t.slice(0,1)}function L(r,e){let t=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");qn(r,o,s,t)}return t}function qn(r,e,t,s){if(!e.includes("*")){Kn(r,e,t,s);return}let n=e.split("/");n.includes("**")?Jn(r,n,t,s):Hn(r,n,t,s)}function Kn(r,e,t,s){let n=C.default.join(r,e);if(t.has(n)||!dr(n))return;t.add(n);let o=St(r,n);o&&s.push(o)}function Jn(r,e,t,s){let n=C.default.join(r,e[0]==="**"?"":e[0]??"");hr(r,n,t,s)}function Hn(r,e,t,s){let n=e.findIndex(a=>a.includes("*")),o=C.default.join(r,...e.slice(0,n)),i;try{i=j.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(t.has(p))continue;t.add(p);let c=St(r,p);c&&s.push(c)}}function hr(r,e,t,s){let n;try{n=j.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(j.default.existsSync(C.default.join(i,"package.json"))&&!t.has(i)){t.add(i);let a=St(r,i);a&&s.push(a)}else hr(r,i,t,s)}}var yr={type:"npm",detect(r){let e=bt.default.join(r,"package.json");if(!we.default.existsSync(e))return null;let t;try{t=JSON.parse(we.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t||we.default.existsSync(bt.default.join(r,"yarn.lock")))return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:L(r,s)}};var G=f(require("fs")),v=f(require("path"));var xr={type:"nx",detect(r){return G.default.existsSync(v.default.join(r,"nx.json"))?Sr(r,r,new Set,0).map(t=>Qn(r,t,v.default.join(t,"project.json"))).filter(t=>t!==null):null}};function Sr(r,e,t,s){if(s>4)return[];let n;try{n=G.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);G.default.existsSync(v.default.join(p,"project.json"))&&!t.has(p)?(t.add(p),o.push(p)):o.push(...Sr(r,p,t,s+1))}return o}function Qn(r,e,t){let s={};try{s=JSON.parse(G.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name,o,i,a=v.default.join(e,"package.json");if(G.default.existsSync(a))try{let p=JSON.parse(G.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(r,e),entryPoints:Vn(e,s,o,i)}:null}function Vn(r,e,t,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=v.default.resolve(r,"../..");n.push(v.default.resolve(a,o)),n.push(v.default.resolve(r,o))}if(s){let a=s;if(typeof a=="string")n.push(v.default.join(r,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(v.default.join(r,p))}}if(t&&n.push(v.default.join(r,t)),e.sourceRoot){let a=v.default.resolve(r,"../.."),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(r,a));let i=n.filter(ke);return i.length>0?i.slice(0,1):n.slice(0,1)}var vt=f(require("fs")),br=f(require("path")),vr=f(require("js-yaml"));var kr={type:"pnpm",detect(r){let e=br.default.join(r,"pnpm-workspace.yaml");if(!vt.default.existsSync(e))return null;let t=[];try{t=vr.default.load(vt.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return L(r,t)}};var wr=f(require("fs")),Cr=f(require("path")),Fr={type:"turborepo",detect(r){return wr.default.existsSync(Cr.default.join(r,"turbo.json"))?[]:null}};var Ce=f(require("fs")),kt=f(require("path"));var Er={type:"yarn",detect(r){if(!Ce.default.existsSync(kt.default.join(r,"yarn.lock")))return null;let e=kt.default.join(r,"package.json");if(!Ce.default.existsSync(e))return null;let t;try{t=JSON.parse(Ce.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t)return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:L(r,s)}};var Tr=[];function A(r){Tr.push(r)}function Pr(){return Tr}A(Fr);A(xr);A(kr);A(Er);A(yr);function re(r,e=Pr()){let t=Ar.default.resolve(r),s=new Map,n=[];for(let i of e){let a=i.detect(t);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:t,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:t,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var se=class r{constructor(e,t){this.monorepoRoot=e;this.type=t}monorepoRoot;type;packages=new Map;addPackage(e,t){this.packages.set(e.name,{graph:t,pkg:e})}getPackageForFile(e){for(let{pkg:t}of this.packages.values())if(e===t.relativeRoot||e.startsWith(`${t.relativeRoot}/`))return t}getPackageDependencies(){let e=new Map;for(let{graph:t,pkg:s}of this.packages.values()){let n=new Set;for(let o of t.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 t=this.getPackageForFile(e);if(!t)return[];let s=this.packages.get(t.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:t.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==t.name)for(let a of o.nodes.values())a.imports.some(c=>c.isWorkspace&&c.workspacePackage===t.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:t})=>({pkg:{name:t.name,relativeRoot:t.relativeRoot,entryPoints:t.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let t=new r(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);t.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return t}};var Ir=new Map;function O(r,e){Ir.set(r,e)}function Mr(r){return Ir.get(r)}function Rr(r,e){return e.startsWith("!")?r!==e.slice(1):r===e}function Xn(r,e){return e.startsWith("!")?!r.includes(e.slice(1)):r.includes(e)}var Zn=(r,e)=>!e.category||Rr(r.category,e.category),Yn=(r,e)=>!e.type||Rr(r.type,e.type),eo=(r,e)=>!e.path||Xn(r.path,e.path),to=(r,e)=>e.isExternal===void 0?!0:r.imports.some(s=>s.isExternal)===e.isExternal,ro=(r,e)=>{if(!e.tags||e.tags.length===0)return!0;let t=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(t.length>0&&!t.some(n=>r.tags.some(o=>o.name===n))||s.some(n=>r.tags.some(o=>o.name===n)))},so=(r,e)=>!e.allTags?.length||e.allTags.every(t=>r.tags.some(s=>s.name===t)),no=(r,e)=>!e.importsFile||r.imports.some(t=>t.toPath?.includes(e.importsFile)),oo=(r,e,t)=>e.importedBy===void 0?!0:(t?.get(r.path)??[]).some(n=>n.includes(e.importedBy)),io=(r,e)=>e.minImports===void 0||r.imports.length>=e.minImports,ao=(r,e)=>e.maxImports===void 0||r.imports.length<=e.maxImports,po=(r,e)=>e.minSize===void 0||r.size>=e.minSize,co=(r,e)=>e.maxSize===void 0||r.size<=e.maxSize,lo=(r,e)=>e.hasDocstring===void 0||!!r.description===e.hasDocstring,uo=(r,e)=>e.minCoverage===void 0||(r.coveragePct??101)>=e.minCoverage,fo=(r,e)=>e.maxCoverage===void 0||(r.coveragePct??0)<=e.maxCoverage,go=(r,e)=>e.minExportUsage===void 0||(r.avgExportUsage??-1)>=e.minExportUsage,mo=(r,e)=>e.maxExportUsage===void 0||(r.avgExportUsage??0)<=e.maxExportUsage,Nr=[Zn,Yn,eo,to,ro,so,no,oo,io,ao,po,co,lo,uo,fo,go,mo];function Gr(r,e,t){return Nr.every(s=>s(r,e,t))}function Fe(r,e){let t=new Map;if(e.importedBy!==void 0){for(let i of r.nodes)for(let a of i.imports)if(a.toPath){let p=t.get(a.toPath)??[];p.push(i.path),t.set(a.toPath,p)}}let s=r.nodes.filter(i=>Gr(i,e,t)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));return e.sort&&o.sort((i,a)=>e.sort==="size"?a.size-i.size:e.sort==="imports"?a.imports.length-i.imports.length:e.sort==="commitCount90d"?(a.commitCount90d??0)-(i.commitCount90d??0):e.sort==="exportUsage"?(a.avgExportUsage??0)-(i.avgExportUsage??0):0),e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:r.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}function Ee(r){let e={},t=r.split(",");for(let s of t){let n=s.indexOf(":");if(n===-1)continue;let o=s.slice(0,n).trim().toLowerCase(),i=s.slice(n+1).trim();if(!(!o||!i))switch(o){case"category":e.category=i;break;case"type":e.type=i;break;case"tag":case"tags":i.includes("+")?e.allTags=[...e.allTags??[],...i.split("+")]:e.tags=[...e.tags??[],i];break;case"path":e.path=i;break;case"external":e.isExternal=i.toLowerCase()==="true";break;case"importsfile":e.importsFile=i;break;case"importedby":e.importedBy=i;break;case"minimports":e.minImports=parseInt(i,10);break;case"maximports":e.maxImports=parseInt(i,10);break;case"minsize":e.minSize=parseInt(i,10);break;case"maxsize":e.maxSize=parseInt(i,10);break;case"sort":e.sort=i;break;case"limit":e.limit=parseInt(i,10);break;case"hasdocstring":e.hasDocstring=i.toLowerCase()!=="false";break;case"mincoverage":e.minCoverage=parseInt(i,10);break;case"maxcoverage":e.maxCoverage=parseInt(i,10);break;case"minexportusage":e.minExportUsage=parseFloat(i);break;case"maxexportusage":e.maxExportUsage=parseFloat(i);break}}return e}var Dt=f(require("fs/promises")),Ur=f(require("path"));var Ge=f(require("path")),ne=f(require("typescript"));var wt=f(require("path")),Ct=f(require("typescript"));var k=f(require("typescript")),Dr=new Set(["describe","test","it"]);function W(r){let e=[];for(let t of r.statements){if(!k.default.isExpressionStatement(t))continue;let s=t.expression;if(!k.default.isCallExpression(s))continue;let n=s.expression;k.default.isIdentifier(n)&&Dr.has(n.text)&&e.push(s),k.default.isPropertyAccessExpression(n)&&k.default.isIdentifier(n.expression)&&Dr.has(n.expression.text)&&e.push(s)}return e}function z(r,e,t){for(let s of r.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 $(r,e,t,s){if(r.arguments.length===0)return null;for(let o=1;o<r.arguments.length;o++){let i=r.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:t};let p=i.getEnd()-1;return{start:p,end:p,text:`${i.properties.length>0?", ":""}${e}: ${t}`}}let n=r.arguments[r.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${t} }, `}}function B(r,e,t){let s=r.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(t),end:o.properties[i+1].getStart(t),text:""}}return null}function U(r,e){let t=[...e].sort((n,o)=>o.start-n.start),s=r;for(let n of t)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function q(r){return`[${r.map(e=>JSON.stringify(e)).join(", ")}]`}var E=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function ho(r){return q(r.map(e=>`@${e}`))}function yo(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Te=class{name="cypress";canHandle(e){return E.has(wt.default.extname(e).toLowerCase())}apply(e,t,s){let n=Ct.default.createSourceFile(wt.default.basename(e),t,Ct.default.ScriptTarget.Latest,!0),o=W(n);if(o.length===0)return t;let i=z(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(yo(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let m=s.length===0?B(c,"tags",n):$(c,"tags",ho(a),n);return m?[m]:[]});return p.length>0?U(t,p):t}};var _r=f(require("path")),Ft=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Et=/^@([a-zA-Z0-9_-]+)/gm;function xo(r){return["# <mokosh-tags>",...r.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
2
+ "use strict";var wn=Object.create;var ye=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Fn=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,Pn=Object.prototype.hasOwnProperty;var Tn=(r,e)=>{for(var t in e)ye(r,t,{get:e[t],enumerable:!0})},sr=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fn(e))!Pn.call(r,n)&&n!==t&&ye(r,n,{get:()=>e[n],enumerable:!(s=Cn(e,n))||s.enumerable});return r};var f=(r,e,t)=>(t=r!=null?wn(En(r)):{},sr(e||!r||!r.__esModule?ye(t,"default",{value:r,enumerable:!0}):t,r)),An=r=>sr(ye({},"__esModule",{value:!0}),r);var va={};Tn(va,{createMcpServer:()=>Ke});module.exports=An(va);var kn=require("@modelcontextprotocol/sdk/server/stdio.js");var vn=require("@modelcontextprotocol/sdk/server/index.js"),qe=require("@modelcontextprotocol/sdk/types.js");var Hs=f(require("fs"));var ve=f(require("fs")),Ve=f(require("path"));var In=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],nr=[];function xe(r){nr.push(r)}function or(r){return[...In,...nr].some(e=>typeof e=="string"?r.includes(e):e instanceof RegExp?e.test(r):e(r))}var Mn=[".test.",".spec.","-test.","-spec."],ir=[];function Se(r){ir.push(r)}function X(){return[...Mn,...ir]}var Rn=["jest","vitest","playwright","cypress","@testing-library/"],ar=[];function be(r){ar.push(r)}function Je(){return[...Rn,...ar]}var pr=.8;function He(r){pr=r}function Qe(){return pr}var Nn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function Z(r,{allowJs:e=!0,isExplicitPath:t=!1}={}){if(t){let s=Ve.default.resolve(r);return ve.default.existsSync(s)?s.endsWith(".json")?cr(s):e?lr(s):{}:{}}for(let s of Nn){let n=Ve.default.resolve(r,s);if(ve.default.existsSync(n)){if(s.endsWith(".json"))return cr(n);if(e)return lr(n)}}return{}}function cr(r){return JSON.parse(ve.default.readFileSync(r,"utf-8"))}function lr(r){let e=require(r);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function Xe(r){for(let e of r.configMatchers??[])xe(e);for(let e of r.testPatterns??[])Se(e);for(let e of r.testLibraries??[])be(e);r.barrelThreshold!==void 0&&He(r.barrelThreshold)}var Ze=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Ye=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"];var ur=f(require("fs")),et=f(require("path"));function tt(r,e){let t=et.default.resolve(r,e);try{let s=ur.default.readFileSync(t,"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=et.default.relative(r,i);o.set(c,p)}return o}catch{return new Map}}var ke={serialize(r){let e=["graph TD"],t=new Set;for(let s of r.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(!t.has(a)){let p=o.isStyle?"-- styles -->":"-->";e.push(` ${n} ${p} ${i}`),t.add(a)}}}return e.join(`
3
+ `)}};var rt=f(require("fs")),fr=f(require("path"));function st(r,e){let t=r.replace(/^\.\//,"");if(e.nodes.has(t))return t;let s=t.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(s)?s:null}function gr(r,e){if(typeof r=="string")return st(r,e);if(r&&typeof r=="object"){let t=r;for(let s of["import","require","default"]){let n=gr(t[s],e);if(n)return n}}return null}function Gn(r){if(!r)return"unknown";let e=r.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 _n(r,e){let t=new Set,s=new Set,n=[...e];for(;n.length;){let o=n.shift();if(s.has(o))continue;s.add(o);let i=r.nodes.get(o);if(i){for(let a of i.exports)t.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=r.nodes.get(a.toPath);if(c)for(let m of c.exports)t.add(m.name);n.push(a.toPath)}else for(let c of a.symbols)t.add(c)}}}return t}function nt(r,e){let t=[],s=fr.default.join(e,"package.json");if(rt.default.existsSync(s))try{let n=JSON.parse(rt.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=gr(o,r);i&&!t.includes(i)&&t.push(i)}else if(typeof n.exports=="string"){let o=st(n.exports,r);o&&t.push(o)}if(t.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=st(o,r);i&&!t.includes(i)&&t.push(i)}}catch{}if(t.length===0){for(let n of["src/index.ts","src/index.js","index.ts","index.js"])if(r.nodes.has(n)){t.push(n);break}}return t}function jn(r,e){let t=new Set(e);for(let s of e)r.traverse(s,n=>(t.add(n.path),!0),{direction:"outgoing"});return t}function On(r,e,t){let s=new Map;for(let n of e){if(t.includes(n))continue;let o=r.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 Ln(r,e,t,s){let n=[];for(let o of r){let i=e.get(o),a=s.flatMap(g=>t.nodes.get(g)?.exports??[]).find(g=>g.name===o),p=i?.symbol??a,c=i?.file??s.find(g=>t.nodes.get(g)?.exports.some(h=>h.name===o))??s[0],m={name:o,definedIn:c,kind:Gn(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 Wn(r,e,t){let s=p=>r.nodes.get(p)?.category==="test",n=[...e].filter(p=>!t.includes(p)&&!s(p)),o=[...r.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 ot(r,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let c of e)if(!r.nodes.has(c))throw new Error(`Entry point not found in graph: ${c}`);let t=jn(r,e),s=On(r,t,e),n=_n(r,e),o=Ln(n,s,r,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=Wn(r,t,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}function it(r,e){let t=null,s=[];for(let o of r.nodes.values()){o.exports.some(i=>i.name===e)&&(t=o.path);for(let i of o.callEdges??[])i.to===e&&s.push({file:o.path,callerFunction:i.from})}let n=[];if(t){let o=r.nodes.get(t);for(let i of o?.callEdges??[])i.from===e&&n.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:t,callers:s,callees:n}}var zn=f(require("fs")),$n=f(require("path"));function mr(r){let e=[...r.nodes.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>`${s}:${n.mtime}:${n.size}`).join("|"),t=2166136261;for(let s=0;s<e.length;s++)t^=e.charCodeAt(s),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function at(r){let e=new Map;for(let t of r.nodes.keys()){let s=[];r.traverse(t,n=>(n.path!==t&&s.push(n.path),!0),{direction:"incoming"}),e.set(t,s)}return{impact:e,graphHash:mr(r)}}function pt(r,e){return r.impact.get(e)??[]}var Y=f(require("path"));function Bn(r){let e=new Map;for(let[t,s]of r){let n=s.imports.filter(o=>o.toPath&&!o.isExternal).length;n>0&&e.set(t,n)}return e}function Un(r,e,t){let s=new Map;for(let[n,o]of e){if(o<t)continue;let i=r.get(n);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Y.default.extname(n),p=Y.default.basename(n,a),c=p==="index"?Y.default.basename(Y.default.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${c}`})}return s}function R(r,e){let t=e?.minOutDegree??5;return Un(r,Bn(r),t)}var qn=(r,e)=>r.outDegree-e.outDegree;function Kn(r,e){let t=new Map;for(let s of e.values()){let n=new Set;r.traverse(s.path,o=>(o.path!==s.path&&n.add(o.path),!0),{direction:"outgoing"}),t.set(s.path,n)}return t}function Jn(r,e,t,s){let n=new Map;for(let[o]of r){if(e.has(o))continue;let i=null;for(let a of e.values())t.get(a.path)?.has(o)&&(!i||s(a,i)<0)&&(i=a);i&&n.set(o,i.path)}return n}function Hn(r,e){let t=new Map;for(let s of r.values()){let n=s.tag.replace("feature:",""),o=[];for(let[i,a]of e)a===s.path&&o.push(i);t.set(n,{hub:s.path,outDegree:s.outDegree,files:o})}return t}function Qn(r,e,t){let s=[];for(let n of r.keys())!e.has(n)&&!t.has(n)&&s.push(n);return s}function ee(r,e){let t=e?.detectFn??R,s=e?.hubComparator??qn,n=t(r.nodes,e),o=Kn(r,n),i=Jn(r.nodes,n,o,s);return{features:Hn(n,i),unassigned:Qn(r.nodes,n,i)}}var te=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let t=new Set(this.nodes.keys());return e.filter(s=>!t.has(s))}findHighExportUsage(e){let t=[];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);t.push({path:s.path,maxExportUsage:s.maxExportUsage,tightestDep:n?.toPath??""})}return t.sort((s,n)=>n.maxExportUsage-s.maxExportUsage)}findCycles(){let e=[],t=new Set,s=new Set,n=[],o=i=>{t.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 t.has(p.toPath)||o(p.toPath)}s.delete(i),n.pop()};for(let i of this.nodes.keys())t.has(i)||o(i);return e}};var P=class r{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let t=new Map;for(let s of e.nodes)t.set(s.path,s);return new r(t)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let t of this.nodes.values())for(let s of t.imports)if(s.toPath){let n=e.get(s.toPath)||[];n.push(t.path),e.set(s.toPath,n)}return this._incomingEdgesCache=e,e}dfs(e,t,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),t(g,c,m)!==!1))for(let h of n(p))a(h,c+1,p)};a(e,0,null)}traverse(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,t,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 t of this.nodes.values())for(let s of t.callEdges??[]){let n=e.get(s.toFile)??[];n.push(t.path),e.set(s.toFile,n)}return this._callIncomingCache=e,e}traverseCalls(e,t,s={}){let n=s.direction??"outgoing",o=n==="incoming"?this.getCallIncomingCache():null;this.dfs(e,t,s,i=>n==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:o?.get(i)??[])}getCallers(e){let t=[];return this.traverseCalls(e,s=>(s.path!==e&&t.push(s.path),!0),{direction:"incoming",maxDepth:1}),t}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let t=this.nodes.get(e);return t?t.imports.map(s=>this.nodes.get(s.toPath)).filter(s=>s!==void 0):[]}findUnusedFiles(e){return new te(this.nodes).findUnusedFiles(e)}findCycles(){return new te(this.nodes).findCycles()}};var N=class{affectedSymbols=new Map;constructor(e,t){this.affectedSymbols.set(e,new Set(["default",...t]))}updateAffectedSymbols(e,t){let s=this.affectedSymbols.get(t)||new Set,n=e.imports.find(p=>p.toPath===t);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 ct(r,e,t=1){let s=[];return r.traverse(e,(n,o,i)=>{if(n.path===e)return!0;let a=i?r.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:t}),s}function lt(r,e){let t=[];return r.traverse(e,s=>{if(s.path===e)return!0;let n=s.imports.find(o=>o.toPath===e);return t.push({path:s.path,...n?.symbols?{symbols:n.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),t}function ut(r,e,t={}){let{testsOnly:s=!1,changedSymbols:n}=t,o=n?new N(e,n):null,i=[];return r.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 ft(r,e,t={}){let{depth:s=1,withEdgeDetail:n=!1}=t,o=[];return r.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 gt(r,e={}){let{metric:t="cognitiveComplexity",threshold:s=10,limit:n=20}=e;return[...r.nodes.values()].flatMap(o=>(o.functions??[]).filter(i=>i[t]>=s).map(i=>({file:o.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((o,i)=>i[t]-o[t]).slice(0,n)}function mt(r){return{nodes:r.nodes.map(t=>({path:t.path,type:t.type,category:t.category,exports:t.exports.map(s=>s.name),tags:t.tags.filter(s=>s.kind==="comment-marker"||s.kind==="import").map(s=>s.name),importsFiles:t.imports.filter(s=>!s.isExternal&&s.toPath).map(s=>s.toPath),...t.description!==void 0&&{description:t.description},...t.testedBy!==void 0&&{testedBy:t.testedBy},...t.coveragePct!==void 0&&{coveragePct:t.coveragePct},...t.avgExportUsage!==void 0&&{avgExportUsage:t.avgExportUsage},...t.maxExportUsage!==void 0&&{maxExportUsage:t.maxExportUsage}})),cycles:r.cycles}}function dt(r){let e=r.getPackageDependencies(),t=Array.from(r.packages.values()).map(({graph:s,pkg:n})=>({name:n.name,relativeRoot:n.relativeRoot,nodeCount:s.nodes.size,dependsOn:e.get(n.name)??[]}));return{monorepoType:r.type,packageCount:t.length,packages:t}}function ht(r){return[...r.nodes.values()].some(e=>e.coveragePct!==void 0)}function dr(r){if(r.category==="test")return"test";if(r.category==="config")return"config";if(r.category==="type-only")return"types";let e=r.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")||re(e)==="cli"?"cli":x(e,"util")||x(e,"utils")||x(e,"helper")||x(e,"helpers")?"util":x(e,"model")||x(e,"models")||re(e)==="model"?"model":x(e,"parser")||x(e,"parsers")||re(e)==="parser"?"parser":re(e)==="builder"?"builder":re(e)==="resolver"?"resolver":"other"}function x(r,e){return r.includes(`/${e}/`)||r.includes(`/${e}.`)}function re(r){let e=r.slice(r.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function yt(r,e){let t=ee(r,e),s=new Map;for(let[o,i]of t.features){for(let a of i.files)s.set(a,o);s.set(i.hub,o)}let n=new Map;for(let o of r.nodes.values()){let i=s.get(o.path);n.set(o.path,{path:o.path,role:dr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}function Vn(r){return r?r.startsWith("interface ")?"interface":r.startsWith("class ")?"class":r.startsWith("enum ")?"enum":"type":"type"}function Xn(r,e){if(e==="type-only")return!0;let t=r.signature??"";return t.startsWith("interface ")||t.startsWith("class ")||t.startsWith("enum ")}function xt(r){let e=new Map;for(let s of r.nodes.values())if(!(s.type!=="typescript"&&s.type!=="javascript"))for(let n of s.exports){if(!Xn(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:Vn(n.signature),...n.doc?{doc:n.doc}:{}})}let t=[];for(let s of r.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}`)&&t.push({fromFile:s.path,toType:o,toFile:n.toPath})}return{types:e,edges:t}}function St(r,e){let t=null;for(let o of r.types.values())if(o.name===e){t=o;break}if(!t)return{type:null,usedByFiles:[],uses:[]};let s=new Set,n=new Map;for(let o of r.edges)if(o.toType===e&&o.toFile===t.file&&s.add(o.fromFile),o.fromFile===t.file){let i=r.types.get(`${o.toFile}::${o.toType}`);i&&n.set(`${i.file}::${i.name}`,i)}return{type:t,usedByFiles:Array.from(s),uses:Array.from(n.values())}}var Ir=f(require("path"));var Ce=f(require("fs")),kt=f(require("path"));var j=f(require("fs")),C=f(require("path"));var bt=f(require("fs")),Zn=f(require("path"));function hr(r){try{return bt.default.statSync(r,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function we(r){try{return bt.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function vt(r,e){let t=C.default.join(e,"package.json");if(!j.default.existsSync(t))return null;let s={};try{s=JSON.parse(j.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name;return n?{name:n,root:e,relativeRoot:C.default.relative(r,e),entryPoints:Yn(e,s)}:null}function Yn(r,e){let t=[];if(e.exports){let n=e.exports;if(typeof n=="string")t.push(C.default.join(r,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")t.push(C.default.join(r,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&t.push(C.default.join(r,i))}}}e.main&&t.push(C.default.join(r,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])t.push(C.default.join(r,n));let s=t.filter(we);return s.length>0?s.slice(0,1):t.slice(0,1)}function O(r,e){let t=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");eo(r,o,s,t)}return t}function eo(r,e,t,s){if(!e.includes("*")){to(r,e,t,s);return}let n=e.split("/");n.includes("**")?ro(r,n,t,s):so(r,n,t,s)}function to(r,e,t,s){let n=C.default.join(r,e);if(t.has(n)||!hr(n))return;t.add(n);let o=vt(r,n);o&&s.push(o)}function ro(r,e,t,s){let n=C.default.join(r,e[0]==="**"?"":e[0]??"");yr(r,n,t,s)}function so(r,e,t,s){let n=e.findIndex(a=>a.includes("*")),o=C.default.join(r,...e.slice(0,n)),i;try{i=j.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(t.has(p))continue;t.add(p);let c=vt(r,p);c&&s.push(c)}}function yr(r,e,t,s){let n;try{n=j.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(j.default.existsSync(C.default.join(i,"package.json"))&&!t.has(i)){t.add(i);let a=vt(r,i);a&&s.push(a)}else yr(r,i,t,s)}}var xr={type:"npm",detect(r){let e=kt.default.join(r,"package.json");if(!Ce.default.existsSync(e))return null;let t;try{t=JSON.parse(Ce.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t||Ce.default.existsSync(kt.default.join(r,"yarn.lock")))return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:O(r,s)}};var D=f(require("fs")),v=f(require("path"));var Sr={type:"nx",detect(r){return D.default.existsSync(v.default.join(r,"nx.json"))?br(r,r,new Set,0).map(t=>no(r,t,v.default.join(t,"project.json"))).filter(t=>t!==null):null}};function br(r,e,t,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"))&&!t.has(p)?(t.add(p),o.push(p)):o.push(...br(r,p,t,s+1))}return o}function no(r,e,t){let s={};try{s=JSON.parse(D.default.readFileSync(t,"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(r,e),entryPoints:oo(e,s,o,i)}:null}function oo(r,e,t,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=v.default.resolve(r,"../..");n.push(v.default.resolve(a,o)),n.push(v.default.resolve(r,o))}if(s){let a=s;if(typeof a=="string")n.push(v.default.join(r,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(v.default.join(r,p))}}if(t&&n.push(v.default.join(r,t)),e.sourceRoot){let a=v.default.resolve(r,"../.."),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(r,a));let i=n.filter(we);return i.length>0?i.slice(0,1):n.slice(0,1)}var wt=f(require("fs")),vr=f(require("path")),kr=f(require("js-yaml"));var wr={type:"pnpm",detect(r){let e=vr.default.join(r,"pnpm-workspace.yaml");if(!wt.default.existsSync(e))return null;let t=[];try{t=kr.default.load(wt.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return O(r,t)}};var Cr=f(require("fs")),Fr=f(require("path")),Er={type:"turborepo",detect(r){return Cr.default.existsSync(Fr.default.join(r,"turbo.json"))?[]:null}};var Fe=f(require("fs")),Ct=f(require("path"));var Pr={type:"yarn",detect(r){if(!Fe.default.existsSync(Ct.default.join(r,"yarn.lock")))return null;let e=Ct.default.join(r,"package.json");if(!Fe.default.existsSync(e))return null;let t;try{t=JSON.parse(Fe.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t)return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:O(r,s)}};var Tr=[];function A(r){Tr.push(r)}function Ar(){return Tr}A(Er);A(Sr);A(wr);A(Pr);A(xr);function se(r,e=Ar()){let t=Ir.default.resolve(r),s=new Map,n=[];for(let i of e){let a=i.detect(t);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:t,type:"none",types:[],packages:[],packageMap:new Map};let o=Array.from(s.values());return{root:t,type:n[0],types:n,packages:o,packageMap:new Map(o.map(i=>[i.name,i]))}}var ne=class r{constructor(e,t){this.monorepoRoot=e;this.type=t}monorepoRoot;type;packages=new Map;addPackage(e,t){this.packages.set(e.name,{graph:t,pkg:e})}getPackageForFile(e){for(let{pkg:t}of this.packages.values())if(e===t.relativeRoot||e.startsWith(`${t.relativeRoot}/`))return t}getPackageDependencies(){let e=new Map;for(let{graph:t,pkg:s}of this.packages.values()){let n=new Set;for(let o of t.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 t=this.getPackageForFile(e);if(!t)return[];let s=this.packages.get(t.name);if(!s)return[];let n=[];s.graph.traverse(e,o=>(o.path!==e&&n.push({file:o.path,package:t.name}),!0),{direction:"incoming"});for(let{graph:o,pkg:i}of this.packages.values())if(i.name!==t.name)for(let a of o.nodes.values())a.imports.some(c=>c.isWorkspace&&c.workspacePackage===t.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:t})=>({pkg:{name:t.name,relativeRoot:t.relativeRoot,entryPoints:t.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let t=new r(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);t.packages.set(s.name,{graph:i,pkg:{...s,root:""}})}return t}};var Mr=new Map;function L(r,e){Mr.set(r,e)}function Rr(r){return Mr.get(r)}function Nr(r,e){return e.startsWith("!")?r!==e.slice(1):r===e}function io(r,e){return e.startsWith("!")?!r.includes(e.slice(1)):r.includes(e)}var ao=(r,e)=>!e.category||Nr(r.category,e.category),po=(r,e)=>!e.type||Nr(r.type,e.type),co=(r,e)=>!e.path||io(r.path,e.path),lo=(r,e)=>e.isExternal===void 0?!0:r.imports.some(s=>s.isExternal)===e.isExternal,uo=(r,e)=>{if(!e.tags||e.tags.length===0)return!0;let t=e.tags.filter(n=>!n.startsWith("!")),s=e.tags.filter(n=>n.startsWith("!")).map(n=>n.slice(1));return!(t.length>0&&!t.some(n=>r.tags.some(o=>o.name===n))||s.some(n=>r.tags.some(o=>o.name===n)))},fo=(r,e)=>!e.allTags?.length||e.allTags.every(t=>r.tags.some(s=>s.name===t)),go=(r,e)=>!e.importsFile||r.imports.some(t=>t.toPath?.includes(e.importsFile)),mo=(r,e,t)=>e.importedBy===void 0?!0:(t?.get(r.path)??[]).some(n=>n.includes(e.importedBy)),ho=(r,e)=>e.minImports===void 0||r.imports.length>=e.minImports,yo=(r,e)=>e.maxImports===void 0||r.imports.length<=e.maxImports,xo=(r,e)=>e.minSize===void 0||r.size>=e.minSize,So=(r,e)=>e.maxSize===void 0||r.size<=e.maxSize,bo=(r,e)=>e.hasDocstring===void 0||!!r.description===e.hasDocstring,vo=(r,e)=>e.minCoverage===void 0||(r.coveragePct??101)>=e.minCoverage,ko=(r,e)=>e.maxCoverage===void 0||(r.coveragePct??0)<=e.maxCoverage,wo=(r,e)=>e.minExportUsage===void 0||(r.avgExportUsage??-1)>=e.minExportUsage,Co=(r,e)=>e.maxExportUsage===void 0||(r.avgExportUsage??0)<=e.maxExportUsage,Dr=[ao,po,co,lo,uo,fo,go,mo,ho,yo,xo,So,bo,vo,ko,wo,Co];function Gr(r,e,t){return Dr.every(s=>s(r,e,t))}function Ee(r,e){let t=new Map;if(e.importedBy!==void 0){for(let i of r.nodes)for(let a of i.imports)if(a.toPath){let p=t.get(a.toPath)??[];p.push(i.path),t.set(a.toPath,p)}}let s=r.nodes.filter(i=>Gr(i,e,t)),n=new Set(s.map(i=>i.path)),o=s.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||n.has(a.toPath))}));return e.sort&&o.sort((i,a)=>e.sort==="size"?a.size-i.size:e.sort==="imports"?a.imports.length-i.imports.length:e.sort==="commitCount90d"?(a.commitCount90d??0)-(i.commitCount90d??0):e.sort==="exportUsage"?(a.avgExportUsage??0)-(i.avgExportUsage??0):0),e.limit!==void 0&&o.splice(e.limit),{nodes:o,cycles:r.cycles?.filter(i=>i.every(a=>n.has(a)))??void 0}}function Pe(r){let e={},t=r.split(",");for(let s of t){let n=s.indexOf(":");if(n===-1)continue;let o=s.slice(0,n).trim().toLowerCase(),i=s.slice(n+1).trim();if(!(!o||!i))switch(o){case"category":e.category=i;break;case"type":e.type=i;break;case"tag":case"tags":i.includes("+")?e.allTags=[...e.allTags??[],...i.split("+")]:e.tags=[...e.tags??[],i];break;case"path":e.path=i;break;case"external":e.isExternal=i.toLowerCase()==="true";break;case"importsfile":e.importsFile=i;break;case"importedby":e.importedBy=i;break;case"minimports":e.minImports=parseInt(i,10);break;case"maximports":e.maxImports=parseInt(i,10);break;case"minsize":e.minSize=parseInt(i,10);break;case"maxsize":e.maxSize=parseInt(i,10);break;case"sort":e.sort=i;break;case"limit":e.limit=parseInt(i,10);break;case"hasdocstring":e.hasDocstring=i.toLowerCase()!=="false";break;case"mincoverage":e.minCoverage=parseInt(i,10);break;case"maxcoverage":e.maxCoverage=parseInt(i,10);break;case"minexportusage":e.minExportUsage=parseFloat(i);break;case"maxexportusage":e.maxExportUsage=parseFloat(i);break}}return e}var jt=f(require("fs/promises")),qr=f(require("path"));var Ge=f(require("path")),oe=f(require("typescript"));var Ft=f(require("path")),Et=f(require("typescript"));var k=f(require("typescript")),_r=new Set(["describe","test","it"]);function W(r){let e=[];for(let t of r.statements){if(!k.default.isExpressionStatement(t))continue;let s=t.expression;if(!k.default.isCallExpression(s))continue;let n=s.expression;k.default.isIdentifier(n)&&_r.has(n.text)&&e.push(s),k.default.isPropertyAccessExpression(n)&&k.default.isIdentifier(n.expression)&&_r.has(n.expression.text)&&e.push(s)}return e}function z(r,e,t){for(let s of r.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 $(r,e,t,s){if(r.arguments.length===0)return null;for(let o=1;o<r.arguments.length;o++){let i=r.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:t};let p=i.getEnd()-1;return{start:p,end:p,text:`${i.properties.length>0?", ":""}${e}: ${t}`}}let n=r.arguments[r.arguments.length-1];return{start:n.getStart(s),end:n.getStart(s),text:`{ ${e}: ${t} }, `}}function B(r,e,t){let s=r.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(t),end:o.properties[i+1].getStart(t),text:""}}return null}function U(r,e){let t=[...e].sort((n,o)=>o.start-n.start),s=r;for(let n of t)s=s.slice(0,n.start)+n.text+s.slice(n.end);return s}function q(r){return`[${r.map(e=>JSON.stringify(e)).join(", ")}]`}var E=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function Fo(r){return q(r.map(e=>`@${e}`))}function Eo(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Te=class{name="cypress";canHandle(e){return E.has(Ft.default.extname(e).toLowerCase())}apply(e,t,s){let n=Et.default.createSourceFile(Ft.default.basename(e),t,Et.default.ScriptTarget.Latest,!0),o=W(n);if(o.length===0)return t;let i=z(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(Eo(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let m=s.length===0?B(c,"tags",n):$(c,"tags",Fo(a),n);return m?[m]:[]});return p.length>0?U(t,p):t}};var jr=f(require("path")),Pt=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Tt=/^@([a-zA-Z0-9_-]+)/gm;function Po(r){return["# <mokosh-tags>",...r.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
4
4
  `)+`
5
5
 
6
- `}function So(r){let e=new Set;Et.lastIndex=0;let t=Et.exec(r);for(;t!==null;)t[1]&&e.add(t[1]),t=Et.exec(r);return e}var Pe=class{name="gherkin";canHandle(e){return _r.default.extname(e).toLowerCase()===".feature"}apply(e,t,s){let n=t.replace(Ft,""),o=So(n),i=s.filter(p=>!o.has(p)),a=i.length>0?xo(i):"";return Ft.test(t)?t.replace(Ft,a):a?t.replace(/^(Feature:)/m,`${a}$1`):t}};function jr(r,e){let t=r.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<t.length;o++){let i=t[o];i==="*"?t[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Lr=f(require("path")),Tt=/^\/\/go:build mokosh_[^\n]+\n/m,bo=/^package\s+\S+/m;function vo(r){return`//go:build ${r.map(t=>`mokosh_${t}`).join(" || ")}
7
- `}function ko(r){let e=Tt.exec(r);if(!e)return null;let t=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(t);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(t);return n}var Ae=class{name="go";canHandle(e){return Lr.default.basename(e).endsWith("_test.go")}apply(e,t,s){let n=ko(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(Tt,"");let i=vo(o);if(n!==null)return t.replace(Tt,i);let a=bo.exec(t);if(!a)return t;let p=a.index;return t.slice(0,p)+i+`
8
- `+t.slice(p)}};var Or=f(require("path"));var wo=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Pt=/^ \* @group (.+)$/gm;function Co(r){return["/**",...r.map(e=>` * @group ${e}`)," */"].join(`
6
+ `}function To(r){let e=new Set;Tt.lastIndex=0;let t=Tt.exec(r);for(;t!==null;)t[1]&&e.add(t[1]),t=Tt.exec(r);return e}var Ae=class{name="gherkin";canHandle(e){return jr.default.extname(e).toLowerCase()===".feature"}apply(e,t,s){let n=t.replace(Pt,""),o=To(n),i=s.filter(p=>!o.has(p)),a=i.length>0?Po(i):"";return Pt.test(t)?t.replace(Pt,a):a?t.replace(/^(Feature:)/m,`${a}$1`):t}};function Or(r,e){let t=r.replace(/\\/g,"/"),s=e.replace(/\\/g,"/"),n="";for(let o=0;o<t.length;o++){let i=t[o];i==="*"?t[o+1]==="*"?(n+=".*",o++):n+="[^/]*":i==="?"?n+="[^/]":i!==void 0&&(n+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${n}$`).test(s)}var Lr=f(require("path")),At=/^\/\/go:build mokosh_[^\n]+\n/m,Ao=/^package\s+\S+/m;function Io(r){return`//go:build ${r.map(t=>`mokosh_${t}`).join(" || ")}
7
+ `}function Mo(r){let e=At.exec(r);if(!e)return null;let t=e[0],s=/mokosh_([a-zA-Z0-9_-]+)/g,n=[],o=s.exec(t);for(;o!==null;)o[1]&&n.push(o[1]),o=s.exec(t);return n}var Ie=class{name="go";canHandle(e){return Lr.default.basename(e).endsWith("_test.go")}apply(e,t,s){let n=Mo(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(At,"");let i=Io(o);if(n!==null)return t.replace(At,i);let a=Ao.exec(t);if(!a)return t;let p=a.index;return t.slice(0,p)+i+`
8
+ `+t.slice(p)}};var Wr=f(require("path"));var Ro=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,It=/^ \* @group (.+)$/gm;function No(r){return["/**",...r.map(e=>` * @group ${e}`)," */"].join(`
9
9
  `)+`
10
10
 
11
- `}function Fo(r){let e=[];Pt.lastIndex=0;let t=Pt.exec(r);for(;t!==null;)t[1]&&e.push(t[1]),t=Pt.exec(r);return e}var Ie=class{name="jest";canHandle(e){return E.has(Or.default.extname(e).toLowerCase())}apply(e,t,s){let n=wo.exec(t),o=n?Fo(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return t;let a=n?t.slice(n[0].length):t;return s.length===0?a:Co(i)+a}};var At=f(require("path")),It=f(require("typescript"));function Eo(r){return q(r.map(e=>`@${e}`))}function To(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Me=class{name="playwright";canHandle(e){return E.has(At.default.extname(e).toLowerCase())}apply(e,t,s){let n=It.default.createSourceFile(At.default.basename(e),t,It.default.ScriptTarget.Latest,!0),o=W(n);if(o.length===0)return t;let i=z(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(To(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let m=s.length===0?B(c,"tag",n):$(c,"tag",Eo(a),n);return m?[m]:[]});return p.length>0?U(t,p):t}};var Wr=f(require("path")),Mt=/^pytestmark\s*=\s*.+$/m,Po=/^import pytest\s*$/m;function Ao(r){let e=r.map(t=>`pytest.mark.${t}`).join(", ");return r.length===1?`pytestmark = pytest.mark.${r[0]}`:`pytestmark = [${e}]`}function Io(r){let e=Mt.exec(r);if(!e)return null;let t=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(t);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(t);return s}var Re=class{name="pytest";canHandle(e){return Wr.default.extname(e).toLowerCase()===".py"}apply(e,t,s){let n=Io(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(Mt,"").replace(/\n{3,}/g,`
11
+ `}function Do(r){let e=[];It.lastIndex=0;let t=It.exec(r);for(;t!==null;)t[1]&&e.push(t[1]),t=It.exec(r);return e}var Me=class{name="jest";canHandle(e){return E.has(Wr.default.extname(e).toLowerCase())}apply(e,t,s){let n=Ro.exec(t),o=n?Do(n[0]):null,i=[...s].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(i))return t;let a=n?t.slice(n[0].length):t;return s.length===0?a:No(i)+a}};var Mt=f(require("path")),Rt=f(require("typescript"));function Go(r){return q(r.map(e=>`@${e}`))}function _o(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Re=class{name="playwright";canHandle(e){return E.has(Mt.default.extname(e).toLowerCase())}apply(e,t,s){let n=Rt.default.createSourceFile(Mt.default.basename(e),t,Rt.default.ScriptTarget.Latest,!0),o=W(n);if(o.length===0)return t;let i=z(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(_o(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let m=s.length===0?B(c,"tag",n):$(c,"tag",Go(a),n);return m?[m]:[]});return p.length>0?U(t,p):t}};var zr=f(require("path")),Nt=/^pytestmark\s*=\s*.+$/m,jo=/^import pytest\s*$/m;function Oo(r){let e=r.map(t=>`pytest.mark.${t}`).join(", ");return r.length===1?`pytestmark = pytest.mark.${r[0]}`:`pytestmark = [${e}]`}function Lo(r){let e=Nt.exec(r);if(!e)return null;let t=e[0],s=[],n=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,o=n.exec(t);for(;o!==null;)o[1]&&s.push(o[1]),o=n.exec(t);return s}var Ne=class{name="pytest";canHandle(e){return zr.default.extname(e).toLowerCase()===".py"}apply(e,t,s){let n=Lo(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(Nt,"").replace(/\n{3,}/g,`
12
12
 
13
- `);let i=Ao(o);if(n!==null)return t.replace(Mt,i);let a=Po.test(t),p=Mo(t),c=t.slice(0,p),m=t.slice(p),g=a?"":`import pytest
13
+ `);let i=Oo(o);if(n!==null)return t.replace(Nt,i);let a=jo.test(t),p=Wo(t),c=t.slice(0,p),m=t.slice(p),g=a?"":`import pytest
14
14
  `,h=c.endsWith(`
15
15
 
16
16
  `)?"":`
17
17
  `;return c+h+g+i+`
18
- `+m}};function Mo(r){let e=r.split(`
19
- `),t=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(t=n)}if(t<0)return 0;let s=0;for(let n=0;n<=t;n++)s+=e[n].length+1;return s}var Rt=f(require("path")),Nt=f(require("typescript"));var Ro=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Ne=class{name="vitest";canHandle(e){return E.has(Rt.default.extname(e).toLowerCase())}apply(e,t,s){let n=t.replace(Ro,""),o=Nt.default.createSourceFile(Rt.default.basename(e),n,Nt.default.ScriptTarget.Latest,!0),i=W(o);if(i.length===0)return n;let a=z(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?B(m,"tags",o):$(m,"tags",q(p),o);return g?[g]:[]});return c.length>0?U(n,c):n}};var zr={vitest:()=>new Ne,playwright:()=>new Me,cypress:()=>new Te,jest:()=>new Ie},No={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function Go(r){let e=ne.default.createSourceFile("detect.ts",r,ne.default.ScriptTarget.Latest,!0);for(let t of e.statements){if(!ne.default.isImportDeclaration(t)||!ne.default.isStringLiteral(t.moduleSpecifier))continue;let s=No[t.moduleSpecifier.text];if(s)return s}return null}var Gt=class{constructor(e,t,s){this.rootDir=e;this.defaultFramework=t;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return E.has(Ge.default.extname(e).toLowerCase())}apply(e,t,s){let n=Go(t)??this.matchOverride(e)??this.defaultFramework;return(zr[n]??zr.vitest)().apply(e,t,s)}matchOverride(e){let t=Ge.default.relative(this.rootDir,e).split(Ge.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(jr(s,t))return n;return null}};function $r(r="vitest",e={},t=process.cwd()){return[new Pe,new Re,new Ae,new Gt(t,r,Object.entries(e))]}function Br(r,e){return e.find(t=>t.canHandle(r))??null}var Do=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,_o=new Set(["import"]),jo=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function Lo(r,e,t,s){let n;try{n=await Dt.default.readFile(r,"utf8")}catch(a){return{path:r,status:"error",error:String(a)}}let o=Br(r,s);if(!o)return{path:r,status:"unchanged"};let i=o.apply(r,n,e);return i===n?{path:r,status:"unchanged"}:(t||await Dt.default.writeFile(r,i,"utf8"),{path:r,status:"updated"})}async function _t(r,e,t){let s=X(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=$r(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let p of r.nodes.values()){if(p.category!=="test")continue;let c=new Set,m=[];for(let b of p.tags)_o.has(b.kind)&&Do.test(b.name)&&(jo.has(b.name.toLowerCase())||c.has(b.name)||(c.add(b.name),m.push(b.name)));m.sort();let g=Ur.default.resolve(e,p.path),h=await Lo(g,m,t.dryRun,i);h.path=p.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var De=class{isTestNode(e){return e.category==="test"||e.tags.some(t=>t.name==="test")}};var ge=f(require("fs")),w=f(require("path"));var jt=require("child_process"),_e=class{getChangedFiles(){try{let t=["git diff --name-only","git diff --cached --name-only","git ls-files --others --exclude-standard"].flatMap(s=>{try{return(0,jt.execSync)(s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
20
- `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(t))}catch(e){return console.error("Error getting git diff:",e),[]}}};function qr(r,e){let s=(0,jt.execSync)(`git -C "${r}" log --follow --format="%ae" --since="90 days ago" -- "${e}"`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
21
- `).filter(Boolean);return{commitCount90d:s.length,lastAuthor:s[0]}}var oe=f(require("fs")),Kr=f(require("path")),Lt=f(require("js-yaml"));function Jr(r){let e=r.lastIndexOf("@");return e>0?r.substring(0,e):r}function Oo(r){return r.replace(/:$/,"").split(",").map(e=>{let t=e.trim();return t.startsWith('"')&&(t=t.slice(1)),t.endsWith('"')&&(t=t.slice(0,-1)),Jr(t)}).filter(Boolean)}function Wo(r,e){let t=r.startsWith("/")?r.slice(1):r,s=t.lastIndexOf("@");return s>0?{name:t.substring(0,s),version:e||t.substring(s+1)}:{name:t,version:e}}function zo(r){try{let e=Lt.default.load(r),t={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=Jr(o);i&&(t.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return t}catch{return null}}function $o(r){let e={dependencies:{}};for(let t of r.split(/\n\n+/)){let s=t.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=Oo(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 Bo(r){let e=oe.default.readFileSync(r,"utf-8"),t=JSON.parse(e),s={dependencies:{}};if(t.packages)for(let[n,o]of Object.entries(t.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(t.dependencies)for(let[n,o]of Object.entries(t.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Uo(r){let e=oe.default.readFileSync(r,"utf-8");if(e.includes("__metadata:")){let t=zo(e);if(t!==null)return t}return $o(e)}function qo(r){let e=oe.default.readFileSync(r,"utf-8"),t={dependencies:{}};try{let s=Lt.default.load(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Wo(n,o.version);i&&(t.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(t.dependencies[n])continue;let i=typeof o=="string"?o:o.version;t.dependencies[n]={version:i||""}}}catch{}return t}function Hr(r){let e=[["package-lock.json",Bo],["yarn.lock",Uo],["pnpm-lock.yaml",qo]];for(let[t,s]of e){let n=Kr.default.join(r,t);if(oe.default.existsSync(n))return s(n)}return null}var Ot=f(require("path"));function I(r){switch(Ot.default.extname(r).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";default:return"unknown"}}function F(r){let e=Ot.default.extname(r).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var Qr=f(require("coffeescript"));function Ko(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function Jo(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function Ho(r,e){let t=e.source?.value;return t?{fromPath:r,toPath:"",rawSpecifier:t,isStyle:F(t),type:"static"}:null}function Qo(r,e){let t=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!t||!s?null:{fromPath:r,toPath:"",rawSpecifier:s,isStyle:F(s),type:"require"}}function Vo(r,e,t){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=Ho(r,e);n&&t.push(n)}else if(s==="Call"){let n=Qo(r,e);n&&t.push(n)}}function Wt(r,e,t){if(!(!e||typeof e!="object")){Vo(r,e,t);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)Wt(r,o,t);else Wt(r,n,t)}}}function Vr(r,e){let t=Ko(e),s=Jo(r,t),n=[];try{Wt(r,Qr.default.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var K=require("@cucumber/gherkin"),Xr=require("@cucumber/messages");var Xo=Xr.IdGenerator.uuid();function zt(r,e){let t=new Set;try{let s=new K.AstBuilder(Xo),n=new K.GherkinClassicTokenMatcher,i=new K.Parser(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{t.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(p=>{t.add(p.name.startsWith("@")?p.name.slice(1):p.name)}),a.scenario.examples.forEach(p=>{p.tags.forEach(c=>{t.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})),a.rule&&a.rule.children.forEach(p=>{p.scenario&&p.scenario.tags.forEach(c=>{t.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${r}:`,s)}return{imports:[],exports:[],tags:Array.from(t).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}O("gherkin",zt);var Yr=f(require("path")),es=require("@lezer/go"),Zo=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Yo=/^\/\/go:build\s+(.+)$/,ei=/^\/\/\s*\+build\s+(.+)$/;function ts(r,e){let t=[],s=new Map,n=new Set,o=new Set,a=es.parser.parse(e).cursor();do switch(a.name){case"LineComment":{let g=e.slice(a.from,a.to),h=g.match(Zo);h?.[1]&&n.add(h[1]);let b=g.match(Yo);b&&Zr(b[1],o);let M=g.match(ei);M&&Zr(M[1],o);break}case"ImportSpec":{let g=a.node.getChild("String");if(g){let b=e.slice(g.from,g.to).slice(1,-1);t.push({fromPath:r,toPath:"",rawSpecifier:b,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 h=e.slice(g.from,g.to);h!=="_"&&/^[A-Z]/.test(h)&&!s.has(h)&&s.set(h,{name:h})}break}}while(a.next());let p=t.some(g=>g.rawSpecifier==="testing"),c=Yr.default.basename(r).endsWith("_test.go")||n.has("test")||p?"test":"logic",m=new Set([...n,...o]);return{imports:t,exports:Array.from(s.values()),tags:Array.from(m).map(g=>({name:g,kind:"comment-marker"})),category:c}}function Zr(r,e){for(let t of r.split(/[\s,&|!()]+/)){let s=t.trim();s&&s!=="ignore"&&e.add(s)}}var rs=f(require("livescript"));function J(r){return r.startsWith("'")||r.startsWith('"')?r.slice(1,-1):r}function ti(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ri(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}var si=new Set(["first_line","first_column","last_line","last_column","line","column"]);function ni(r,e){let t=r.constructor?.name||r.type;if(t==="Import"){let s=r.right?.value;if(typeof s=="string"){let n=J(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:F(n),type:"static"}}}if(t==="Chain"&&r.head?.value==="require"){let s=r.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=J(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:F(o),type:"require"}}}}return null}function $t(r,e){if(!r||typeof r!="object")return[];let t=[],s=ni(r,e);s&&t.push(s);for(let n in r){if(si.has(n))continue;let o=r[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)t.push(...$t(i,e));else t.push(...$t(o,e))}return t}function ss(r,e){let t=ti(e),s=ri(r,t),n=[];try{n=$t(rs.default.ast(e),r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var ns=f(require("luaparse"));function oi(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ii(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function ai(r,e){let t=[];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=J(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=J(i.raw))}o&&t.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(r),t}function os(r,e){let t=oi(e),s=ii(r,t),n=[];try{let o=ns.default.parse(e);n=ai(o,r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var is=f(require("path")),as=require("@lezer/python"),pi=new Set(["pytest","unittest","nose","hypothesis"]);function ps(r,e){let t=[],s=[],n=new Set,o=is.default.basename(r).toLowerCase(),a=as.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 ci(a.node,e,r))t.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=gi(o,t,n);return p==="test"&&n.add("test"),{imports:t,exports:s,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:p}}function ci(r,e,t){let s=r.firstChild;return s?s.name==="from"?li(r,e,t):ui(r,e,t):[]}function li(r,e,t){let s=r.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=fi(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[ie(t,o,i,!0)];let c=a===1?"./":"../".repeat(a-1);return p?[ie(t,c+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[ie(t,c.slice(0,-1),["*"],!1)]:i.map(m=>ie(t,c+m,[m],!1))}function ui(r,e,t){let s=[],n=r.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(ie(t,o,["*"],!0))}n=n.nextSibling}return s}function fi(r,e){let t=[],s=r;for(;s;)s.name==="*"?t.push("*"):s.name==="VariableName"&&(t.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return t}function ie(r,e,t,s){return{fromPath:r,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:t.length>0?t:void 0}}function gi(r,e,t){return r.startsWith("test_")||r.endsWith("_test.py")?"test":r==="conftest.py"||r==="setup.py"?"config":t.has("test")||e.some(s=>pi.has(s.rawSpecifier))?"test":"logic"}var qt=f(require("path")),l=f(require("typescript"));var d=f(require("typescript"));function mi(r){let e=1;function t(s){switch(s.kind){case d.default.SyntaxKind.IfStatement:case d.default.SyntaxKind.ConditionalExpression:case d.default.SyntaxKind.ForStatement:case d.default.SyntaxKind.ForInStatement:case d.default.SyntaxKind.ForOfStatement:case d.default.SyntaxKind.WhileStatement:case d.default.SyntaxKind.DoStatement:case d.default.SyntaxKind.CatchClause:case d.default.SyntaxKind.CaseClause:e++;break;case d.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.default.SyntaxKind.AmpersandAmpersandToken||n===d.default.SyntaxKind.BarBarToken||n===d.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}d.default.forEachChild(s,t)}return t(r),e}function di(r){let e=0;function t(s,n,o){if(d.default.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;t(s.expression,a,!1),t(s.thenStatement,a,!1),s.elseStatement&&(d.default.isIfStatement(s.elseStatement)?t(s.elseStatement,n,!0):(e+=1,t(s.elseStatement,n+1,!1)));return}if(d.default.isForStatement(s)||d.default.isForInStatement(s)||d.default.isForOfStatement(s)||d.default.isWhileStatement(s)||d.default.isDoStatement(s)||d.default.isSwitchStatement(s)){e+=1+n,d.default.forEachChild(s,a=>t(a,n+1,!1));return}if(d.default.isCatchClause(s)){e+=1+n,d.default.forEachChild(s,a=>t(a,n,!1));return}if(d.default.isConditionalExpression(s)&&(e+=1),d.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.default.SyntaxKind.AmpersandAmpersandToken||a===d.default.SyntaxKind.BarBarToken||a===d.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(d.default.isFunctionDeclaration(s)||d.default.isFunctionExpression(s)||d.default.isArrowFunction(s))){e+=1+n,d.default.forEachChild(s,a=>t(a,n+1,!1));return}d.default.forEachChild(s,a=>t(a,n,!1))}return t(r,0,!1),e}function Bt(r){return{complexity:mi(r),cognitiveComplexity:di(r)}}var S=f(require("typescript")),Ut=new Set(["test","describe","it"]);function cs(r,e){hi(r,e),xi(r,e),Si(r,e),bi(r,e)}function hi(r,e){if((S.default.isFunctionDeclaration(r)||S.default.isVariableDeclaration(r))&&r.name&&S.default.isIdentifier(r.name)&&yi(r)){let t;if(S.default.isFunctionDeclaration(r))t="function";else{let s=r.initializer;t=s&&(S.default.isArrowFunction(s)||S.default.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:r.name.text,kind:t})}}function yi(r){if(S.default.isFunctionDeclaration(r))return S.default.isSourceFile(r.parent);let e=r.parent?.parent;return!!e&&S.default.isSourceFile(e.parent)}function xi(r,e){if(!S.default.isStringLiteral(r))return;let t=r.text.match(/@[\w-]+/g);if(t)for(let s of t)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function Si(r,e){if(!S.default.isSourceFile(r))return;let t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.getFullText(),n=t.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=t.exec(s)}function bi(r,e){if(S.default.isCallExpression(r)&&vi(r.expression))for(let t of r.arguments)S.default.isObjectLiteralExpression(t)&&ki(t,e)}function vi(r){return S.default.isIdentifier(r)?Ut.has(r.text):!!(S.default.isPropertyAccessExpression(r)&&(Ut.has(r.name.text)||S.default.isIdentifier(r.expression)&&Ut.has(r.expression.text)))}function ki(r,e){for(let t of r.properties){if(!S.default.isPropertyAssignment(t)||!S.default.isIdentifier(t.name)||t.name.text!=="tags"&&t.name.text!=="tag")continue;let{initializer:s}=t,n=S.default.isArrayLiteralExpression(s)?s.elements.filter(S.default.isStringLiteral):t.name.text==="tag"&&S.default.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function Kt(r,e,t){let s=[],n=new Map,o=new Set,i=l.default.createSourceFile(r,e,l.default.ScriptTarget.Latest,!0,t==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:r,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},p=de=>{Ei(de,a),l.default.forEachChild(de,p)};p(i);let c=ji(r,a);(c==="test"||c==="barrel")&&o.add({name:c,kind:"comment-marker"}),c!=="test"&&Li(a,i);let m=i.statements[0],g=m?us(m):void 0,{complexity:h,cognitiveComplexity:b}=Bt(i),M=wi(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:c,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:b,...M.length>0?{functions:M}:{},...g!==void 0?{description:g}:{}}}function wi(r){let e=[],t=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Bt(o),p=r.getLineAndCharacterOfPosition(o.getStart(r)).line+1;e.push({name:n,line:p,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?t(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))?t(n.name.text,n.initializer):o&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?t(`${o}.${n.name.text}`,n):o&&l.default.isConstructorDeclaration(n)&&n.body?t(`${o}.constructor`,n):o&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?t(`${o}.get ${n.name.text}`,n):o&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&t(`${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(r,void 0),e}function ls(r,e,t,s){let n={name:r},o=us(t);o!==void 0&&(n.doc=o);let i=Ci(e);i!==void 0&&(n.flags=i);let a=Fi(e,s);return a!==void 0&&(n.signature=a),n}function us(r){let e=l.default.getJSDocCommentsAndTags(r);for(let t of e)if(l.default.isJSDoc(t)&&t.comment)return l.default.getTextOfJSDocComment(t.comment)||void 0}function Ci(r){let e=new Set(["deprecated","internal","public","alpha","beta"]),t=l.default.getJSDocTags(r).map(s=>s.tagName.text).filter(s=>e.has(s));return t.length>0?t:void 0}function Fi(r,e){let t=l.default.createPrinter({removeComments:!0}),s=n=>t.printNode(l.default.EmitHint.Unspecified,n,e);if(l.default.isFunctionDeclaration(r)||l.default.isMethodDeclaration(r)){let n=r.parameters.map(s).join(", "),o=r.type?s(r.type):"void";return`${r.typeParameters?`<${r.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(l.default.isVariableDeclaration(r)){if(r.type)return s(r.type);if(r.initializer&&(l.default.isArrowFunction(r.initializer)||l.default.isFunctionExpression(r.initializer))){let n=r.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(l.default.isClassDeclaration(r)&&r.name)return`class ${r.name.text}`;if(l.default.isInterfaceDeclaration(r))return`interface ${r.name.text}`;if(l.default.isTypeAliasDeclaration(r))return s(r.type);if(l.default.isEnumDeclaration(r))return`enum ${r.name.text}`}function Ei(r,e){Ti(r,e),Pi(r,e),Ii(r,e),Mi(r,e),_i(r,e),cs(r,e)}function Ti(r,e){if(!l.default.isSourceFile(r))return;let t=r.statements.filter(s=>!l.default.isEmptyStatement(s));e.totalStatements=t.length,e.exportStatements=t.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||Jt(s)).length}function Pi(r,e){if(l.default.isJsxElement(r)||l.default.isJsxSelfClosingElement(r)||l.default.isJsxFragment(r)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(r)||l.default.isMethodDeclaration(r)||l.default.isArrowFunction(r)||l.default.isClassDeclaration(r)||l.default.isVariableStatement(r)||l.default.isEnumDeclaration(r)){e.hasTypesOnly=!1;return}l.default.isExportDeclaration(r)&&!Ai(r)&&(e.hasTypesOnly=!1)}function Ai(r){return r.isTypeOnly?!0:!r.exportClause||!l.default.isNamedExports(r.exportClause)?!1:r.exportClause.elements.every(e=>e.isTypeOnly)}function Ii(r,e){if(!l.default.isImportDeclaration(r)||!r.moduleSpecifier||!l.default.isStringLiteral(r.moduleSpecifier))return;let t=[];if(r.importClause&&(r.importClause.name&&t.push("default"),r.importClause.namedBindings))if(l.default.isNamedImports(r.importClause.namedBindings))for(let n of r.importClause.namedBindings.elements)t.push(n.name.text);else l.default.isNamespaceImport(r.importClause.namedBindings)&&t.push("*");let s=t.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.moduleSpecifier.text,isStyle:F(r.moduleSpecifier.text),type:s,symbols:t.length>0?t:void 0})}function Mi(r,e){l.default.isExportDeclaration(r)?Ri(r,e):l.default.isExportAssignment(r)?e.exports.set("default",{name:"default"}):Jt(r)&&Di(r,e)}function Ri(r,e){if(r.moduleSpecifier&&l.default.isStringLiteral(r.moduleSpecifier))Ni(r,r.moduleSpecifier.text,e);else if(r.exportClause&&l.default.isNamedExports(r.exportClause))for(let t of r.exportClause.elements){let s=t.name.text;e.exports.set(s,{name:s})}}function Ni(r,e,t){let s=Gi(r),n={fromPath:t.filePath,toPath:"",rawSpecifier:e,isStyle:F(e),type:"re-export"};s.length>0&&(n.symbols=s),t.imports.push(n)}function Gi(r){return r.exportClause?l.default.isNamedExports(r.exportClause)?r.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Di(r,e){if((l.default.isFunctionDeclaration(r)||l.default.isClassDeclaration(r)||l.default.isInterfaceDeclaration(r)||l.default.isTypeAliasDeclaration(r)||l.default.isEnumDeclaration(r))&&r.name){let s=r.name.text;e.exports.set(s,ls(s,r,r,e.sourceFile));return}if(l.default.isVariableStatement(r)){for(let s of r.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,ls(n,s,r,e.sourceFile))}}}function _i(r,e){if(!l.default.isCallExpression(r))return;let t=r.arguments[0];!t||!l.default.isStringLiteral(t)||(r.expression.kind===l.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:F(t.text),type:"dynamic"}):l.default.isIdentifier(r.expression)&&r.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:F(t.text),type:"require"}))}function ji(r,e){let t=qt.default.basename(r).toLowerCase(),s=qt.default.extname(r).toLowerCase();return V().some(o=>t.includes(o))?"test":nr(t)?"config":e.imports.some(o=>qe().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>Je()?"barrel":"logic"}function Jt(r){return l.default.canHaveModifiers(r)&&l.default.getModifiers(r)?.some(e=>e.kind===l.default.SyntaxKind.ExportKeyword)===!0}function Li(r,e){let t=r.rawCallEdges??[];r.rawCallEdges=t;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=Wi(n);if(o){let i=zi(n);i&&je(i,o,s,t);continue}l.default.isClassDeclaration(n)&&n.name&&Oi(n,s,t)}}function Oi(r,e,t){let s=r.name.text;for(let n of r.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?je(n.body,`${s}.${n.name.text}`,e,t):l.default.isConstructorDeclaration(n)&&n.body&&je(n.body,`${s}.constructor`,e,t)}function Wi(r){if(Jt(r)){if(l.default.isFunctionDeclaration(r)&&r.name)return r.name.text;if(l.default.isVariableStatement(r)){for(let e of r.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 zi(r){if(l.default.isFunctionDeclaration(r))return r.body;if(l.default.isVariableStatement(r)){for(let e of r.declarationList.declarations)if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.initializer}}function je(r,e,t,s){if(l.default.isCallExpression(r)&&l.default.isIdentifier(r.expression)){let n=r.expression.text,o=t.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(r,n=>je(n,e,t,s))}function Le(r,e){if(e.length===0)return"ui";let t=!1;return r.walk(s=>{if(s.type==="rule")return t=!0,!1}),t?"ui":"barrel"}var Ht=f(require("postcss")),$i=f(require("postcss-less")),Bi=$i,gs=new Set(["reference","inline"]);function fs(r){return r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("data:")}function Ui(r){let e=r.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function qi(r,e){let t=r.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(t){let o=t[1]?.trim()??"",i=t[2]??"";if(!i)return null;let a=gs.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...fs(i)?{isExternal:!0}:{}}}let s=r.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":r.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...fs(n)?{isExternal:!0}:{}}:null}function Ki(r,e){let t=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"";Ui(o)&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(r)}return t}function ms(r,e){let t=[];return r.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=qi(s.params,e);n&&t.push(n)}s.type==="decl"&&t.push(...Ki(s.value,e))}),t}function Ji(r){return r.replace(/(?<!:)\/\/.*/g,"")}function Hi(r,e){let t=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=gs.has(o)?"side-effect":"static";t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(r)}return t}function ds(r,e){let t=Ht.default.parse(Ji(r));return{imports:ms(t,e),root:t}}function hs(r,e){try{let t=Bi.parse(r);return{imports:ms(t,e),root:t}}catch{return{imports:Hi(r,e),root:Ht.default.parse("")}}}var ys=require("postcss-scss");function Qi(r){return!!(r.startsWith("sass:")||r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||!r.startsWith(".")&&!r.startsWith("/")&&!r.startsWith("_"))}function Vi(r){let e=r.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let t=e[1],n=r.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:t,alias:n}:{specifier:t}}function xs(r,e){let t=(0,ys.parse)(r),s=[];return t.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}=Vi(i);if(!a)return;let c={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...Qi(a)?{isExternal:!0}:{}};p&&(c.symbols=[p]),s.push(c)}),{imports:s,root:t}}function Ss(r,e){let t=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(r)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(r);n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(r)}return t}function bs(r,e){if(e.length===0)return"ui";try{let t=require("stylus");return new t.Parser(r).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return r.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function ae(r,e){let t=I(r);if(t==="stylus"){let o=Ss(e,r);return{imports:o,exports:[],tags:[],category:bs(e,o)}}if(t==="scss"){let{imports:o,root:i}=xs(e,r);return{imports:o,exports:[],tags:[],category:Le(i,o)}}if(t==="less"){let{imports:o,root:i}=hs(e,r);return{imports:o,exports:[],tags:[],category:Le(i,o)}}let{imports:s,root:n}=ds(e,r);return{imports:s,exports:[],tags:[],category:Le(n,s)}}for(let[r,e]of[["javascript",(t,s)=>Kt(t,s,"javascript")],["typescript",(t,s)=>Kt(t,s,"typescript")],["css",ae],["scss",ae],["less",ae],["stylus",ae],["coffeescript",Vr],["livescript",ss],["lua",os],["python",ps],["go",ts],["gherkin",zt]])O(r,e);async function vs(r,e){let t=I(r),s=Mr(t);return s?s(r,e):{imports:[],exports:[],tags:[],category:"other"}}var Qt=f(require("path"));function ws(r,e){for(let t of r.values()){let s=e.get(t.path);s!==void 0&&(t.coveragePct=s)}}function Cs(r,e){for(let t of r)if(t.isExternal){let s=t.rawSpecifier.startsWith("@")?t.rawSpecifier.split("/").slice(0,2).join("/"):t.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function Fs(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports){if(t.isExternal||!t.toPath)continue;let s=r.get(t.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function ks(r){return Math.round(r*1e4)/1e4}function Es(r){for(let e of r.values()){let t=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=r.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=ks(Math.min(1,o)),t.push(s.exportUsageRatio)}t.length>0&&(e.avgExportUsage=ks(t.reduce((s,n)=>s+n,0)/t.length),e.maxExportUsage=Math.max(...t))}}function Vt(r,e,t){e&&(r.some(s=>s.name===e&&s.kind===t)||r.push({name:e,kind:t}))}function Xi(r,e){let t=e.toPath,s=Qt.default.basename(t,Qt.default.extname(t)).replace(/\.(test|spec)$/,"");Vt(r.tags,s,"import")}function Zi(r,e){if(!(!e.symbols||e.symbols.includes("*")))for(let t of e.symbols)Vt(r.tags,t,"import")}function Yi(r,e,t){let s=t.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&Vt(r.tags,n.name,"comment-marker")}function Ts(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports)!t.toPath||t.isExternal||(Xi(e,t),Zi(e,t),Yi(e,t,r))}var fe=f(require("fs")),P=f(require("path"));var Xt=f(require("fs")),D=f(require("path")),pe=class{extensions=[".go"];goModCache=new Map;resolve(e,t,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(t,i,s);if(a!==void 0)return As(a);if(t!==o&&!t.startsWith(`${o}/`))return null;let p=t.slice(o.length).replace(/^\//,"");return p?As(D.default.join(s,p)):null}readGoMod(e){let t=this.goModCache.get(e);if(t!==void 0)return t;let s={mod:null,replaces:new Map};try{let n=Xt.default.readFileSync(D.default.join(e,"go.mod"),"utf-8"),o=ea(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,t,s){for(let[n,o]of t){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return D.default.join(o,i)}}}};function ea(r,e){let t=r.split(`
23
- `),s=null,n=new Map,o=!1;for(let i of t){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("=>")){Ps(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&Ps(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function Ps(r,e,t){let[s,n]=r.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=D.default.isAbsolute(n)?n:D.default.resolve(e,n);t.set(o,i)}function As(r){let e;try{e=Xt.default.readdirSync(r,{withFileTypes:!0})}catch{return null}let t=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:D.default.join(r,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return t.length>0?t:null}var Is=f(require("fs")),Oe=f(require("path")),ce=class{extensions=[".lua"];resolve(e,t,s,n){let o=t.replace(/\./g,Oe.default.sep),i=[s,Oe.default.join(s,"lib")];for(let a of i){if(!Is.default.existsSync(a))continue;let p=n(Oe.default.join(a,"_dummy.lua"),o);if(p)return[p]}return null}};var Rs=f(require("fs")),We=f(require("path")),le=class{extensions=[".py"];resolve(e,t,s,n){let o=t.replace(/\./g,We.default.sep),i=We.default.join(s,`${o}.py`);if(Ms(i))return[{path:i,isExternal:!1}];let a=We.default.join(s,o,"__init__.py");return Ms(a)?[{path:a,isExternal:!1}]:null}};function Ms(r){try{return Rs.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Zt=f(require("path")),ta=["~","http://","https://","//","data:","sass:"],ue=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,t,s,n){if(ta.some(m=>t.startsWith(m)))return null;let o=n(e,t);if(o)return[o];let i=Zt.default.dirname(t),a=Zt.default.basename(t),p=i==="."?`_${a}`:`${i}/_${a}`,c=n(e,p);return c?[c]:null}};var H=class{constructor(e,t={}){this.rootDir=e;this.workspaceMap=t.workspaceMap??new Map,this.tsconfigSearchPaths=t.tsconfigSearchPaths??[e],this.langResolvers=t.langResolvers??[new le,new ce,new pe,new ue]}rootDir;workspaceMap;tsconfigSearchPaths;langResolvers;resolveAll(e,t){let s=this.resolvePathAlias(t);if(s)return[s];if(t.startsWith(".")||t.startsWith("/")){let i=this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(t);return o?[o]:[{path:t,isExternal:!0}]}resolve(e,t){let s=this.resolvePathAlias(t);if(s)return s;if(t.startsWith(".")||t.startsWith("/"))return this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(t);return o||{path:t,isExternal:!0}}resolveLocalPath(e,t){let s=P.default.dirname(e),n=t.startsWith("/")?t:P.default.resolve(s,t),o=!n.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature"],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,t,s){let n=e+t;if(this.isFile(n))return{path:n,isExternal:s};let o=P.default.join(e,`index${t}`);if(this.isFile(o))return{path:o,isExternal:s};if(t===".py"){let i=P.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return fe.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let t of this.tsconfigSearchPaths){let s=P.default.join(t,"tsconfig.json");if(fe.default.existsSync(s))try{let o=JSON.parse(fe.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]||"",t);if(p)return p}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,t){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return t.match(s)}tryAliasSubstitutions(e,t,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",t),a=P.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[t,s]of this.workspaceMap){if(e!==t&&!e.startsWith(`${t}/`))continue;let n=e.slice(t.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:t};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let p=P.default.join(s,a);try{if(fe.default.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(P.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var ra=["tests","test","__tests__","specs","spec"];function sa(r,e){if(r.length===0)return e;let t=r.map(i=>w.default.dirname(i).split(w.default.sep)),s=t[0];for(let i of t.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 me=class{constructor(e,t=null,s,n,o=!1,i=new Map){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.previousGraph=t,this.resolver=s||new H(e),this.lockFile=Hr(e),n&&(this.progressCallback=n)}rootDir;enableGitStats;coverageMap;graph={nodes:new Map};visited=new Set;previousGraph=null;resolver;lockFile=null;progressCallback;async build(e){let t=e.map(s=>w.default.isAbsolute(s)?s:w.default.resolve(this.rootDir,s));for(let s of t)await this.processFile(s);return await this.processTestFiles(sa(t,this.rootDir)),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
18
+ `+m}};function Wo(r){let e=r.split(`
19
+ `),t=-1;for(let n=0;n<e.length;n++){let o=e[n].trimStart();(o.startsWith("import ")||o.startsWith("from "))&&(t=n)}if(t<0)return 0;let s=0;for(let n=0;n<=t;n++)s+=e[n].length+1;return s}var Dt=f(require("path")),Gt=f(require("typescript"));var zo=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,De=class{name="vitest";canHandle(e){return E.has(Dt.default.extname(e).toLowerCase())}apply(e,t,s){let n=t.replace(zo,""),o=Gt.default.createSourceFile(Dt.default.basename(e),n,Gt.default.ScriptTarget.Latest,!0),i=W(o);if(i.length===0)return n;let a=z(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?B(m,"tags",o):$(m,"tags",q(p),o);return g?[g]:[]});return c.length>0?U(n,c):n}};var $r={vitest:()=>new De,playwright:()=>new Re,cypress:()=>new Te,jest:()=>new Me},$o={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function Bo(r){let e=oe.default.createSourceFile("detect.ts",r,oe.default.ScriptTarget.Latest,!0);for(let t of e.statements){if(!oe.default.isImportDeclaration(t)||!oe.default.isStringLiteral(t.moduleSpecifier))continue;let s=$o[t.moduleSpecifier.text];if(s)return s}return null}var _t=class{constructor(e,t,s){this.rootDir=e;this.defaultFramework=t;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return E.has(Ge.default.extname(e).toLowerCase())}apply(e,t,s){let n=Bo(t)??this.matchOverride(e)??this.defaultFramework;return($r[n]??$r.vitest)().apply(e,t,s)}matchOverride(e){let t=Ge.default.relative(this.rootDir,e).split(Ge.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Or(s,t))return n;return null}};function Br(r="vitest",e={},t=process.cwd()){return[new Ae,new Ne,new Ie,new _t(t,r,Object.entries(e))]}function Ur(r,e){return e.find(t=>t.canHandle(r))??null}var Uo=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,qo=new Set(["import"]),Ko=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function Jo(r,e,t,s){let n;try{n=await jt.default.readFile(r,"utf8")}catch(a){return{path:r,status:"error",error:String(a)}}let o=Ur(r,s);if(!o)return{path:r,status:"unchanged"};let i=o.apply(r,n,e);return i===n?{path:r,status:"unchanged"}:(t||await jt.default.writeFile(r,i,"utf8"),{path:r,status:"updated"})}async function Ot(r,e,t){let s=Z(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=Br(n,o,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let p of r.nodes.values()){if(p.category!=="test")continue;let c=new Set,m=[];for(let b of p.tags)qo.has(b.kind)&&Uo.test(b.name)&&(Ko.has(b.name.toLowerCase())||c.has(b.name)||(c.add(b.name),m.push(b.name)));m.sort();let g=qr.default.resolve(e,p.path),h=await Jo(g,m,t.dryRun,i);h.path=p.path,a.files.push(h),h.status==="updated"?a.updated++:h.status==="unchanged"?a.unchanged++:a.errors++}return a}var _e=class{isTestNode(e){return e.category==="test"||e.tags.some(t=>t.name==="test")}};var Q=f(require("fs")),w=f(require("path")),Ws=f(require("piscina"));var je=require("child_process"),Oe=class{getChangedFiles(){try{let t=["git diff --name-only","git diff --cached --name-only","git ls-files --others --exclude-standard"].flatMap(s=>{try{return(0,je.execSync)(s,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
20
+ `).map(o=>o.trim()).filter(o=>o!=="")}catch{return[]}});return Array.from(new Set(t))}catch(e){return console.error("Error getting git diff:",e),[]}}};function Kr(r,e){let s=(0,je.execSync)(`git -C "${r}" log --follow --format="%ae" --since="90 days ago" -- "${e}"`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
21
+ `).filter(Boolean),n=(0,je.execSync)(`git -C "${r}" log -1 --format="%at" -- "${e}"`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return{commitCount90d:s.length,lastAuthor:s[0],lastCommitAt:n?Number(n)*1e3:void 0}}var ie=f(require("fs")),Jr=f(require("path")),Lt=f(require("js-yaml"));function Hr(r){let e=r.lastIndexOf("@");return e>0?r.substring(0,e):r}function Ho(r){return r.replace(/:$/,"").split(",").map(e=>{let t=e.trim();return t.startsWith('"')&&(t=t.slice(1)),t.endsWith('"')&&(t=t.slice(0,-1)),Hr(t)}).filter(Boolean)}function Qo(r,e){let t=r.startsWith("/")?r.slice(1):r,s=t.lastIndexOf("@");return s>0?{name:t.substring(0,s),version:e||t.substring(s+1)}:{name:t,version:e}}function Vo(r){try{let e=Lt.default.load(r),t={dependencies:{}};for(let[s,n]of Object.entries(e))if(!(s==="__metadata"||!n?.version))for(let o of s.split(", ")){let i=Hr(o);i&&(t.dependencies[i]={version:n.version,...n.dependencies!==void 0&&{dependencies:n.dependencies}})}return t}catch{return null}}function Xo(r){let e={dependencies:{}};for(let t of r.split(/\n\n+/)){let s=t.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=Ho(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 Zo(r){let e=ie.default.readFileSync(r,"utf-8"),t=JSON.parse(e),s={dependencies:{}};if(t.packages)for(let[n,o]of Object.entries(t.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(t.dependencies)for(let[n,o]of Object.entries(t.dependencies))s.dependencies[n]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}};return s}function Yo(r){let e=ie.default.readFileSync(r,"utf-8");if(e.includes("__metadata:")){let t=Vo(e);if(t!==null)return t}return Xo(e)}function ei(r){let e=ie.default.readFileSync(r,"utf-8"),t={dependencies:{}};try{let s=Lt.default.load(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Qo(n,o.version);i&&(t.dependencies[i]={version:a,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}if(s.dependencies)for(let[n,o]of Object.entries(s.dependencies)){if(t.dependencies[n])continue;let i=typeof o=="string"?o:o.version;t.dependencies[n]={version:i||""}}}catch{}return t}function Qr(r){let e=[["package-lock.json",Zo],["yarn.lock",Yo],["pnpm-lock.yaml",ei]];for(let[t,s]of e){let n=Jr.default.join(r,t);if(ie.default.existsSync(n))return s(n)}return null}var Wt=f(require("path"));function I(r){switch(Wt.default.extname(r).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(r){let e=Wt.default.extname(r).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var Vr=f(require("coffeescript"));function ti(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ri(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function si(r,e){let t=e.source?.value;return t?{fromPath:r,toPath:"",rawSpecifier:t,isStyle:F(t),type:"static"}:null}function ni(r,e){let t=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!t||!s?null:{fromPath:r,toPath:"",rawSpecifier:s,isStyle:F(s),type:"require"}}function oi(r,e,t){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=si(r,e);n&&t.push(n)}else if(s==="Call"){let n=ni(r,e);n&&t.push(n)}}function zt(r,e,t){if(!(!e||typeof e!="object")){oi(r,e,t);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)zt(r,o,t);else zt(r,n,t)}}}function Xr(r,e){let t=ti(e),s=ri(r,t),n=[];try{zt(r,Vr.default.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var K=require("@cucumber/gherkin"),Zr=require("@cucumber/messages");var ii=Zr.IdGenerator.uuid();function $t(r,e){let t=new Set;try{let s=new K.AstBuilder(ii),n=new K.GherkinClassicTokenMatcher,i=new K.Parser(s,n).parse(e);i.feature&&(i.feature.tags.forEach(a=>{t.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(p=>{t.add(p.name.startsWith("@")?p.name.slice(1):p.name)}),a.scenario.examples.forEach(p=>{p.tags.forEach(c=>{t.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})),a.rule&&a.rule.children.forEach(p=>{p.scenario&&p.scenario.tags.forEach(c=>{t.add(c.name.startsWith("@")?c.name.slice(1):c.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${r}:`,s)}return{imports:[],exports:[],tags:Array.from(t).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}L("gherkin",$t);var es=f(require("path")),ts=require("@lezer/go"),ai=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,pi=/^\/\/go:build\s+(.+)$/,ci=/^\/\/\s*\+build\s+(.+)$/;function rs(r,e){let t=[],s=new Map,n=new Set,o=new Set,a=ts.parser.parse(e).cursor();do switch(a.name){case"LineComment":{let g=e.slice(a.from,a.to),h=g.match(ai);h?.[1]&&n.add(h[1]);let b=g.match(pi);b&&Yr(b[1],o);let M=g.match(ci);M&&Yr(M[1],o);break}case"ImportSpec":{let g=a.node.getChild("String");if(g){let b=e.slice(g.from,g.to).slice(1,-1);t.push({fromPath:r,toPath:"",rawSpecifier:b,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 h=e.slice(g.from,g.to);h!=="_"&&/^[A-Z]/.test(h)&&!s.has(h)&&s.set(h,{name:h})}break}}while(a.next());let p=t.some(g=>g.rawSpecifier==="testing"),c=es.default.basename(r).endsWith("_test.go")||n.has("test")||p?"test":"logic",m=new Set([...n,...o]);return{imports:t,exports:Array.from(s.values()),tags:Array.from(m).map(g=>({name:g,kind:"comment-marker"})),category:c}}function Yr(r,e){for(let t of r.split(/[\s,&|!()]+/)){let s=t.trim();s&&s!=="ignore"&&e.add(s)}}var ss=f(require("livescript"));function J(r){return r.startsWith("'")||r.startsWith('"')?r.slice(1,-1):r}function li(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function ui(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}var fi=new Set(["first_line","first_column","last_line","last_column","line","column"]);function gi(r,e){let t=r.constructor?.name||r.type;if(t==="Import"){let s=r.right?.value;if(typeof s=="string"){let n=J(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:F(n),type:"static"}}}if(t==="Chain"&&r.head?.value==="require"){let s=r.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let n=s.args?.[0]?.value;if(typeof n=="string"){let o=J(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:F(o),type:"require"}}}}return null}function Bt(r,e){if(!r||typeof r!="object")return[];let t=[],s=gi(r,e);s&&t.push(s);for(let n in r){if(fi.has(n))continue;let o=r[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)t.push(...Bt(i,e));else t.push(...Bt(o,e))}return t}function ns(r,e){let t=li(e),s=ui(r,t),n=[];try{n=Bt(ss.default.ast(e),r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var os=f(require("luaparse"));function mi(r){let e=new Set,t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.exec(r);for(;s!==null;)s[1]&&e.add(s[1]),s=t.exec(r);return e}function di(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function hi(r,e){let t=[];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=J(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=J(i.raw))}o&&t.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(r),t}function is(r,e){let t=mi(e),s=di(r,t),n=[];try{let o=os.default.parse(e);n=hi(o,r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var yi=["http://","https://","mailto:","//"],xi="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Si=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${xi})\\b`,"g"),as;async function bi(){return as??=(async()=>{let{unified:r}=await import("unified"),e=(await import("remark-parse")).default;return r().use(e)})(),as}function vi(r){let e=r.trim();return e.length===0||e.startsWith("#")||yi.some(t=>e.startsWith(t))}function ki(r,e){let t=r.match(Si);return t?t.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function ps(r,e,t){if(r.type==="link"&&typeof r.url=="string"&&!vi(r.url)&&t.push({fromPath:e,toPath:"",rawSpecifier:r.url,isStyle:!1,type:"static"}),(r.type==="code"||r.type==="inlineCode")&&typeof r.value=="string"&&t.push(...ki(r.value,e)),Array.isArray(r.children))for(let s of r.children)ps(s,e,t)}async function cs(r,e){let s=(await bi()).parse(e),n=[];ps(s,r,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 ls=f(require("path")),us=require("@lezer/python"),wi=new Set(["pytest","unittest","nose","hypothesis"]);function fs(r,e){let t=[],s=[],n=new Set,o=ls.default.basename(r).toLowerCase(),a=us.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 Ci(a.node,e,r))t.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=Ti(o,t,n);return p==="test"&&n.add("test"),{imports:t,exports:s,tags:Array.from(n).map(c=>({name:c,kind:"comment-marker"})),category:p}}function Ci(r,e,t){let s=r.firstChild;return s?s.name==="from"?Fi(r,e,t):Ei(r,e,t):[]}function Fi(r,e,t){let s=r.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=Pi(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[ae(t,o,i,!0)];let c=a===1?"./":"../".repeat(a-1);return p?[ae(t,c+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[ae(t,c.slice(0,-1),["*"],!1)]:i.map(m=>ae(t,c+m,[m],!1))}function Ei(r,e,t){let s=[],n=r.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(ae(t,o,["*"],!0))}n=n.nextSibling}return s}function Pi(r,e){let t=[],s=r;for(;s;)s.name==="*"?t.push("*"):s.name==="VariableName"&&(t.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return t}function ae(r,e,t,s){return{fromPath:r,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:t.length>0?t:void 0}}function Ti(r,e,t){return r.startsWith("test_")||r.endsWith("_test.py")?"test":r==="conftest.py"||r==="setup.py"?"config":t.has("test")||e.some(s=>wi.has(s.rawSpecifier))?"test":"logic"}var Kt=f(require("path")),l=f(require("typescript"));var d=f(require("typescript"));function Ai(r){let e=1;function t(s){switch(s.kind){case d.default.SyntaxKind.IfStatement:case d.default.SyntaxKind.ConditionalExpression:case d.default.SyntaxKind.ForStatement:case d.default.SyntaxKind.ForInStatement:case d.default.SyntaxKind.ForOfStatement:case d.default.SyntaxKind.WhileStatement:case d.default.SyntaxKind.DoStatement:case d.default.SyntaxKind.CatchClause:case d.default.SyntaxKind.CaseClause:e++;break;case d.default.SyntaxKind.BinaryExpression:{let n=s.operatorToken.kind;(n===d.default.SyntaxKind.AmpersandAmpersandToken||n===d.default.SyntaxKind.BarBarToken||n===d.default.SyntaxKind.QuestionQuestionToken)&&e++;break}}d.default.forEachChild(s,t)}return t(r),e}function Ii(r){let e=0;function t(s,n,o){if(d.default.isIfStatement(s)){e+=o?1:1+n;let a=o?n:n+1;t(s.expression,a,!1),t(s.thenStatement,a,!1),s.elseStatement&&(d.default.isIfStatement(s.elseStatement)?t(s.elseStatement,n,!0):(e+=1,t(s.elseStatement,n+1,!1)));return}if(d.default.isForStatement(s)||d.default.isForInStatement(s)||d.default.isForOfStatement(s)||d.default.isWhileStatement(s)||d.default.isDoStatement(s)||d.default.isSwitchStatement(s)){e+=1+n,d.default.forEachChild(s,a=>t(a,n+1,!1));return}if(d.default.isCatchClause(s)){e+=1+n,d.default.forEachChild(s,a=>t(a,n,!1));return}if(d.default.isConditionalExpression(s)&&(e+=1),d.default.isBinaryExpression(s)){let a=s.operatorToken.kind;(a===d.default.SyntaxKind.AmpersandAmpersandToken||a===d.default.SyntaxKind.BarBarToken||a===d.default.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(n>0&&(d.default.isFunctionDeclaration(s)||d.default.isFunctionExpression(s)||d.default.isArrowFunction(s))){e+=1+n,d.default.forEachChild(s,a=>t(a,n+1,!1));return}d.default.forEachChild(s,a=>t(a,n,!1))}return t(r,0,!1),e}function Ut(r){return{complexity:Ai(r),cognitiveComplexity:Ii(r)}}var S=f(require("typescript")),qt=new Set(["test","describe","it"]);function gs(r,e){Mi(r,e),Ni(r,e),Di(r,e),Gi(r,e)}function Mi(r,e){if((S.default.isFunctionDeclaration(r)||S.default.isVariableDeclaration(r))&&r.name&&S.default.isIdentifier(r.name)&&Ri(r)){let t;if(S.default.isFunctionDeclaration(r))t="function";else{let s=r.initializer;t=s&&(S.default.isArrowFunction(s)||S.default.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:r.name.text,kind:t})}}function Ri(r){if(S.default.isFunctionDeclaration(r))return S.default.isSourceFile(r.parent);let e=r.parent?.parent;return!!e&&S.default.isSourceFile(e.parent)}function Ni(r,e){if(!S.default.isStringLiteral(r))return;let t=r.text.match(/@[\w-]+/g);if(t)for(let s of t)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function Di(r,e){if(!S.default.isSourceFile(r))return;let t=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.getFullText(),n=t.exec(s);for(;n!==null;)n[1]&&e.tags.add({name:n[1],kind:"comment-marker"}),n=t.exec(s)}function Gi(r,e){if(S.default.isCallExpression(r)&&_i(r.expression))for(let t of r.arguments)S.default.isObjectLiteralExpression(t)&&ji(t,e)}function _i(r){return S.default.isIdentifier(r)?qt.has(r.text):!!(S.default.isPropertyAccessExpression(r)&&(qt.has(r.name.text)||S.default.isIdentifier(r.expression)&&qt.has(r.expression.text)))}function ji(r,e){for(let t of r.properties){if(!S.default.isPropertyAssignment(t)||!S.default.isIdentifier(t.name)||t.name.text!=="tags"&&t.name.text!=="tag")continue;let{initializer:s}=t,n=S.default.isArrayLiteralExpression(s)?s.elements.filter(S.default.isStringLiteral):t.name.text==="tag"&&S.default.isStringLiteral(s)?[s]:[];for(let o of n)e.tags.add({name:o.text.replace(/^@/,""),kind:"comment-marker"})}}function Jt(r,e,t){let s=[],n=new Map,o=new Set,i=l.default.createSourceFile(r,e,l.default.ScriptTarget.Latest,!0,t==="typescript"?l.default.ScriptKind.TSX:l.default.ScriptKind.JSX),a={filePath:r,imports:s,exports:n,tags:o,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},p=he=>{zi(he,a),l.default.forEachChild(he,p)};p(i);let c=Zi(r,a);(c==="test"||c==="barrel")&&o.add({name:c,kind:"comment-marker"}),c!=="test"&&Yi(a,i);let m=i.statements[0],g=m?ds(m):void 0,{complexity:h,cognitiveComplexity:b}=Ut(i),M=Oi(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:c,rawCallEdges:a.rawCallEdges??[],complexity:h,cognitiveComplexity:b,...M.length>0?{functions:M}:{},...g!==void 0?{description:g}:{}}}function Oi(r){let e=[],t=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Ut(o),p=r.getLineAndCharacterOfPosition(o.getStart(r)).line+1;e.push({name:n,line:p,complexity:i,cognitiveComplexity:a})},s=(n,o)=>{if(l.default.isFunctionDeclaration(n)&&n.name&&n.body?t(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))?t(n.name.text,n.initializer):o&&l.default.isMethodDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?t(`${o}.${n.name.text}`,n):o&&l.default.isConstructorDeclaration(n)&&n.body?t(`${o}.constructor`,n):o&&l.default.isGetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body?t(`${o}.get ${n.name.text}`,n):o&&l.default.isSetAccessorDeclaration(n)&&l.default.isIdentifier(n.name)&&n.body&&t(`${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(r,void 0),e}function ms(r,e,t,s){let n={name:r},o=ds(t);o!==void 0&&(n.doc=o);let i=Li(e);i!==void 0&&(n.flags=i);let a=Wi(e,s);return a!==void 0&&(n.signature=a),n}function ds(r){let e=l.default.getJSDocCommentsAndTags(r);for(let t of e)if(l.default.isJSDoc(t)&&t.comment)return l.default.getTextOfJSDocComment(t.comment)||void 0}function Li(r){let e=new Set(["deprecated","internal","public","alpha","beta"]),t=l.default.getJSDocTags(r).map(s=>s.tagName.text).filter(s=>e.has(s));return t.length>0?t:void 0}function Wi(r,e){let t=l.default.createPrinter({removeComments:!0}),s=n=>t.printNode(l.default.EmitHint.Unspecified,n,e);if(l.default.isFunctionDeclaration(r)||l.default.isMethodDeclaration(r)){let n=r.parameters.map(s).join(", "),o=r.type?s(r.type):"void";return`${r.typeParameters?`<${r.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${n}) => ${o}`}if(l.default.isVariableDeclaration(r)){if(r.type)return s(r.type);if(r.initializer&&(l.default.isArrowFunction(r.initializer)||l.default.isFunctionExpression(r.initializer))){let n=r.initializer,o=n.parameters.map(s).join(", "),i=n.type?s(n.type):"unknown";return`(${o}) => ${i}`}return}if(l.default.isClassDeclaration(r)&&r.name)return`class ${r.name.text}`;if(l.default.isInterfaceDeclaration(r))return`interface ${r.name.text}`;if(l.default.isTypeAliasDeclaration(r))return s(r.type);if(l.default.isEnumDeclaration(r))return`enum ${r.name.text}`}function zi(r,e){$i(r,e),Bi(r,e),qi(r,e),Ki(r,e),Xi(r,e),gs(r,e)}function $i(r,e){if(!l.default.isSourceFile(r))return;let t=r.statements.filter(s=>!l.default.isEmptyStatement(s));e.totalStatements=t.length,e.exportStatements=t.filter(s=>l.default.isExportDeclaration(s)||l.default.isExportAssignment(s)||Ht(s)).length}function Bi(r,e){if(l.default.isJsxElement(r)||l.default.isJsxSelfClosingElement(r)||l.default.isJsxFragment(r)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(l.default.isFunctionDeclaration(r)||l.default.isMethodDeclaration(r)||l.default.isArrowFunction(r)||l.default.isClassDeclaration(r)||l.default.isVariableStatement(r)||l.default.isEnumDeclaration(r)){e.hasTypesOnly=!1;return}l.default.isExportDeclaration(r)&&!Ui(r)&&(e.hasTypesOnly=!1)}function Ui(r){return r.isTypeOnly?!0:!r.exportClause||!l.default.isNamedExports(r.exportClause)?!1:r.exportClause.elements.every(e=>e.isTypeOnly)}function qi(r,e){if(!l.default.isImportDeclaration(r)||!r.moduleSpecifier||!l.default.isStringLiteral(r.moduleSpecifier))return;let t=[];if(r.importClause&&(r.importClause.name&&t.push("default"),r.importClause.namedBindings))if(l.default.isNamedImports(r.importClause.namedBindings))for(let n of r.importClause.namedBindings.elements)t.push(n.name.text);else l.default.isNamespaceImport(r.importClause.namedBindings)&&t.push("*");let s=t.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.moduleSpecifier.text,isStyle:F(r.moduleSpecifier.text),type:s,symbols:t.length>0?t:void 0})}function Ki(r,e){l.default.isExportDeclaration(r)?Ji(r,e):l.default.isExportAssignment(r)?e.exports.set("default",{name:"default"}):Ht(r)&&Vi(r,e)}function Ji(r,e){if(r.moduleSpecifier&&l.default.isStringLiteral(r.moduleSpecifier))Hi(r,r.moduleSpecifier.text,e);else if(r.exportClause&&l.default.isNamedExports(r.exportClause))for(let t of r.exportClause.elements){let s=t.name.text;e.exports.set(s,{name:s})}}function Hi(r,e,t){let s=Qi(r),n={fromPath:t.filePath,toPath:"",rawSpecifier:e,isStyle:F(e),type:"re-export"};s.length>0&&(n.symbols=s),t.imports.push(n)}function Qi(r){return r.exportClause?l.default.isNamedExports(r.exportClause)?r.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Vi(r,e){if((l.default.isFunctionDeclaration(r)||l.default.isClassDeclaration(r)||l.default.isInterfaceDeclaration(r)||l.default.isTypeAliasDeclaration(r)||l.default.isEnumDeclaration(r))&&r.name){let s=r.name.text;e.exports.set(s,ms(s,r,r,e.sourceFile));return}if(l.default.isVariableStatement(r)){for(let s of r.declarationList.declarations)if(l.default.isIdentifier(s.name)){let n=s.name.text;e.exports.set(n,ms(n,s,r,e.sourceFile))}}}function Xi(r,e){if(!l.default.isCallExpression(r))return;let t=r.arguments[0];!t||!l.default.isStringLiteral(t)||(r.expression.kind===l.default.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:F(t.text),type:"dynamic"}):l.default.isIdentifier(r.expression)&&r.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:F(t.text),type:"require"}))}function Zi(r,e){let t=Kt.default.basename(r).toLowerCase(),s=Kt.default.extname(r).toLowerCase();return X().some(o=>t.includes(o))?"test":or(t)?"config":e.imports.some(o=>Je().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>Qe()?"barrel":"logic"}function Ht(r){return l.default.canHaveModifiers(r)&&l.default.getModifiers(r)?.some(e=>e.kind===l.default.SyntaxKind.ExportKeyword)===!0}function Yi(r,e){let t=r.rawCallEdges??[];r.rawCallEdges=t;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=ta(n);if(o){let i=ra(n);i&&Le(i,o,s,t);continue}l.default.isClassDeclaration(n)&&n.name&&ea(n,s,t)}}function ea(r,e,t){let s=r.name.text;for(let n of r.members)l.default.isMethodDeclaration(n)&&n.body&&l.default.isIdentifier(n.name)?Le(n.body,`${s}.${n.name.text}`,e,t):l.default.isConstructorDeclaration(n)&&n.body&&Le(n.body,`${s}.constructor`,e,t)}function ta(r){if(Ht(r)){if(l.default.isFunctionDeclaration(r)&&r.name)return r.name.text;if(l.default.isVariableStatement(r)){for(let e of r.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 ra(r){if(l.default.isFunctionDeclaration(r))return r.body;if(l.default.isVariableStatement(r)){for(let e of r.declarationList.declarations)if(e.initializer&&(l.default.isArrowFunction(e.initializer)||l.default.isFunctionExpression(e.initializer)))return e.initializer}}function Le(r,e,t,s){if(l.default.isCallExpression(r)&&l.default.isIdentifier(r.expression)){let n=r.expression.text,o=t.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(r,n=>Le(n,e,t,s))}function We(r,e){if(e.length===0)return"ui";let t=!1;return r.walk(s=>{if(s.type==="rule")return t=!0,!1}),t?"ui":"barrel"}var Qt=f(require("postcss")),sa=f(require("postcss-less")),na=sa,ys=new Set(["reference","inline"]);function hs(r){return r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("data:")}function oa(r){let e=r.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function ia(r,e){let t=r.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(t){let o=t[1]?.trim()??"",i=t[2]??"";if(!i)return null;let a=ys.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...hs(i)?{isExternal:!0}:{}}}let s=r.match(/^url\(['"]?([^'")]+)['"]?\)/),n=s?s[1]?.trim()??"":r.match(/^['"]([^'"]+)['"]/)?.[1]??"";return n?{fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static",...hs(n)?{isExternal:!0}:{}}:null}function aa(r,e){let t=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"";oa(o)&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(r)}return t}function xs(r,e){let t=[];return r.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=ia(s.params,e);n&&t.push(n)}s.type==="decl"&&t.push(...aa(s.value,e))}),t}function pa(r){return r.replace(/(?<!:)\/\/.*/g,"")}function ca(r,e){let t=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"",i=n[2]??"";if(i){let a=ys.has(o)?"side-effect":"static";t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(r)}return t}function Ss(r,e){let t=Qt.default.parse(pa(r));return{imports:xs(t,e),root:t}}function bs(r,e){try{let t=na.parse(r);return{imports:xs(t,e),root:t}}catch{return{imports:ca(r,e),root:Qt.default.parse("")}}}var vs=require("postcss-scss");function la(r){return!!(r.startsWith("sass:")||r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||!r.startsWith(".")&&!r.startsWith("/")&&!r.startsWith("_"))}function ua(r){let e=r.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let t=e[1],n=r.match(/\bas\s+(\S+)/)?.[1];return n!==void 0?{specifier:t,alias:n}:{specifier:t}}function ks(r,e){let t=(0,vs.parse)(r),s=[];return t.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}=ua(i);if(!a)return;let c={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...la(a)?{isExternal:!0}:{}};p&&(c.symbols=[p]),s.push(c)}),{imports:s,root:t}}function ws(r,e){let t=[],s=/@require\s+['"]([^'"]+)['"]/g,n=s.exec(r);for(;n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),n=s.exec(r)}let o=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(n=o.exec(r);n!==null;){let i=n[1];i&&t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),n=o.exec(r)}return t}function Cs(r,e){if(e.length===0)return"ui";try{let t=require("stylus");return new t.Parser(r).parse().nodes.some(o=>o.constructor.name!=="Import")?"ui":"barrel"}catch{return r.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function pe(r,e){let t=I(r);if(t==="stylus"){let o=ws(e,r);return{imports:o,exports:[],tags:[],category:Cs(e,o)}}if(t==="scss"){let{imports:o,root:i}=ks(e,r);return{imports:o,exports:[],tags:[],category:We(i,o)}}if(t==="less"){let{imports:o,root:i}=bs(e,r);return{imports:o,exports:[],tags:[],category:We(i,o)}}let{imports:s,root:n}=Ss(e,r);return{imports:s,exports:[],tags:[],category:We(n,s)}}for(let[r,e]of[["javascript",(t,s)=>Jt(t,s,"javascript")],["typescript",(t,s)=>Jt(t,s,"typescript")],["css",pe],["scss",pe],["less",pe],["stylus",pe],["coffeescript",Xr],["livescript",ns],["lua",is],["python",fs],["go",rs],["gherkin",$t],["markdown",cs]])L(r,e);async function Fs(r,e){let t=I(r),s=Rr(t);return s?s(r,e):{imports:[],exports:[],tags:[],category:"other"}}var Vt=f(require("path"));function Ps(r,e){for(let t of r.values()){let s=e.get(t.path);s!==void 0&&(t.coveragePct=s)}}function Ts(r,e){for(let t of r)if(t.isExternal){let s=t.rawSpecifier.startsWith("@")?t.rawSpecifier.split("/").slice(0,2).join("/"):t.rawSpecifier.split("/")[0];s&&!e.some(n=>n.name===s)&&e.push({name:s,kind:"library"})}}function As(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports){if(t.isExternal||!t.toPath)continue;let s=r.get(t.toPath);s&&(s.category!=="logic"&&s.category!=="barrel"||(s.testedBy??=[],s.testedBy.includes(e.path)||s.testedBy.push(e.path)))}}function Is(r){for(let e of r.values())if(e.type==="markdown")for(let t of e.imports){if(t.isExternal||!t.toPath)continue;let s=r.get(t.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 Es(r){return Math.round(r*1e4)/1e4}function Ms(r){for(let e of r.values()){let t=[];for(let s of e.imports){if(s.isExternal||!s.toPath)continue;let n=r.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=Es(Math.min(1,o)),t.push(s.exportUsageRatio)}t.length>0&&(e.avgExportUsage=Es(t.reduce((s,n)=>s+n,0)/t.length),e.maxExportUsage=Math.max(...t))}}function Xt(r,e,t){e&&(r.some(s=>s.name===e&&s.kind===t)||r.push({name:e,kind:t}))}function fa(r,e){let t=e.toPath,s=Vt.default.basename(t,Vt.default.extname(t)).replace(/\.(test|spec)$/,"");Xt(r.tags,s,"import")}function ga(r,e){if(!(!e.symbols||e.symbols.includes("*")))for(let t of e.symbols)Xt(r.tags,t,"import")}function ma(r,e,t){let s=t.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&Xt(r.tags,n.name,"comment-marker")}function Rs(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports)!t.toPath||t.isExternal||(fa(e,t),ga(e,t),ma(e,t,r))}var me=f(require("fs")),T=f(require("path"));var Zt=f(require("fs")),G=f(require("path")),ce=class{extensions=[".go"];goModCache=new Map;resolve(e,t,s,n){let{mod:o,replaces:i}=this.readGoMod(s);if(!o)return null;let a=this.applyReplace(t,i,s);if(a!==void 0)return Ds(a);if(t!==o&&!t.startsWith(`${o}/`))return null;let p=t.slice(o.length).replace(/^\//,"");return p?Ds(G.default.join(s,p)):null}readGoMod(e){let t=this.goModCache.get(e);if(t!==void 0)return t;let s={mod:null,replaces:new Map};try{let n=Zt.default.readFileSync(G.default.join(e,"go.mod"),"utf-8"),o=da(n,e);return this.goModCache.set(e,o),o}catch{return this.goModCache.set(e,s),s}}applyReplace(e,t,s){for(let[n,o]of t){if(e===n)return o;if(e.startsWith(`${n}/`)){let i=e.slice(n.length+1);return G.default.join(o,i)}}}};function da(r,e){let t=r.split(`
23
+ `),s=null,n=new Map,o=!1;for(let i of t){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("=>")){Ns(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&Ns(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function Ns(r,e,t){let[s,n]=r.split("=>").map(a=>a.trim());if(!s||!n)return;let o=s.split(/\s+/)[0];if(!n.startsWith(".")&&!n.startsWith("/"))return;let i=G.default.isAbsolute(n)?n:G.default.resolve(e,n);t.set(o,i)}function Ds(r){let e;try{e=Zt.default.readdirSync(r,{withFileTypes:!0})}catch{return null}let t=e.filter(s=>s.isFile()&&s.name.endsWith(".go")&&!s.name.endsWith("_test.go")).map(s=>({path:G.default.join(r,s.name),isExternal:!1})).sort((s,n)=>s.path.localeCompare(n.path));return t.length>0?t:null}var Gs=f(require("fs")),ze=f(require("path")),le=class{extensions=[".lua"];resolve(e,t,s,n){let o=t.replace(/\./g,ze.default.sep),i=[s,ze.default.join(s,"lib")];for(let a of i){if(!Gs.default.existsSync(a))continue;let p=n(ze.default.join(a,"_dummy.lua"),o);if(p)return[p]}return null}};var _s=f(require("path")),ue=class{extensions=[".md",".mdx"];resolve(e,t,s,n){let o=n(_s.default.join(s,"_dummy"),`./${t}`);return o?[o]:null}};var Os=f(require("fs")),$e=f(require("path")),fe=class{extensions=[".py"];resolve(e,t,s,n){let o=t.replace(/\./g,$e.default.sep),i=$e.default.join(s,`${o}.py`);if(js(i))return[{path:i,isExternal:!1}];let a=$e.default.join(s,o,"__init__.py");return js(a)?[{path:a,isExternal:!1}]:null}};function js(r){try{return Os.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Yt=f(require("path")),ha=["~","http://","https://","//","data:","sass:"],ge=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,t,s,n){if(ha.some(m=>t.startsWith(m)))return null;let o=n(e,t);if(o)return[o];let i=Yt.default.dirname(t),a=Yt.default.basename(t),p=i==="."?`_${a}`:`${i}/_${a}`,c=n(e,p);return c?[c]:null}};var H=class{constructor(e,t={}){this.rootDir=e;this.workspaceMap=t.workspaceMap??new Map,this.tsconfigSearchPaths=t.tsconfigSearchPaths??[e],this.langResolvers=t.langResolvers??[new fe,new le,new ce,new ge,new ue]}rootDir;workspaceMap;tsconfigSearchPaths;langResolvers;resolveAll(e,t){let s=this.resolvePathAlias(t);if(s)return[s];if(t.startsWith(".")||t.startsWith("/")){let i=this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a}let o=this.resolveWorkspaceImport(t);return o?[o]:[{path:t,isExternal:!0}]}resolve(e,t){let s=this.resolvePathAlias(t);if(s)return s;if(t.startsWith(".")||t.startsWith("/"))return this.resolveLocalPath(e,t);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,t,this.rootDir,n);if(a)return a[0]??null}let o=this.resolveWorkspaceImport(t);return o||{path:t,isExternal:!0}}resolveLocalPath(e,t){let s=T.default.dirname(e),n=t.startsWith("/")?t:T.default.resolve(s,t),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,t,s){let n=e+t;if(this.isFile(n))return{path:n,isExternal:s};let o=T.default.join(e,`index${t}`);if(this.isFile(o))return{path:o,isExternal:s};if(t===".py"){let i=T.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return me.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let t of this.tsconfigSearchPaths){let s=T.default.join(t,"tsconfig.json");if(me.default.existsSync(s))try{let o=JSON.parse(me.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]||"",t);if(p)return p}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,t){let s=this.aliasRegexCache.get(e);if(!s){let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");s=new RegExp(`^${n}$`),this.aliasRegexCache.set(e,s)}return t.match(s)}tryAliasSubstitutions(e,t,s=this.rootDir){let n=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let o of e){let i=o.replace("*",t),a=T.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[t,s]of this.workspaceMap){if(e!==t&&!e.startsWith(`${t}/`))continue;let n=e.slice(t.length),o={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:t};if(!n){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let p=T.default.join(s,a);try{if(me.default.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(T.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var ya=["tests","test","__tests__","specs","spec"],Ls=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),xa=20;function Sa(r,e){if(r.length===0)return e;let t=r.map(i=>w.default.dirname(i).split(w.default.sep)),s=t[0];for(let i of t.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 de=class{constructor(e,t=null,s,n,o=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=o;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=t,this.resolver=s||new H(e),this.lockFile=Qr(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;async build(e){let t=e.map(s=>w.default.isAbsolute(s)?s:w.default.resolve(this.rootDir,s));await this.initPool();try{for(let s of t)this.enqueue(s);return await this.drain(),await this.processTestFiles(Sa(t,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
24
24
  Done. Total processed: ${this.visited.size} nodes.
25
- `),Ts(this.graph.nodes),Fs(this.graph.nodes),Es(this.graph.nodes),this.coverageMap.size>0&&ws(this.graph.nodes,this.coverageMap),new T(this.graph.nodes)}async processTestFiles(e){let t=V(),s=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),n=async i=>{let a;try{a=ge.default.readdirSync(i,{withFileTypes:!0})}catch{return}for(let p of a){let c=w.default.join(i,p.name);p.isDirectory()?s.has(p.name)||await n(c):p.isFile()&&t.some(m=>p.name.includes(m))&&await this.processFile(c)}};await n(e);let o=e;for(;o!==this.rootDir;){let i=w.default.dirname(o);if(i===o)break;for(let a of ra){let p=w.default.join(i,a);try{ge.default.statSync(p).isDirectory()&&await n(p)}catch{}}o=i}}async processFile(e){if(this.visited.has(e))return;this.visited.add(e),this.showProgress();let t=ge.default.statSync(e,{throwIfNoEntry:!1});if(!t?.isFile())return;let s=w.default.relative(this.rootDir,e),n=await this.getNode(e,s,t);n.imports=await this.resolveImports(e,n.imports),Cs(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,t,s){let n=this.previousGraph?.nodes.get(t);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,t);if(!o)return this.makeStubNode(e,t,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,t,s,o,i);return this.attachGitStats(a,t),a}async tryParse(e,t){let s=ge.default.readFileSync(e,"utf-8");try{return await vs(e,s)}catch(n){return process.stderr.write(`
25
+ `),Rs(this.graph.nodes),As(this.graph.nodes),Ms(this.graph.nodes),Is(this.graph.nodes),this.coverageMap.size>0&&Ps(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:{},t=e.minFiles??xa;if(!(t>0&&!this.hasAtLeastFiles(this.rootDir,t)))try{let s=w.default.join(__dirname,"parse-worker.js");this.pool=new Ws.default({filename:s,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(s){process.stderr.write(`
26
+ Warning: failed to start parse worker pool, falling back to synchronous parsing: ${s}
27
+ `),this.pool=null}}hasAtLeastFiles(e,t){let s=0,n=[e];for(;n.length>0;){let o=n.pop(),i;try{i=Q.default.readdirSync(o,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())Ls.has(a.name)||n.push(w.default.join(o,a.name));else if(a.isFile()&&(s++,s>=t))return!0}return s>=t}async processTestFiles(e){let t=X(),s=o=>t.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 ya){let a=w.default.join(o,i);try{Q.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,t){let s;try{s=Q.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of s){let o=w.default.join(e,n.name);n.isDirectory()?Ls.has(n.name)||this.walkProject(o,t):n.isFile()&&t(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(t=>this.finishFile(t)))}}async finishFile(e){let t=Q.default.statSync(e,{throwIfNoEntry:!1});if(!t?.isFile())return;let s=w.default.relative(this.rootDir,e),n=await this.getNode(e,s,t);n.imports=await this.resolveImports(e,n.imports),Ts(n.imports,n.tags),this.graph.nodes.set(n.path,n)}async getNode(e,t,s){let n=this.previousGraph?.nodes.get(t);if(n&&n.mtime===s.mtimeMs&&n.size===s.size)return{...n};let o=await this.tryParse(e,t);if(!o)return this.makeStubNode(e,t,s);let i=this.resolveCallEdges(e,o.rawCallEdges),a=this.buildNode(e,t,s,o,i);return this.attachGitStats(a,t),a}async tryParse(e,t){let s=Q.default.readFileSync(e,"utf-8");try{return await this.parseContent(e,s)}catch(n){return process.stderr.write(`
26
28
  Warning: failed to parse ${t}: ${n}
27
- `),null}}makeStubNode(e,t,s){return{path:t,type:I(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,t){let s=[];for(let n of t??[])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,t,s,n,o){let{imports:i,exports:a,tags:p,category:c,description:m,complexity:g,cognitiveComplexity:h,functions:b}=n;return{path:t,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}:{},...h!==void 0?{cognitiveComplexity:h}:{},...b!==void 0?{functions:b}:{}}}attachGitStats(e,t){if(this.enableGitStats)try{let s=qr(this.rootDir,t);e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor)}catch{}}async resolveImports(e,t){let s=[];for(let n of t){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):await this.processFile(i.path),s.push(a)}}return s}attachLockfileVersion(e){if(!this.lockFile)return;let t=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=t?this.lockFile.dependencies[t]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function Ns(r,e){return{identifier:e?.identifier??new De,featureMap:e?.featureDetection===!1?new Map:R(r.nodes,e?.featureDetection??void 0)}}function Gs(r,e,t,s,n){for(let o of e){let i=r.nodes.get(o);if(!i)continue;let a=new N(o,["*",...i.exports.map(p=>p.name)]);r.traverse(o,(p,c,m)=>{if(!m)return!0;if(!a.updateAffectedSymbols(p,m))return!1;if(c>0){let g=t.get(p.path);if(g)return s(g),!1}return n(p),!0},{direction:"incoming"})}}function Yt(r,e,t){let{identifier:s,featureMap:n}=Ns(r,t),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return Gs(r,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 er(r,e,t){let{identifier:s,featureMap:n}=Ns(r,t),o=new Set;return Gs(r,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Ds=f(require("fs")),Q=f(require("path"));async function _s(r,e,t=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new me(Q.default.resolve(r),t,void 0,n,s.gitStats??!1,s.coverageMap??new Map).build(e)}async function js(r,e={}){let t=Q.default.resolve(r),s=re(t),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 se(t,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 me(t,null,new H(t,{workspaceMap:o,tsconfigSearchPaths:[a.root,t]}),p,e.gitStats??!1).build(a.entryPoints);i.addPackage(a,m)}return i}function Ls(r,e={}){let t=[],s=new Set([...e.ignoreDirs??Ve,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??Xe,...e.additionalExtensions??[]]);function o(i){try{let a=Ds.default.readdirSync(i,{withFileTypes:!0});for(let p of a){let c=Q.default.join(i,p.name);p.isDirectory()?s.has(p.name)||o(c):p.isFile()&&n.has(Q.default.extname(p.name).toLowerCase())&&t.push(Q.default.relative(r,c))}}catch{}}return o(r),t}var Os=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var ze=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,t){this.configs.set(e,t)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,t,s=new Map){let n=this.configs.get(e),o=await _s(e,t,this.graphs.get(e)??null,{gitStats:n?.gitStats??!1,coverageMap:s});return this.graphs.set(e,o),o}require(e){let t=this.graphs.get(e);if(!t)throw new Error('No graph cached for this root. Call "analyze" first.');return t}async getOrBuildWorkspace(e,t={}){let s=this.workspaceGraphs.get(e);if(s)return s;let n=await js(e,t);return this.workspaceGraphs.set(e,n),n}requireWorkspace(e){let t=this.workspaceGraphs.get(e);if(!t)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return t}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let t=this.changeImpactCaches.get(e);if(t)return t;let s=this.require(e),n=ot(s);return this.changeImpactCaches.set(e,n),n}storeLastAnalyze(e,t){this.lastAnalyze.set(e,t)}startWatching(e){if(!this.watchers.has(e))try{let t=Ws.default.watch(e,{recursive:!0},(s,n)=>{!n||Os.test(n)||this.dirtyRoots.add(e)});t.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,t)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let t=this.lastAnalyze.get(e);return t?.kind==="single"?this.getOrBuild(e,t.entryPoints,t.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 t=this.configs.get(e);return this.getOrBuildWorkspace(e,{gitStats:t?.gitStats??!1})}invalidate(e){let t=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),t}};var _=f(require("path"));var zs=f(require("fs")),$s=f(require("os")),$e=f(require("path"));function x(r){return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}function Bs(r){if(!$e.default.isAbsolute(r))throw new Error("root must be an absolute path");let e=$e.default.resolve(r),t=$s.default.homedir();if(e!==t&&!e.startsWith(t+$e.default.sep))throw new Error("root must be within the user home directory");let s;try{s=zs.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function Us(r,e){let{root:t,entryPoints:s}=e;if(!r.isConfigured(t)){let g=X(t,{allowJs:!1});Qe(g),r.storeConfig(t,g)}if(s.length===0){let g=re(t);if(g.type!=="none"){let h=r.getConfig(t),b=await r.getOrBuildWorkspace(t,{gitStats:h?.gitStats??!1});r.storeLastAnalyze(t,{kind:"workspace"}),r.startWatching(t);let M=Array.from(b.packages.values()).map(({graph:de,pkg:tr})=>({package:tr.name,relativeRoot:tr.relativeRoot,nodeCount:de.nodes.size}));return x({monorepoType:g.type,packageCount:b.packages.size,packages:M})}}let n=s.map(g=>_.default.resolve(t,g)),o=r.getConfig(t),i=o?.coverageReportPath?Ye(t,o.coverageReportPath):new Map,a=await r.getOrBuild(t,n,i);r.storeLastAnalyze(t,{kind:"single",entryPoints:n,coverageMap:i}),r.startWatching(t);let p=a.serialize(),c=p.nodes.reduce((g,h)=>(g[h.category]=(g[h.category]??0)+1,g),{}),m=a.findCycles();return x({nodeCount:p.nodes.length,categories:c,cycles:m})}async function qs(r,e){let{root:t,file:s,depth:n=1}=e,o=await r.ensureFresh(t),i=at(o,s,n);return x({file:s,dependencies:i})}async function Ks(r,e){let{root:t,file:s}=e,n=await r.ensureFresh(t),o=pt(n,s);return x({file:s,dependents:o})}async function Js(r,e){let{root:t,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i}=e,a=await r.ensureFresh(t);if(o){let c=r.getOrBuildChangeImpact(t),m=it(c,s),g=n?m.filter(h=>a.nodes.get(h)?.category==="test"):m;return x({file:s,affected:g,count:g.length})}let p=ct(a,s,{testsOnly:n,changedSymbols:i});return x({file:s,affected:p,count:p.length})}async function Hs(r,e){let{root:t,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await r.ensureFresh(t),a=lt(i,s,{depth:n,withEdgeDetail:o});return x({file:s,callers:a,count:a.length})}async function Qs(r,e){let{root:t,entryPoints:s}=e,n=s.map(p=>_.default.resolve(t,p)),o=await r.getOrBuild(t,n),i=Ls(t),a=o.findUnusedFiles(i);return x({unusedFiles:a,count:a.length})}async function Vs(r,e){let{root:t,coverageThreshold:s}=e,n=await r.ensureFresh(t),o=r.getConfig(t),i=s??o?.coverageThreshold??80;if(!mt(n))return x({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 x({threshold:i,uncovered:a,count:a.length})}async function Xs(r,e){let{root:t,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,i=await r.ensureFresh(t),a=ut(i,{metric:s,threshold:n,limit:o});return x({metric:s,threshold:n,functions:a,count:a.length})}async function Zs(r,e){let{root:t,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await r.ensureFresh(t),a=s??new _e().getChangedFiles().map(m=>_.default.relative(t,_.default.resolve(t,m))),p=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let m=er(i,a,p);return x({changedFiles:a,affectedTests:m,count:m.length})}let c=Yt(i,a,p);return x({changedFiles:a,proposedTags:c})}async function Ys(r,e){let{root:t,entryPoints:s,featureThreshold:n}=e,o=s?await r.getOrBuild(t,s.map(p=>_.default.resolve(t,p))):await r.ensureFresh(t),i=R(o.nodes,n!==void 0?{minOutDegree:n}:void 0),a=Array.from(i.values()).sort((p,c)=>c.outDegree-p.outDegree);return x({features:a,count:a.length})}async function en(r,e){let{root:t,entryPoints:s,filter:n,mermaid:o=!1,slim:i=!0}=e,a=s?await r.getOrBuild(t,s.map(c=>_.default.resolve(t,c))):await r.ensureFresh(t),p=Fe(a.serialize(),Ee(n));return o?x(ve.serialize(T.deserialize(p))):i?x(ft(p)):x(p)}async function tn(r,e){let{root:t}=e,s=await r.ensureFreshWorkspace(t);return x(gt(s))}async function rn(r,e){let{root:t,file:s}=e,o=(await r.ensureFreshWorkspace(t)).getAffectedAcrossPackages(s);return x({file:s,affected:o,count:o.length})}function sn(r,e){let{root:t}=e,s=r.invalidate(t);return x({root:t,cleared:s,message:s?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function nn(r,e){let{root:t,type:s}=e,n=await r.ensureFresh(t),o=ht(n);if(s)return x(yt(o,s));let i=Array.from(o.types.values());return x({count:i.length,types:i})}async function on(r,e){let{root:t,paths:s,minOutDegree:n}=e,o=await r.ensureFresh(t),i=dt(o,n!==void 0?{minOutDegree:n}:void 0);if(s?.length){let p=s.map(c=>i.get(c)).filter(Boolean);return x({count:p.length,modules:p})}let a=Array.from(i.values());return x({count:a.length,modules:a})}async function an(r,e){let{root:t,minOutDegree:s}=e,n=await r.ensureFresh(t),o=Y(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return x({features:i,unassigned:o.unassigned})}async function pn(r,e){let{root:t,function:s}=e,n=await r.ensureFresh(t);return x(nt(n,s))}async function cn(r,e){let{root:t,entryPoints:s}=e,n=await r.ensureFresh(t),o=s?.length?s:rt(n,t);if(o.length===0)throw new Error("No entry points found. Pass entryPoints explicitly or ensure package.json has a main/exports field.");return x(st(n,o))}async function ln(r,e){let t=await r.ensureFresh(e.root),s=await _t(t,e.root,{dryRun:e.dryRun??!1});return x(s)}var un=[{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)"}},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"}},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.",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)."}},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:"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. sort: size|imports|commitCount90d|exportUsage. 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:"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 Ue(){let r=new ze,e=new fn.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(Be.ListToolsRequestSchema,async()=>({tools:un})),e.setRequestHandler(Be.CallToolRequestSchema,async t=>{let{name:s,arguments:n}=t.params,o=n,a={analyze:p=>Us(r,p),get_dependencies:p=>qs(r,p),get_dependents:p=>Ks(r,p),get_affected:p=>Js(r,p),get_callers:p=>Hs(r,p),find_unused:p=>Qs(r,p),find_uncovered:p=>Vs(r,p),find_complex_functions:p=>Xs(r,p),propose_tags:p=>Zs(r,p),detect_features:p=>Ys(r,p),get_type_graph:p=>nn(r,p),get_module_responsibility:p=>on(r,p),get_feature_graph:p=>an(r,p),get_call_graph:p=>pn(r,p),get_api_surface:p=>cn(r,p),query:p=>en(r,p),get_workspace_packages:p=>tn(r,p),get_workspace_affected:p=>rn(r,p),clear_cache:p=>sn(r,p),apply_tags:p=>ln(r,p)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return Bs(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 na(){let r=Ue(),e=new gn.StdioServerTransport;await r.connect(e)}na().catch(console.error);0&&(module.exports={createMcpServer});
29
+ `),null}}parseContent(e,t){return this.pool?this.pool.run({filePath:e,content:t}):Fs(e,t)}makeStubNode(e,t,s){return{path:t,type:I(e),category:"other",imports:[],exports:[],tags:[],mtime:s.mtimeMs,size:s.size}}resolveCallEdges(e,t){let s=[];for(let n of t??[])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,t,s,n,o){let{imports:i,exports:a,tags:p,category:c,description:m,complexity:g,cognitiveComplexity:h,functions:b}=n;return{path:t,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}:{},...h!==void 0?{cognitiveComplexity:h}:{},...b!==void 0?{functions:b}:{}}}attachGitStats(e,t){if(this.enableGitStats)try{let s=Kr(this.rootDir,t);e.commitCount90d=s.commitCount90d,s.lastAuthor!==void 0&&(e.lastAuthor=s.lastAuthor),s.lastCommitAt!==void 0&&(e.lastCommitAt=s.lastCommitAt)}catch{}}async resolveImports(e,t){let s=[];for(let n of t){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 t=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],s=t?this.lockFile.dependencies[t]:void 0;s&&(e.version=s.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}};function zs(r,e){return{identifier:e?.identifier??new _e,featureMap:e?.featureDetection===!1?new Map:R(r.nodes,e?.featureDetection??void 0)}}function $s(r,e,t,s,n){for(let o of e){let i=r.nodes.get(o);if(!i)continue;let a=new N(o,["*",...i.exports.map(p=>p.name)]);r.traverse(o,(p,c,m)=>{if(!m)return!0;if(!a.updateAffectedSymbols(p,m))return!1;if(c>0){let g=t.get(p.path);if(g)return s(g),!1}return n(p),!0},{direction:"incoming"})}}function er(r,e,t){let{identifier:s,featureMap:n}=zs(r,t),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return $s(r,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 tr(r,e,t){let{identifier:s,featureMap:n}=zs(r,t),o=new Set;return $s(r,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Bs=f(require("fs")),V=f(require("path"));async function Us(r,e,t=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new de(V.default.resolve(r),t,void 0,n,s.gitStats??!1,s.coverageMap??new Map,s.parallelParsing??!0).build(e)}async function qs(r,e={}){let t=V.default.resolve(r),s=se(t),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 ne(t,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 de(t,null,new H(t,{workspaceMap:o,tsconfigSearchPaths:[a.root,t]}),p,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,m)}return i}function Ks(r,e={}){let t=[],s=new Set([...e.ignoreDirs??Ze,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??Ye,...e.additionalExtensions??[]]);function o(i){try{let a=Bs.default.readdirSync(i,{withFileTypes:!0});for(let p of a){let c=V.default.join(i,p.name);p.isDirectory()?s.has(p.name)||o(c):p.isFile()&&n.has(V.default.extname(p.name).toLowerCase())&&t.push(V.default.relative(r,c))}}catch{}}return o(r),t}var Js=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/;var Be=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,t){this.configs.set(e,t)}getConfig(e){return this.configs.get(e)}async getOrBuild(e,t,s=new Map){let n=this.configs.get(e),o=await Us(e,t,this.graphs.get(e)??null,{gitStats:n?.gitStats??!1,coverageMap:s,parallelParsing:n?.parallelParsing});return this.graphs.set(e,o),o}require(e){let t=this.graphs.get(e);if(!t)throw new Error('No graph cached for this root. Call "analyze" first.');return t}async getOrBuildWorkspace(e,t={}){let s=this.workspaceGraphs.get(e);if(s)return s;let n=await qs(e,t);return this.workspaceGraphs.set(e,n),n}requireWorkspace(e){let t=this.workspaceGraphs.get(e);if(!t)throw new Error('No workspace graph cached for this root. Call "analyze" first.');return t}hasWorkspace(e){return this.workspaceGraphs.has(e)}getOrBuildChangeImpact(e){let t=this.changeImpactCaches.get(e);if(t)return t;let s=this.require(e),n=at(s);return this.changeImpactCaches.set(e,n),n}storeLastAnalyze(e,t){this.lastAnalyze.set(e,t)}startWatching(e){if(!this.watchers.has(e))try{let t=Hs.default.watch(e,{recursive:!0},(s,n)=>{!n||Js.test(n)||this.dirtyRoots.add(e)});t.on("error",()=>{this.watchers.delete(e)}),this.watchers.set(e,t)}catch{}}async ensureFresh(e){if(!this.dirtyRoots.has(e))return this.require(e);this.dirtyRoots.delete(e),this.changeImpactCaches.delete(e);let t=this.lastAnalyze.get(e);return t?.kind==="single"?this.getOrBuild(e,t.entryPoints,t.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 t=this.configs.get(e);return this.getOrBuildWorkspace(e,{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing})}invalidate(e){let t=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),t}};var _=f(require("path"));var Qs=f(require("fs")),Vs=f(require("os")),Ue=f(require("path"));function y(r){return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}function Xs(r){if(!Ue.default.isAbsolute(r))throw new Error("root must be an absolute path");let e=Ue.default.resolve(r),t=Vs.default.homedir();if(e!==t&&!e.startsWith(t+Ue.default.sep))throw new Error("root must be within the user home directory");let s;try{s=Qs.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function Zs(r,e){let{root:t,entryPoints:s}=e;if(!r.isConfigured(t)){let g=Z(t,{allowJs:!1});Xe(g),r.storeConfig(t,g)}if(s.length===0){let g=se(t);if(g.type!=="none"){let h=r.getConfig(t),b=await r.getOrBuildWorkspace(t,{gitStats:h?.gitStats??!1,parallelParsing:h?.parallelParsing});r.storeLastAnalyze(t,{kind:"workspace"}),r.startWatching(t);let M=Array.from(b.packages.values()).map(({graph:he,pkg:rr})=>({package:rr.name,relativeRoot:rr.relativeRoot,nodeCount:he.nodes.size}));return y({monorepoType:g.type,packageCount:b.packages.size,packages:M})}}let n=s.map(g=>_.default.resolve(t,g)),o=r.getConfig(t),i=o?.coverageReportPath?tt(t,o.coverageReportPath):new Map,a=await r.getOrBuild(t,n,i);r.storeLastAnalyze(t,{kind:"single",entryPoints:n,coverageMap:i}),r.startWatching(t);let p=a.serialize(),c=p.nodes.reduce((g,h)=>(g[h.category]=(g[h.category]??0)+1,g),{}),m=a.findCycles();return y({nodeCount:p.nodes.length,categories:c,cycles:m})}async function Ys(r,e){let{root:t,file:s,depth:n=1}=e,o=await r.ensureFresh(t),i=ct(o,s,n);return y({file:s,dependencies:i})}async function en(r,e){let{root:t,file:s}=e,n=await r.ensureFresh(t),o=lt(n,s);return y({file:s,dependents:o})}async function tn(r,e){let{root:t,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i}=e,a=await r.ensureFresh(t);if(o){let c=r.getOrBuildChangeImpact(t),m=pt(c,s),g=n?m.filter(h=>a.nodes.get(h)?.category==="test"):m;return y({file:s,affected:g,count:g.length})}let p=ut(a,s,{testsOnly:n,changedSymbols:i});return y({file:s,affected:p,count:p.length})}async function rn(r,e){let{root:t,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await r.ensureFresh(t),a=ft(i,s,{depth:n,withEdgeDetail:o});return y({file:s,callers:a,count:a.length})}async function sn(r,e){let{root:t,entryPoints:s}=e,n=s.map(p=>_.default.resolve(t,p)),o=await r.getOrBuild(t,n),i=Ks(t),a=o.findUnusedFiles(i);return y({unusedFiles:a,count:a.length})}async function nn(r,e){let{root:t,coverageThreshold:s}=e,n=await r.ensureFresh(t),o=r.getConfig(t),i=s??o?.coverageThreshold??80;if(!ht(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 on(r,e){let{root:t}=e,n=[...(await r.ensureFresh(t)).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 an(r,e){let{root:t,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,i=await r.ensureFresh(t),a=gt(i,{metric:s,threshold:n,limit:o});return y({metric:s,threshold:n,functions:a,count:a.length})}async function pn(r,e){let{root:t,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await r.ensureFresh(t),a=s??new Oe().getChangedFiles().map(m=>_.default.relative(t,_.default.resolve(t,m))),p=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let m=tr(i,a,p);return y({changedFiles:a,affectedTests:m,count:m.length})}let c=er(i,a,p);return y({changedFiles:a,proposedTags:c})}async function cn(r,e){let{root:t,entryPoints:s,featureThreshold:n}=e,o=s?await r.getOrBuild(t,s.map(p=>_.default.resolve(t,p))):await r.ensureFresh(t),i=R(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 ln(r,e){let{root:t,entryPoints:s,filter:n,mermaid:o=!1,slim:i=!0}=e,a=s?await r.getOrBuild(t,s.map(c=>_.default.resolve(t,c))):await r.ensureFresh(t),p=Ee(a.serialize(),Pe(n));return o?y(ke.serialize(P.deserialize(p))):i?y(mt(p)):y(p)}async function un(r,e){let{root:t}=e,s=await r.ensureFreshWorkspace(t);return y(dt(s))}async function fn(r,e){let{root:t,file:s}=e,o=(await r.ensureFreshWorkspace(t)).getAffectedAcrossPackages(s);return y({file:s,affected:o,count:o.length})}function gn(r,e){let{root:t}=e,s=r.invalidate(t);return y({root:t,cleared:s,message:s?"Cache cleared. Call analyze to rebuild.":"No cache was present for this root."})}async function mn(r,e){let{root:t,type:s}=e,n=await r.ensureFresh(t),o=xt(n);if(s)return y(St(o,s));let i=Array.from(o.types.values());return y({count:i.length,types:i})}async function dn(r,e){let{root:t,paths:s,minOutDegree:n}=e,o=await r.ensureFresh(t),i=yt(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 hn(r,e){let{root:t,minOutDegree:s}=e,n=await r.ensureFresh(t),o=ee(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return y({features:i,unassigned:o.unassigned})}async function yn(r,e){let{root:t,function:s}=e,n=await r.ensureFresh(t);return y(it(n,s))}async function xn(r,e){let{root:t,entryPoints:s}=e,n=await r.ensureFresh(t),o=s?.length?s:nt(n,t);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(ot(n,o))}async function Sn(r,e){let t=await r.ensureFresh(e.root),s=await Ot(t,e.root,{dryRun:e.dryRun??!1});return y(s)}var bn=[{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)"}},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"}},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.",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)."}},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. sort: size|imports|commitCount90d|exportUsage. 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:"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 Ke(){let r=new Be,e=new vn.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler(qe.ListToolsRequestSchema,async()=>({tools:bn})),e.setRequestHandler(qe.CallToolRequestSchema,async t=>{let{name:s,arguments:n}=t.params,o=n,a={analyze:p=>Zs(r,p),get_dependencies:p=>Ys(r,p),get_dependents:p=>en(r,p),get_affected:p=>tn(r,p),get_callers:p=>rn(r,p),find_unused:p=>sn(r,p),find_uncovered:p=>nn(r,p),check_doc_drift:p=>on(r,p),find_complex_functions:p=>an(r,p),propose_tags:p=>pn(r,p),detect_features:p=>cn(r,p),get_type_graph:p=>mn(r,p),get_module_responsibility:p=>dn(r,p),get_feature_graph:p=>hn(r,p),get_call_graph:p=>yn(r,p),get_api_surface:p=>xn(r,p),query:p=>ln(r,p),get_workspace_packages:p=>un(r,p),get_workspace_affected:p=>fn(r,p),clear_cache:p=>gn(r,p),apply_tags:p=>Sn(r,p)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return Xs(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 ba(){let r=Ke(),e=new kn.StdioServerTransport;await r.connect(e)}ba().catch(console.error);0&&(module.exports={createMcpServer});
28
30
  //# sourceMappingURL=mcp.js.map