@omfalos/mokosh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.d.mts ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+
4
+ /** Creates and configures the MCP server, wiring all tool handlers to their JSON Schema definitions. */
5
+
6
+ /**
7
+ * @description Creates and wires up the mokosh MCP server. Each call returns a fresh `Server`
8
+ * instance backed by its own `SessionState`, so multiple instances (e.g. parallel test runs)
9
+ * are fully isolated. Every incoming `root` argument is validated to be within the user's home
10
+ * directory before any handler runs.
11
+ * @returns {Server} A configured MCP `Server` ready to be connected to a transport.
12
+ */
13
+ declare function createMcpServer(): Server;
14
+
15
+ export { createMcpServer };
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+
4
+ /** Creates and configures the MCP server, wiring all tool handlers to their JSON Schema definitions. */
5
+
6
+ /**
7
+ * @description Creates and wires up the mokosh MCP server. Each call returns a fresh `Server`
8
+ * instance backed by its own `SessionState`, so multiple instances (e.g. parallel test runs)
9
+ * are fully isolated. Every incoming `root` argument is validated to be within the user's home
10
+ * directory before any handler runs.
11
+ * @returns {Server} A configured MCP `Server` ready to be connected to a transport.
12
+ */
13
+ declare function createMcpServer(): Server;
14
+
15
+ export { createMcpServer };
package/dist/mcp.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var tn=Object.create;var me=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,on=Object.prototype.hasOwnProperty;var an=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},qt=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sn(e))!on.call(r,n)&&n!==t&&me(r,n,{get:()=>e[n],enumerable:!(s=rn(e,n))||s.enumerable});return r};var g=(r,e,t)=>(t=r!=null?tn(nn(r)):{},qt(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),pn=r=>qt(me({},"__esModule",{value:!0}),r);var Ki={};an(Ki,{createMcpServer:()=>Be});module.exports=pn(Ki);var en=require("@modelcontextprotocol/sdk/server/stdio.js");var Ys=require("@modelcontextprotocol/sdk/server/index.js"),$e=require("@modelcontextprotocol/sdk/types.js");var As=g(require("fs"));var xe=g(require("fs")),Je=g(require("path"));var cn=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Kt=[];function de(r){Kt.push(r)}function Jt(r){return[...cn,...Kt].some(e=>typeof e=="string"?r.includes(e):e instanceof RegExp?e.test(r):e(r))}var ln=[".test.",".spec.","-test.","-spec."],Ht=[];function he(r){Ht.push(r)}function Q(){return[...ln,...Ht]}var un=["jest","vitest","playwright","cypress","@testing-library/"],Qt=[];function ye(r){Qt.push(r)}function Ue(){return[...un,...Qt]}var Vt=.8;function qe(r){Vt=r}function Ke(){return Vt}var fn=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"];function V(r,{allowJs:e=!0,isExplicitPath:t=!1}={}){if(t){let s=Je.default.resolve(r);return xe.default.existsSync(s)?s.endsWith(".json")?Xt(s):e?Zt(s):{}:{}}for(let s of fn){let n=Je.default.resolve(r,s);if(xe.default.existsSync(n)){if(s.endsWith(".json"))return Xt(n);if(e)return Zt(n)}}return{}}function Xt(r){return JSON.parse(xe.default.readFileSync(r,"utf-8"))}function Zt(r){let e=require(r);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function He(r){for(let e of r.configMatchers??[])de(e);for(let e of r.testPatterns??[])he(e);for(let e of r.testLibraries??[])ye(e);r.barrelThreshold!==void 0&&qe(r.barrelThreshold)}var Qe=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Ve=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature"];var Yt=g(require("fs")),Xe=g(require("path"));function Ze(r,e){let t=Xe.default.resolve(r,e);try{let s=Yt.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=Xe.default.relative(r,i);o.set(c,p)}return o}catch{return new Map}}var Se={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 Ye=g(require("fs")),er=g(require("path"));function et(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 tr(r,e){if(typeof r=="string")return et(r,e);if(r&&typeof r=="object"){let t=r;for(let s of["import","require","default"]){let n=tr(t[s],e);if(n)return n}}return null}function mn(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 dn(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 u of c.exports)t.add(u.name);n.push(a.toPath)}else for(let c of a.symbols)t.add(c)}}}return t}function tt(r,e){let t=[],s=er.default.join(e,"package.json");if(Ye.default.existsSync(s))try{let n=JSON.parse(Ye.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=tr(o,r);i&&!t.includes(i)&&t.push(i)}else if(typeof n.exports=="string"){let o=et(n.exports,r);o&&t.push(o)}if(t.length===0)for(let o of[n.main,n.module].filter(Boolean)){let i=et(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 hn(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 yn(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 xn(r,e,t,s){let n=[];for(let o of r){let i=e.get(o),a=s.flatMap(f=>t.nodes.get(f)?.exports??[]).find(f=>f.name===o),p=i?.symbol??a,c=i?.file??s.find(f=>t.nodes.get(f)?.exports.some(m=>m.name===o))??s[0],u={name:o,definedIn:c,kind:mn(p?.signature)};p?.doc&&(u.doc=p.doc),p?.signature&&(u.signature=p.signature),n.push(u)}return n.sort((o,i)=>o.name.localeCompare(i.name)),n}function Sn(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 rt(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=hn(r,e),s=yn(r,t,e),n=dn(r,e),o=xn(n,s,r,e),{internalFiles:i,unreachableFromEntry:a,testFiles:p}=Sn(r,t,e);return{entryPoints:e,publicExports:o,internalFiles:i,unreachableFromEntry:a,testFiles:p}}function st(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 bn=g(require("fs")),vn=g(require("path"));function rr(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 nt(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:rr(r)}}function ot(r,e){return r.impact.get(e)??[]}var X=g(require("path"));function kn(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 wn(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=X.default.extname(n),p=X.default.basename(n,a),c=p==="index"?X.default.basename(X.default.dirname(n)):p;s.set(n,{path:n,outDegree:o,tag:`feature:${c}`})}return s}function M(r,e){let t=e?.minOutDegree??5;return wn(r,kn(r),t)}var Cn=(r,e)=>r.outDegree-e.outDegree;function Fn(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 En(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 Tn(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 An(r,e,t){let s=[];for(let n of r.keys())!e.has(n)&&!t.has(n)&&s.push(n);return s}function Z(r,e){let t=e?.detectFn??M,s=e?.hubComparator??Cn,n=t(r.nodes,e),o=Fn(r,n),i=En(r.nodes,n,o,s);return{features:Tn(n,i),unassigned:An(r.nodes,n,i)}}var Y=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,u)=>{if(c>i||o.has(p))return;let f=this.nodes.get(p);if(f&&(o.add(p),t(f,c,u)!==!1))for(let m of n(p))a(m,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 Y(this.nodes).findUnusedFiles(e)}findCycles(){return new Y(this.nodes).findCycles()}};function sr(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 h(e,"component")||h(e,"components")?"component":h(e,"controller")||h(e,"controllers")?"controller":h(e,"middleware")?"middleware":h(e,"router")||h(e,"routes")||h(e,"route")?"router":h(e,"store")||h(e,"stores")?"store":h(e,"service")||h(e,"services")?"service":h(e,"handler")||h(e,"handlers")?"handler":h(e,"adapter")||h(e,"adapters")?"adapter":h(e,"plugin")||h(e,"plugins")?"plugin":h(e,"api")?"api":h(e,"cli")||h(e,"commands")||ee(e)==="cli"?"cli":h(e,"util")||h(e,"utils")||h(e,"helper")||h(e,"helpers")?"util":h(e,"model")||h(e,"models")||ee(e)==="model"?"model":h(e,"parser")||h(e,"parsers")||ee(e)==="parser"?"parser":ee(e)==="builder"?"builder":ee(e)==="resolver"?"resolver":"other"}function h(r,e){return r.includes(`/${e}/`)||r.includes(`/${e}.`)}function ee(r){let e=r.slice(r.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}function it(r,e){let t=Z(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:sr(o),...o.description?{description:o.description}:{},exports:o.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return n}var R=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 Pn(r){return r?r.startsWith("interface ")?"interface":r.startsWith("class ")?"class":r.startsWith("enum ")?"enum":"type":"type"}function In(r,e){if(e==="type-only")return!0;let t=r.signature??"";return t.startsWith("interface ")||t.startsWith("class ")||t.startsWith("enum ")}function at(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(!In(n,s.category))continue;let o=`${s.path}::${n.name}`;e.set(o,{name:n.name,file:s.path,kind:Pn(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 pt(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 xr=g(require("path"));var ve=g(require("fs")),ut=g(require("path"));var j=g(require("fs")),w=g(require("path"));var ct=g(require("fs")),Mn=g(require("path"));function nr(r){try{return ct.default.statSync(r,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function be(r){try{return ct.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}function lt(r,e){let t=w.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:w.default.relative(r,e),entryPoints:Rn(e,s)}:null}function Rn(r,e){let t=[];if(e.exports){let n=e.exports;if(typeof n=="string")t.push(w.default.join(r,n));else if(typeof n=="object"&&n!==null){let o=n["."];if(typeof o=="string")t.push(w.default.join(r,o));else if(typeof o=="object"&&o!==null){let i=o.import??o.require??o.default;typeof i=="string"&&t.push(w.default.join(r,i))}}}e.main&&t.push(w.default.join(r,e.main));for(let n of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])t.push(w.default.join(r,n));let s=t.filter(be);return s.length>0?s.slice(0,1):t.slice(0,1)}function _(r,e){let t=[],s=new Set;for(let n of e){let o=n.replace(/\/$/,"").replace(/^\.\//,"");Nn(r,o,s,t)}return t}function Nn(r,e,t,s){if(!e.includes("*")){Gn(r,e,t,s);return}let n=e.split("/");n.includes("**")?Dn(r,n,t,s):jn(r,n,t,s)}function Gn(r,e,t,s){let n=w.default.join(r,e);if(t.has(n)||!nr(n))return;t.add(n);let o=lt(r,n);o&&s.push(o)}function Dn(r,e,t,s){let n=w.default.join(r,e[0]==="**"?"":e[0]??"");or(r,n,t,s)}function jn(r,e,t,s){let n=e.findIndex(a=>a.includes("*")),o=w.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=w.default.join(o,a.name);if(t.has(p))continue;t.add(p);let c=lt(r,p);c&&s.push(c)}}function or(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=w.default.join(e,o.name);if(j.default.existsSync(w.default.join(i,"package.json"))&&!t.has(i)){t.add(i);let a=lt(r,i);a&&s.push(a)}else or(r,i,t,s)}}var ir={type:"npm",detect(r){let e=ut.default.join(r,"package.json");if(!ve.default.existsSync(e))return null;let t;try{t=JSON.parse(ve.default.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!t||ve.default.existsSync(ut.default.join(r,"yarn.lock")))return null;let s=Array.isArray(t)?t:t.packages??[];return s.length===0?null:_(r,s)}};var N=g(require("fs")),b=g(require("path"));var ar={type:"nx",detect(r){return N.default.existsSync(b.default.join(r,"nx.json"))?pr(r,r,new Set,0).map(t=>_n(r,t,b.default.join(t,"project.json"))).filter(t=>t!==null):null}};function pr(r,e,t,s){if(s>4)return[];let n;try{n=N.default.readdirSync(e,{withFileTypes:!0})}catch{return[]}let o=[];for(let i of n){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let p=b.default.join(e,a);N.default.existsSync(b.default.join(p,"project.json"))&&!t.has(p)?(t.add(p),o.push(p)):o.push(...pr(r,p,t,s+1))}return o}function _n(r,e,t){let s={};try{s=JSON.parse(N.default.readFileSync(t,"utf-8"))}catch{return null}let n=s.name,o,i,a=b.default.join(e,"package.json");if(N.default.existsSync(a))try{let p=JSON.parse(N.default.readFileSync(a,"utf-8"));n=p.name??n,o=p.main,i=p.exports}catch{}return n?{name:n,root:e,relativeRoot:b.default.relative(r,e),entryPoints:Ln(e,s,o,i)}:null}function Ln(r,e,t,s){let n=[],o=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(o){let a=b.default.resolve(r,"../..");n.push(b.default.resolve(a,o)),n.push(b.default.resolve(r,o))}if(s){let a=s;if(typeof a=="string")n.push(b.default.join(r,a));else if(typeof a=="object"&&a!==null){let p=a["."];typeof p=="string"&&n.push(b.default.join(r,p))}}if(t&&n.push(b.default.join(r,t)),e.sourceRoot){let a=b.default.resolve(r,"../.."),p=b.default.resolve(a,e.sourceRoot);n.push(b.default.join(p,"index.ts"),b.default.join(p,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])n.push(b.default.join(r,a));let i=n.filter(be);return i.length>0?i.slice(0,1):n.slice(0,1)}var ft=g(require("fs")),cr=g(require("path")),lr=g(require("js-yaml"));var ur={type:"pnpm",detect(r){let e=cr.default.join(r,"pnpm-workspace.yaml");if(!ft.default.existsSync(e))return null;let t=[];try{t=lr.default.load(ft.default.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return _(r,t)}};var fr=g(require("fs")),gr=g(require("path")),mr={type:"turborepo",detect(r){return fr.default.existsSync(gr.default.join(r,"turbo.json"))?[]:null}};var ke=g(require("fs")),gt=g(require("path"));var dr={type:"yarn",detect(r){if(!ke.default.existsSync(gt.default.join(r,"yarn.lock")))return null;let e=gt.default.join(r,"package.json");if(!ke.default.existsSync(e))return null;let t;try{t=JSON.parse(ke.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:_(r,s)}};var hr=[];function P(r){hr.push(r)}function yr(){return hr}P(mr);P(ar);P(ur);P(dr);P(ir);function te(r,e=yr()){let t=xr.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 re=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 Sr=new Map;function L(r,e){Sr.set(r,e)}function br(r){return Sr.get(r)}function vr(r,e){return e.startsWith("!")?r!==e.slice(1):r===e}function On(r,e){return e.startsWith("!")?!r.includes(e.slice(1)):r.includes(e)}var Wn=(r,e)=>!e.category||vr(r.category,e.category),zn=(r,e)=>!e.type||vr(r.type,e.type),$n=(r,e)=>!e.path||On(r.path,e.path),Bn=(r,e)=>e.isExternal===void 0?!0:r.imports.some(s=>s.isExternal)===e.isExternal,Un=(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)))},qn=(r,e)=>!e.allTags?.length||e.allTags.every(t=>r.tags.some(s=>s.name===t)),Kn=(r,e)=>!e.importsFile||r.imports.some(t=>t.toPath?.includes(e.importsFile)),Jn=(r,e,t)=>e.importedBy===void 0?!0:(t?.get(r.path)??[]).some(n=>n.includes(e.importedBy)),Hn=(r,e)=>e.minImports===void 0||r.imports.length>=e.minImports,Qn=(r,e)=>e.maxImports===void 0||r.imports.length<=e.maxImports,Vn=(r,e)=>e.minSize===void 0||r.size>=e.minSize,Xn=(r,e)=>e.maxSize===void 0||r.size<=e.maxSize,Zn=(r,e)=>e.hasDocstring===void 0||!!r.description===e.hasDocstring,Yn=(r,e)=>e.minCoverage===void 0||(r.coveragePct??101)>=e.minCoverage,eo=(r,e)=>e.maxCoverage===void 0||(r.coveragePct??0)<=e.maxCoverage,to=(r,e)=>e.minExportUsage===void 0||(r.avgExportUsage??-1)>=e.minExportUsage,ro=(r,e)=>e.maxExportUsage===void 0||(r.avgExportUsage??0)<=e.maxExportUsage,kr=[Wn,zn,$n,Bn,Un,qn,Kn,Jn,Hn,Qn,Vn,Xn,Zn,Yn,eo,to,ro];function wr(r,e,t){return kr.every(s=>s(r,e,t))}function we(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=>wr(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 Ce(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 Et=g(require("fs/promises")),Nr=g(require("path"));var Re=g(require("path")),se=g(require("typescript"));var mt=g(require("path")),dt=g(require("typescript"));var v=g(require("typescript")),Cr=new Set(["describe","test","it"]);function O(r){let e=[];for(let t of r.statements){if(!v.default.isExpressionStatement(t))continue;let s=t.expression;if(!v.default.isCallExpression(s))continue;let n=s.expression;v.default.isIdentifier(n)&&Cr.has(n.text)&&e.push(s),v.default.isPropertyAccessExpression(n)&&v.default.isIdentifier(n.expression)&&Cr.has(n.expression.text)&&e.push(s)}return e}function W(r,e,t){for(let s of r.arguments){if(!v.default.isObjectLiteralExpression(s))continue;let n=s.properties.find(o=>v.default.isPropertyAssignment(o)&&v.default.isIdentifier(o.name)&&o.name.text===e);if(!(!n||!v.default.isArrayLiteralExpression(n.initializer)))return n.initializer.elements.filter(v.default.isStringLiteral).map(o=>o.text)}return null}function z(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(!v.default.isObjectLiteralExpression(i))continue;let a=i.properties.find(c=>v.default.isPropertyAssignment(c)&&v.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 $(r,e,t){let s=r.arguments;for(let n=1;n<s.length;n++){let o=s[n];if(!v.default.isObjectLiteralExpression(o))continue;let i=o.properties.findIndex(p=>v.default.isPropertyAssignment(p)&&v.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 B(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 U(r){return`[${r.map(e=>JSON.stringify(e)).join(", ")}]`}var F=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]);function so(r){return U(r.map(e=>`@${e}`))}function no(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Fe=class{name="cypress";canHandle(e){return F.has(mt.default.extname(e).toLowerCase())}apply(e,t,s){let n=dt.default.createSourceFile(mt.default.basename(e),t,dt.default.ScriptTarget.Latest,!0),o=O(n);if(o.length===0)return t;let i=W(o[0],"tags",n),a=[...s].sort();if(i!==null&&JSON.stringify(no(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let u=s.length===0?$(c,"tags",n):z(c,"tags",so(a),n);return u?[u]:[]});return p.length>0?B(t,p):t}};var Fr=g(require("path")),ht=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,yt=/^@([a-zA-Z0-9_-]+)/gm;function oo(r){return["# <mokosh-tags>",...r.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
4
+ `)+`
5
+
6
+ `}function io(r){let e=new Set;yt.lastIndex=0;let t=yt.exec(r);for(;t!==null;)t[1]&&e.add(t[1]),t=yt.exec(r);return e}var Ee=class{name="gherkin";canHandle(e){return Fr.default.extname(e).toLowerCase()===".feature"}apply(e,t,s){let n=t.replace(ht,""),o=io(n),i=s.filter(p=>!o.has(p)),a=i.length>0?oo(i):"";return ht.test(t)?t.replace(ht,a):a?t.replace(/^(Feature:)/m,`${a}$1`):t}};function Er(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 Tr=g(require("path")),xt=/^\/\/go:build mokosh_[^\n]+\n/m,ao=/^package\s+\S+/m;function po(r){return`//go:build ${r.map(t=>`mokosh_${t}`).join(" || ")}
7
+ `}function co(r){let e=xt.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 Te=class{name="go";canHandle(e){return Tr.default.basename(e).endsWith("_test.go")}apply(e,t,s){let n=co(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(xt,"");let i=po(o);if(n!==null)return t.replace(xt,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 Ar=g(require("path"));var lo=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,St=/^ \* @group (.+)$/gm;function uo(r){return["/**",...r.map(e=>` * @group ${e}`)," */"].join(`
9
+ `)+`
10
+
11
+ `}function fo(r){let e=[];St.lastIndex=0;let t=St.exec(r);for(;t!==null;)t[1]&&e.push(t[1]),t=St.exec(r);return e}var Ae=class{name="jest";canHandle(e){return F.has(Ar.default.extname(e).toLowerCase())}apply(e,t,s){let n=lo.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:uo(i)+a}};var bt=g(require("path")),vt=g(require("typescript"));function go(r){return U(r.map(e=>`@${e}`))}function mo(r){return r.map(e=>e.startsWith("@")?e.slice(1):e)}var Pe=class{name="playwright";canHandle(e){return F.has(bt.default.extname(e).toLowerCase())}apply(e,t,s){let n=vt.default.createSourceFile(bt.default.basename(e),t,vt.default.ScriptTarget.Latest,!0),o=O(n);if(o.length===0)return t;let i=W(o[0],"tag",n),a=[...s].sort();if(i!==null&&JSON.stringify(mo(i).sort())===JSON.stringify(a))return t;let p=o.flatMap(c=>{let u=s.length===0?$(c,"tag",n):z(c,"tag",go(a),n);return u?[u]:[]});return p.length>0?B(t,p):t}};var Pr=g(require("path")),kt=/^pytestmark\s*=\s*.+$/m,ho=/^import pytest\s*$/m;function yo(r){let e=r.map(t=>`pytest.mark.${t}`).join(", ");return r.length===1?`pytestmark = pytest.mark.${r[0]}`:`pytestmark = [${e}]`}function xo(r){let e=kt.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 Ie=class{name="pytest";canHandle(e){return Pr.default.extname(e).toLowerCase()===".py"}apply(e,t,s){let n=xo(t),o=[...s].sort();if(n!==null&&JSON.stringify([...n].sort())===JSON.stringify(o))return t;if(s.length===0)return t.replace(kt,"").replace(/\n{3,}/g,`
12
+
13
+ `);let i=yo(o);if(n!==null)return t.replace(kt,i);let a=ho.test(t),p=So(t),c=t.slice(0,p),u=t.slice(p),f=a?"":`import pytest
14
+ `,m=c.endsWith(`
15
+
16
+ `)?"":`
17
+ `;return c+m+f+i+`
18
+ `+u}};function So(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 wt=g(require("path")),Ct=g(require("typescript"));var bo=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,Me=class{name="vitest";canHandle(e){return F.has(wt.default.extname(e).toLowerCase())}apply(e,t,s){let n=t.replace(bo,""),o=Ct.default.createSourceFile(wt.default.basename(e),n,Ct.default.ScriptTarget.Latest,!0),i=O(o);if(i.length===0)return n;let a=W(i[0],"tags",o),p=[...s].sort();if(a!==null&&JSON.stringify([...a].sort())===JSON.stringify(p))return n;let c=i.flatMap(u=>{let f=s.length===0?$(u,"tags",o):z(u,"tags",U(p),o);return f?[f]:[]});return c.length>0?B(n,c):n}};var Ir={vitest:()=>new Me,playwright:()=>new Pe,cypress:()=>new Fe,jest:()=>new Ae},vo={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};function ko(r){let e=se.default.createSourceFile("detect.ts",r,se.default.ScriptTarget.Latest,!0);for(let t of e.statements){if(!se.default.isImportDeclaration(t)||!se.default.isStringLiteral(t.moduleSpecifier))continue;let s=vo[t.moduleSpecifier.text];if(s)return s}return null}var Ft=class{constructor(e,t,s){this.rootDir=e;this.defaultFramework=t;this.frameworkOverrides=s}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return F.has(Re.default.extname(e).toLowerCase())}apply(e,t,s){let n=ko(t)??this.matchOverride(e)??this.defaultFramework;return(Ir[n]??Ir.vitest)().apply(e,t,s)}matchOverride(e){let t=Re.default.relative(this.rootDir,e).split(Re.default.sep).join("/");for(let[s,n]of this.frameworkOverrides)if(Er(s,t))return n;return null}};function Mr(r="vitest",e={},t=process.cwd()){return[new Ee,new Ie,new Te,new Ft(t,r,Object.entries(e))]}function Rr(r,e){return e.find(t=>t.canHandle(r))??null}var wo=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Co=new Set(["import"]),Fo=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"]);async function Eo(r,e,t,s){let n;try{n=await Et.default.readFile(r,"utf8")}catch(a){return{path:r,status:"error",error:String(a)}}let o=Rr(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 Et.default.writeFile(r,i,"utf8"),{path:r,status:"updated"})}async function Tt(r,e,t){let s=V(e),n=s.tagApplier?.framework??"vitest",o=s.tagApplier?.frameworkOverrides??{},i=Mr(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,u=[];for(let x of p.tags)Co.has(x.kind)&&wo.test(x.name)&&(Fo.has(x.name.toLowerCase())||c.has(x.name)||(c.add(x.name),u.push(x.name)));u.sort();let f=Nr.default.resolve(e,p.path),m=await Eo(f,u,t.dryRun,i);m.path=p.path,a.files.push(m),m.status==="updated"?a.updated++:m.status==="unchanged"?a.unchanged++:a.errors++}return a}var Ne=class{isTestNode(e){return e.category==="test"||e.tags.some(t=>t.name==="test")}};var ue=g(require("fs")),k=g(require("path"));var At=require("child_process"),Ge=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,At.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 Gr(r,e){let s=(0,At.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 ne=g(require("fs")),Dr=g(require("path")),Pt=g(require("js-yaml"));function jr(r){let e=r.lastIndexOf("@");return e>0?r.substring(0,e):r}function To(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 Ao(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 Po(r){try{let e=Pt.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 Io(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=To(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 Mo(r){let e=ne.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 Ro(r){let e=ne.default.readFileSync(r,"utf-8");if(e.includes("__metadata:")){let t=Po(e);if(t!==null)return t}return Io(e)}function No(r){let e=ne.default.readFileSync(r,"utf-8"),t={dependencies:{}};try{let s=Pt.default.load(e);if(s.packages)for(let[n,o]of Object.entries(s.packages)){let{name:i,version:a}=Ao(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 _r(r){let e=[["package-lock.json",Mo],["yarn.lock",Ro],["pnpm-lock.yaml",No]];for(let[t,s]of e){let n=Dr.default.join(r,t);if(ne.default.existsSync(n))return s(n)}return null}var It=g(require("path"));function I(r){switch(It.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 C(r){let e=It.default.extname(r).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var Lr=g(require("coffeescript"));function Go(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 Do(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function jo(r,e){let t=e.source?.value;return t?{fromPath:r,toPath:"",rawSpecifier:t,isStyle:C(t),type:"static"}:null}function _o(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:C(s),type:"require"}}function Lo(r,e,t){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=jo(r,e);n&&t.push(n)}else if(s==="Call"){let n=_o(r,e);n&&t.push(n)}}function Mt(r,e,t){if(!(!e||typeof e!="object")){Lo(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)Mt(r,o,t);else Mt(r,n,t)}}}function Or(r,e){let t=Go(e),s=Do(r,t),n=[];try{Mt(r,Lr.default.nodes(e),n)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var q=require("@cucumber/gherkin"),Wr=require("@cucumber/messages");var Oo=Wr.IdGenerator.uuid();function Rt(r,e){let t=new Set;try{let s=new q.AstBuilder(Oo),n=new q.GherkinClassicTokenMatcher,i=new q.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",Rt);var $r=g(require("path")),Br=require("@lezer/go"),Wo=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,zo=/^\/\/go:build\s+(.+)$/,$o=/^\/\/\s*\+build\s+(.+)$/;function Ur(r,e){let t=[],s=new Map,n=new Set,o=new Set,a=Br.parser.parse(e).cursor();do switch(a.name){case"LineComment":{let f=e.slice(a.from,a.to),m=f.match(Wo);m?.[1]&&n.add(m[1]);let x=f.match(zo);x&&zr(x[1],o);let E=f.match($o);E&&zr(E[1],o);break}case"ImportSpec":{let f=a.node.getChild("String");if(f){let x=e.slice(f.from,f.to).slice(1,-1);t.push({fromPath:r,toPath:"",rawSpecifier:x,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let f=a.node.getChild("DefName")??a.node.getChild("TypeSpec")?.getChild("DefName")??a.node.getChild("VarSpec")?.getChild("DefName")??a.node.getChild("ConstSpec")?.getChild("DefName");if(f){let m=e.slice(f.from,f.to);m!=="_"&&/^[A-Z]/.test(m)&&!s.has(m)&&s.set(m,{name:m})}break}}while(a.next());let p=t.some(f=>f.rawSpecifier==="testing"),c=$r.default.basename(r).endsWith("_test.go")||n.has("test")||p?"test":"logic",u=new Set([...n,...o]);return{imports:t,exports:Array.from(s.values()),tags:Array.from(u).map(f=>({name:f,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 qr=g(require("livescript"));function K(r){return r.startsWith("'")||r.startsWith('"')?r.slice(1,-1):r}function Bo(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 Uo(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}var qo=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Ko(r,e){let t=r.constructor?.name||r.type;if(t==="Import"){let s=r.right?.value;if(typeof s=="string"){let n=K(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:C(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=K(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:C(o),type:"require"}}}}return null}function Nt(r,e){if(!r||typeof r!="object")return[];let t=[],s=Ko(r,e);s&&t.push(s);for(let n in r){if(qo.has(n))continue;let o=r[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let i of o)t.push(...Nt(i,e));else t.push(...Nt(o,e))}return t}function Kr(r,e){let t=Bo(e),s=Uo(r,t),n=[];try{n=Nt(qr.default.ast(e),r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Jr=g(require("luaparse"));function Jo(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 Ho(r,e){let t=r.toLowerCase();return t.includes(".test.")||t.includes(".spec.")||e.has("test")?"test":"logic"}function Qo(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=K(i.raw))}else if(n.type==="StringCallExpression"){let i=n.argument;i?.type==="StringLiteral"&&(o=K(i.raw))}o&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:C(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 Hr(r,e){let t=Jo(e),s=Ho(r,t),n=[];try{let o=Jr.default.parse(e);n=Qo(o,r)}catch{}return{imports:n,exports:[],tags:Array.from(t).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Qr=g(require("path")),Vr=require("@lezer/python"),Vo=new Set(["pytest","unittest","nose","hypothesis"]);function Xr(r,e){let t=[],s=[],n=new Set,o=Qr.default.basename(r).toLowerCase(),a=Vr.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 Xo(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 f=a.node.getChild("VariableName");f&&s.push({name:e.slice(f.from,f.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 Xo(r,e,t){let s=r.firstChild;return s?s.name==="from"?Zo(r,e,t):Yo(r,e,t):[]}function Zo(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=ei(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[oe(t,o,i,!0)];let c=a===1?"./":"../".repeat(a-1);return p?[oe(t,c+p.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[oe(t,c.slice(0,-1),["*"],!1)]:i.map(u=>oe(t,c+u,[u],!1))}function Yo(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(oe(t,o,["*"],!0))}n=n.nextSibling}return s}function ei(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 oe(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=>Vo.has(s.rawSpecifier))?"test":"logic"}var jt=g(require("path")),l=g(require("typescript"));var d=g(require("typescript"));function ri(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 si(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 Gt(r){return{complexity:ri(r),cognitiveComplexity:si(r)}}var S=g(require("typescript")),Dt=new Set(["test","describe","it"]);function Zr(r,e){ni(r,e),ii(r,e),ai(r,e),pi(r,e)}function ni(r,e){if((S.default.isFunctionDeclaration(r)||S.default.isVariableDeclaration(r))&&r.name&&S.default.isIdentifier(r.name)&&oi(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 oi(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 ii(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 ai(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 pi(r,e){if(S.default.isCallExpression(r)&&ci(r.expression))for(let t of r.arguments)S.default.isObjectLiteralExpression(t)&&li(t,e)}function ci(r){return S.default.isIdentifier(r)?Dt.has(r.text):!!(S.default.isPropertyAccessExpression(r)&&(Dt.has(r.name.text)||S.default.isIdentifier(r.expression)&&Dt.has(r.expression.text)))}function li(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 _t(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=ge=>{mi(ge,a),l.default.forEachChild(ge,p)};p(i);let c=Fi(r,a);(c==="test"||c==="barrel")&&o.add({name:c,kind:"comment-marker"}),c!=="test"&&Ei(a,i);let u=i.statements[0],f=u?es(u):void 0,{complexity:m,cognitiveComplexity:x}=Gt(i),E=ui(i);return{imports:s,exports:Array.from(n.values()),tags:Array.from(o),category:c,rawCallEdges:a.rawCallEdges??[],complexity:m,cognitiveComplexity:x,...E.length>0?{functions:E}:{},...f!==void 0?{description:f}:{}}}function ui(r){let e=[],t=(n,o)=>{let{complexity:i,cognitiveComplexity:a}=Gt(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 Yr(r,e,t,s){let n={name:r},o=es(t);o!==void 0&&(n.doc=o);let i=fi(e);i!==void 0&&(n.flags=i);let a=gi(e,s);return a!==void 0&&(n.signature=a),n}function es(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 fi(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 gi(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 mi(r,e){di(r,e),hi(r,e),xi(r,e),Si(r,e),Ci(r,e),Zr(r,e)}function di(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)||Lt(s)).length}function hi(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)&&!yi(r)&&(e.hasTypesOnly=!1)}function yi(r){return r.isTypeOnly?!0:!r.exportClause||!l.default.isNamedExports(r.exportClause)?!1:r.exportClause.elements.every(e=>e.isTypeOnly)}function xi(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:C(r.moduleSpecifier.text),type:s,symbols:t.length>0?t:void 0})}function Si(r,e){l.default.isExportDeclaration(r)?bi(r,e):l.default.isExportAssignment(r)?e.exports.set("default",{name:"default"}):Lt(r)&&wi(r,e)}function bi(r,e){if(r.moduleSpecifier&&l.default.isStringLiteral(r.moduleSpecifier))vi(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 vi(r,e,t){let s=ki(r),n={fromPath:t.filePath,toPath:"",rawSpecifier:e,isStyle:C(e),type:"re-export"};s.length>0&&(n.symbols=s),t.imports.push(n)}function ki(r){return r.exportClause?l.default.isNamedExports(r.exportClause)?r.exportClause.elements.map(e=>e.name.text):[]:["*"]}function wi(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,Yr(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,Yr(n,s,r,e.sourceFile))}}}function Ci(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:C(t.text),type:"dynamic"}):l.default.isIdentifier(r.expression)&&r.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.text,isStyle:C(t.text),type:"require"}))}function Fi(r,e){let t=jt.default.basename(r).toLowerCase(),s=jt.default.extname(r).toLowerCase();return Q().some(o=>t.includes(o))?"test":Jt(t)?"config":e.imports.some(o=>Ue().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>Ke()?"barrel":"logic"}function Lt(r){return l.default.canHaveModifiers(r)&&l.default.getModifiers(r)?.some(e=>e.kind===l.default.SyntaxKind.ExportKeyword)===!0}function Ei(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=Ai(n);if(o){let i=Pi(n);i&&De(i,o,s,t);continue}l.default.isClassDeclaration(n)&&n.name&&Ti(n,s,t)}}function Ti(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)?De(n.body,`${s}.${n.name.text}`,e,t):l.default.isConstructorDeclaration(n)&&n.body&&De(n.body,`${s}.constructor`,e,t)}function Ai(r){if(Lt(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 Pi(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 De(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=>De(n,e,t,s))}function je(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 Ot=g(require("postcss")),Ii=require("postcss-less"),rs=new Set(["reference","inline"]);function ts(r){return r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("data:")}function Mi(r){let e=r.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Ri(r,e){let t=r.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(t){let o=t[1]?.trim()??"",i=t[2]??"";if(!i)return null;let a=rs.has(o)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...ts(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",...ts(n)?{isExternal:!0}:{}}:null}function Ni(r,e){let t=[],s=/url\(['"]?([^'")]+)['"]?\)/g,n=s.exec(r);for(;n!==null;){let o=n[1]?.trim()??"";Mi(o)&&t.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),n=s.exec(r)}return t}function ss(r,e){let t=[];return r.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let n=Ri(s.params,e);n&&t.push(n)}s.type==="decl"&&t.push(...Ni(s.value,e))}),t}function Gi(r){return r.replace(/(?<!:)\/\/.*/g,"")}function Di(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=rs.has(o)?"side-effect":"static";t.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}n=s.exec(r)}return t}function ns(r,e){let t=Ot.default.parse(Gi(r));return{imports:ss(t,e),root:t}}function os(r,e){try{let t=Ii.parse(r);return{imports:ss(t,e),root:t}}catch{return{imports:Di(r,e),root:Ot.default.parse("")}}}var is=require("postcss-scss");function ji(r){return!!(r.startsWith("sass:")||r.startsWith("~")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||!r.startsWith(".")&&!r.startsWith("/")&&!r.startsWith("_"))}function _i(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 as(r,e){let t=(0,is.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}=_i(i);if(!a)return;let c={fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:o==="forward"?"re-export":"static",...ji(a)?{isExternal:!0}:{}};p&&(c.symbols=[p]),s.push(c)}),{imports:s,root:t}}function ps(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 ie(r,e){let t=I(r);if(t==="stylus"){let o=ps(e,r);return{imports:o,exports:[],tags:[],category:cs(e,o)}}if(t==="scss"){let{imports:o,root:i}=as(e,r);return{imports:o,exports:[],tags:[],category:je(i,o)}}if(t==="less"){let{imports:o,root:i}=os(e,r);return{imports:o,exports:[],tags:[],category:je(i,o)}}let{imports:s,root:n}=ns(e,r);return{imports:s,exports:[],tags:[],category:je(n,s)}}for(let[r,e]of[["javascript",(t,s)=>_t(t,s,"javascript")],["typescript",(t,s)=>_t(t,s,"typescript")],["css",ie],["scss",ie],["less",ie],["stylus",ie],["coffeescript",Or],["livescript",Kr],["lua",Hr],["python",Xr],["go",Ur],["gherkin",Rt]])L(r,e);async function ls(r,e){let t=I(r),s=br(t);return s?s(r,e):{imports:[],exports:[],tags:[],category:"other"}}var _e=g(require("path"));function fs(r,e){for(let t of r.values()){let s=e.get(t.path);s!==void 0&&(t.coveragePct=s)}}function gs(r,e){for(let t of r)if(!t.rawSpecifier.startsWith(".")&&!_e.default.isAbsolute(t.rawSpecifier)){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 ms(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 us(r){return Math.round(r*1e4)/1e4}function ds(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=us(Math.min(1,o)),t.push(s.exportUsageRatio)}t.length>0&&(e.avgExportUsage=us(t.reduce((s,n)=>s+n,0)/t.length),e.maxExportUsage=Math.max(...t))}}function Wt(r,e,t){e&&(r.some(s=>s.name===e&&s.kind===t)||r.push({name:e,kind:t}))}function Li(r,e){let t=e.toPath,s=_e.default.basename(t,_e.default.extname(t)).replace(/\.(test|spec)$/,"");Wt(r.tags,s,"import")}function Oi(r,e){if(!(!e.symbols||e.symbols.includes("*")))for(let t of e.symbols)Wt(r.tags,t,"import")}function Wi(r,e,t){let s=t.get(e.toPath);if(!(!s||s.category==="test"))for(let n of s.tags)n.kind==="comment-marker"&&Wt(r.tags,n.name,"comment-marker")}function hs(r){for(let e of r.values())if(e.category==="test")for(let t of e.imports)!t.toPath||t.isExternal||(Li(e,t),Oi(e,t),Wi(e,t,r))}var le=g(require("fs")),A=g(require("path"));var zt=g(require("fs")),G=g(require("path")),ae=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 xs(a);if(t!==o&&!t.startsWith(`${o}/`))return null;let p=t.slice(o.length).replace(/^\//,"");return p?xs(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=zi(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 zi(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("=>")){ys(a,e,n);continue}!o&&/^replace\s+/.test(a)&&a.includes("=>")&&ys(a.replace(/^replace\s+/,""),e,n)}return{mod:s,replaces:n}}function ys(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 xs(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 Ss=g(require("fs")),Le=g(require("path")),pe=class{extensions=[".lua"];resolve(e,t,s,n){let o=t.replace(/\./g,Le.default.sep),i=[s,Le.default.join(s,"lib")];for(let a of i){if(!Ss.default.existsSync(a))continue;let p=n(Le.default.join(a,"_dummy.lua"),o);if(p)return[p]}return null}};var vs=g(require("fs")),Oe=g(require("path")),ce=class{extensions=[".py"];resolve(e,t,s,n){let o=t.replace(/\./g,Oe.default.sep),i=Oe.default.join(s,`${o}.py`);if(bs(i))return[{path:i,isExternal:!1}];let a=Oe.default.join(s,o,"__init__.py");return bs(a)?[{path:a,isExternal:!1}]:null}};function bs(r){try{return vs.default.statSync(r,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var J=class{constructor(e,t={}){this.rootDir=e;this.workspaceMap=t.workspaceMap??new Map,this.tsconfigSearchPaths=t.tsconfigSearchPaths??[e],this.langResolvers=t.langResolvers??[new ce,new pe,new ae]}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=A.default.dirname(e),n=t.startsWith("/")?t:A.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 u=this.tryExtensions(p,c,o);if(u)return u}}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=A.default.join(e,`index${t}`);if(this.isFile(o))return{path:o,isExternal:s};if(t===".py"){let i=A.default.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:s}}return null}isFile(e){try{return le.default.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){for(let t of this.tsconfigSearchPaths){let s=A.default.join(t,"tsconfig.json");if(le.default.existsSync(s))try{let o=JSON.parse(le.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=A.default.resolve(s,i);for(let p of n){let c=this.tryExtensions(a,p,!1);if(c)return c}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[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=A.default.join(s,a);try{if(le.default.statSync(p,{throwIfNoEntry:!1})?.isFile())return{...o,path:p}}catch{}}return{...o,path:s}}let i=this.resolveLocalPath(A.default.join(s,"_dummy"),n.slice(1));return i?{...o,path:i.path}:null}return null}};var $i=["tests","test","__tests__","specs","spec"];function Bi(r,e){if(r.length===0)return e;let t=r.map(i=>k.default.dirname(i).split(k.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(k.default.sep)||k.default.sep,o=k.default.relative(e,n);return o.startsWith("..")||k.default.isAbsolute(o)?e:n}var fe=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 J(e),this.lockFile=_r(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=>k.default.isAbsolute(s)?s:k.default.resolve(this.rootDir,s));for(let s of t)await this.processFile(s);return await this.processTestFiles(Bi(t,this.rootDir)),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
24
+ Done. Total processed: ${this.visited.size} nodes.
25
+ `),hs(this.graph.nodes),ms(this.graph.nodes),ds(this.graph.nodes),this.coverageMap.size>0&&fs(this.graph.nodes,this.coverageMap),new T(this.graph.nodes)}async processTestFiles(e){let t=Q(),s=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),n=async i=>{let a;try{a=ue.default.readdirSync(i,{withFileTypes:!0})}catch{return}for(let p of a){let c=k.default.join(i,p.name);p.isDirectory()?s.has(p.name)||await n(c):p.isFile()&&t.some(u=>p.name.includes(u))&&await this.processFile(c)}};await n(e);let o=e;for(;o!==this.rootDir;){let i=k.default.dirname(o);if(i===o)break;for(let a of $i){let p=k.default.join(i,a);try{ue.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=ue.default.statSync(e,{throwIfNoEntry:!1});if(!t?.isFile())return;let s=k.default.relative(this.rootDir,e),n=await this.getNode(e,s,t);n.imports=await this.resolveImports(e,n.imports),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);gs(o.imports,o.tags);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=ue.default.readFileSync(e,"utf-8");try{return await ls(e,s)}catch(n){return process.stderr.write(`
26
+ 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:k.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:u,complexity:f,cognitiveComplexity:m,functions:x}=n;return{path:t,type:I(e),category:c,imports:i,exports:a,tags:p,mtime:s.mtimeMs,size:s.size,...u!==void 0?{description:u}:{},...o.length>0?{callEdges:o}:{},...f!==void 0?{complexity:f}:{},...m!==void 0?{cognitiveComplexity:m}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,t){if(this.enableGitStats)try{let s=Gr(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:k.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 ks(r,e){return{identifier:e?.identifier??new Ne,featureMap:e?.featureDetection===!1?new Map:M(r.nodes,e?.featureDetection??void 0)}}function ws(r,e,t,s,n){for(let o of e){let i=r.nodes.get(o);if(!i)continue;let a=new R(o,["*",...i.exports.map(p=>p.name)]);r.traverse(o,(p,c,u)=>{if(!u)return!0;if(!a.updateAffectedSymbols(p,u))return!1;if(c>0){let f=t.get(p.path);if(f)return s(f),!1}return n(p),!0},{direction:"incoming"})}}function $t(r,e,t){let{identifier:s,featureMap:n}=ks(r,t),o=new Set;for(let i of e){let a=n.get(i);a&&o.add(a.tag)}return ws(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 Bt(r,e,t){let{identifier:s,featureMap:n}=ks(r,t),o=new Set;return ws(r,e,n,()=>{},i=>{s.isTestNode(i)&&o.add(i.path)}),Array.from(o)}var Cs=g(require("fs")),H=g(require("path"));async function Fs(r,e,t=null,s={}){let n=s.silent?void 0:i=>{process.stderr.write(`Processed ${i} files...\r`)};return await new fe(H.default.resolve(r),t,void 0,n,s.gitStats??!1,s.coverageMap??new Map).build(e)}async function Es(r,e={}){let t=H.default.resolve(r),s=te(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 re(t,s.type);for(let a of n){let p=e.silent?void 0:f=>{process.stderr.write(`[${a.name}] Processed ${f} files...\r`)},u=await new fe(t,null,new J(t,{workspaceMap:o,tsconfigSearchPaths:[a.root,t]}),p,e.gitStats??!1).build(a.entryPoints);i.addPackage(a,u)}return i}function Ts(r,e={}){let t=[],s=new Set([...e.ignoreDirs??Qe,...e.additionalIgnoreDirs??[]]),n=new Set([...e.extensions??Ve,...e.additionalExtensions??[]]);function o(i){try{let a=Cs.default.readdirSync(i,{withFileTypes:!0});for(let p of a){let c=H.default.join(i,p.name);p.isDirectory()?s.has(p.name)||o(c):p.isFile()&&n.has(H.default.extname(p.name).toLowerCase())&&t.push(H.default.relative(r,c))}}catch{}}return o(r),t}var Ui=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/,We=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 Fs(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 Es(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=nt(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=As.default.watch(e,{recursive:!0},(s,n)=>{!n||Ui.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 D=g(require("path"));var Ps=g(require("fs")),Is=g(require("os")),ze=g(require("path"));function y(r){return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}function Ms(r){if(!ze.default.isAbsolute(r))throw new Error("root must be an absolute path");let e=ze.default.resolve(r),t=Is.default.homedir();if(e!==t&&!e.startsWith(t+ze.default.sep))throw new Error("root must be within the user home directory");let s;try{s=Ps.default.statSync(e)}catch{throw new Error("root does not exist")}if(!s.isDirectory())throw new Error("root is not a directory")}async function Rs(r,e){let{root:t,entryPoints:s}=e;if(!r.isConfigured(t)){let f=V(t,{allowJs:!1});He(f),r.storeConfig(t,f)}if(s.length===0){let f=te(t);if(f.type!=="none"){let m=r.getConfig(t),x=await r.getOrBuildWorkspace(t,{gitStats:m?.gitStats??!1});r.storeLastAnalyze(t,{kind:"workspace"}),r.startWatching(t);let E=Array.from(x.packages.values()).map(({graph:ge,pkg:Ut})=>({package:Ut.name,relativeRoot:Ut.relativeRoot,nodeCount:ge.nodes.size}));return y({monorepoType:f.type,packageCount:x.packages.size,packages:E})}}let n=s.map(f=>D.default.resolve(t,f)),o=r.getConfig(t),i=o?.coverageReportPath?Ze(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((f,m)=>(f[m.category]=(f[m.category]??0)+1,f),{}),u=a.findCycles();return y({nodeCount:p.nodes.length,categories:c,cycles:u})}async function Ns(r,e){let{root:t,file:s,depth:n=1}=e,o=await r.ensureFresh(t),i=[];return o.traverse(s,(a,p,c)=>{if(a.path===s)return!0;let u=c?o.nodes.get(c)?.imports.find(f=>f.toPath===a.path):void 0;return i.push({path:a.path,...u?.symbols?{symbols:u.symbols}:{}}),!0},{direction:"outgoing",maxDepth:n}),y({file:s,dependencies:i})}async function Gs(r,e){let{root:t,file:s}=e,n=await r.ensureFresh(t),o=[];return n.traverse(s,i=>{if(i.path===s)return!0;let a=i.imports.find(p=>p.toPath===s);return o.push({path:i.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),y({file:s,dependents:o})}async function Ds(r,e){let{root:t,file:s,testsOnly:n=!1,cached:o=!1,changedSymbols:i}=e,a=await r.ensureFresh(t);if(o){let u=r.getOrBuildChangeImpact(t),f=ot(u,s),m=n?f.filter(x=>a.nodes.get(x)?.category==="test"):f;return y({file:s,affected:m,count:m.length})}let p=i?new R(s,i):null,c=[];return a.traverse(s,(u,f,m)=>{if(u.path===s)return!0;if(p&&m&&!p.updateAffectedSymbols(u,m))return!1;let x=u.category==="test"||u.tags.some(E=>E.name==="test");return(!n||x)&&c.push(u.path),!0},{direction:"incoming"}),y({file:s,affected:c,count:c.length})}async function js(r,e){let{root:t,file:s,depth:n=1,withEdgeDetail:o=!1}=e,i=await r.ensureFresh(t),a=[];return i.traverseCalls(s,p=>{if(p.path===s)return!0;let c={file:p.path};return o&&(c.edges=(p.callEdges??[]).filter(u=>u.toFile===s).map(u=>({from:u.from,to:u.to}))),a.push(c),!0},{direction:"incoming",maxDepth:n}),y({file:s,callers:a,count:a.length})}async function _s(r,e){let{root:t,entryPoints:s}=e,n=s.map(p=>D.default.resolve(t,p)),o=await r.getOrBuild(t,n),i=Ts(t),a=o.findUnusedFiles(i);return y({unusedFiles:a,count:a.length})}async function Ls(r,e){let{root:t,coverageThreshold:s}=e,n=await r.ensureFresh(t),o=r.getConfig(t),i=s??o?.coverageThreshold??80;if(![...n.nodes.values()].some(c=>c.coveragePct!==void 0))return y({error:"No coverage data available. Set coverageReportPath in mokosh.config and call analyze again."});let p=[...n.nodes.values()].filter(c=>c.category!=="test"&&c.category!=="config").filter(c=>c.coveragePct!==void 0&&c.coveragePct<i).map(c=>({file:c.path,coveragePct:c.coveragePct}));return y({threshold:i,uncovered:p,count:p.length})}async function Os(r,e){let{root:t,metric:s="cognitiveComplexity",threshold:n=10,limit:o=20}=e,a=[...(await r.ensureFresh(t)).nodes.values()].flatMap(p=>(p.functions??[]).filter(c=>c[s]>=n).map(c=>({file:p.path,name:c.name,line:c.line,complexity:c.complexity,cognitiveComplexity:c.cognitiveComplexity}))).sort((p,c)=>c[s]-p[s]).slice(0,o);return y({metric:s,threshold:n,functions:a,count:a.length})}async function Ws(r,e){let{root:t,changedFiles:s,featureThreshold:n,format:o="tags"}=e,i=await r.ensureFresh(t),a=s??new Ge().getChangedFiles().map(u=>D.default.relative(t,D.default.resolve(t,u))),p=n!==void 0?{featureDetection:{minOutDegree:n}}:void 0;if(o==="paths"){let u=Bt(i,a,p);return y({changedFiles:a,affectedTests:u,count:u.length})}let c=$t(i,a,p);return y({changedFiles:a,proposedTags:c})}async function zs(r,e){let{root:t,entryPoints:s,featureThreshold:n}=e,o=s?await r.getOrBuild(t,s.map(p=>D.default.resolve(t,p))):await r.ensureFresh(t),i=M(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 $s(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=>D.default.resolve(t,c))):await r.ensureFresh(t),p=we(a.serialize(),Ce(n));if(o)return y(Se.serialize(T.deserialize(p)));if(i){let c=p.nodes.map(u=>({path:u.path,type:u.type,category:u.category,exports:u.exports.map(f=>f.name),tags:u.tags.filter(f=>f.kind==="comment-marker"||f.kind==="import").map(f=>f.name),importsFiles:u.imports.filter(f=>!f.isExternal&&f.toPath).map(f=>f.toPath),...u.description!==void 0&&{description:u.description},...u.testedBy!==void 0&&{testedBy:u.testedBy},...u.coveragePct!==void 0&&{coveragePct:u.coveragePct},...u.avgExportUsage!==void 0&&{avgExportUsage:u.avgExportUsage},...u.maxExportUsage!==void 0&&{maxExportUsage:u.maxExportUsage}}));return y({nodes:c,cycles:p.cycles})}return y(p)}async function Bs(r,e){let{root:t}=e,s=await r.ensureFreshWorkspace(t),n=s.getPackageDependencies(),o=Array.from(s.packages.values()).map(({graph:i,pkg:a})=>({name:a.name,relativeRoot:a.relativeRoot,nodeCount:i.nodes.size,dependsOn:n.get(a.name)??[]}));return y({monorepoType:s.type,packageCount:o.length,packages:o})}async function Us(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 qs(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 Ks(r,e){let{root:t,type:s}=e,n=await r.ensureFresh(t),o=at(n);if(s)return y(pt(o,s));let i=Array.from(o.types.values());return y({count:i.length,types:i})}async function Js(r,e){let{root:t,paths:s,minOutDegree:n}=e,o=await r.ensureFresh(t),i=it(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 Hs(r,e){let{root:t,minOutDegree:s}=e,n=await r.ensureFresh(t),o=Z(n,s!==void 0?{minOutDegree:s}:void 0),i=Object.fromEntries(o.features);return y({features:i,unassigned:o.unassigned})}async function Qs(r,e){let{root:t,function:s}=e,n=await r.ensureFresh(t);return y(st(n,s))}async function Vs(r,e){let{root:t,entryPoints:s}=e,n=await r.ensureFresh(t),o=s?.length?s:tt(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(rt(n,o))}async function Xs(r,e){let t=await r.ensureFresh(e.root),s=await Tt(t,e.root,{dryRun:e.dryRun??!1});return y(s)}var Zs=[{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 Be(){let r=new We,e=new Ys.Server({name:"mokosh",version:"0.0.1"},{capabilities:{tools:{}}});return e.setRequestHandler($e.ListToolsRequestSchema,async()=>({tools:Zs})),e.setRequestHandler($e.CallToolRequestSchema,async t=>{let{name:s,arguments:n}=t.params,o=n,a={analyze:p=>Rs(r,p),get_dependencies:p=>Ns(r,p),get_dependents:p=>Gs(r,p),get_affected:p=>Ds(r,p),get_callers:p=>js(r,p),find_unused:p=>_s(r,p),find_uncovered:p=>Ls(r,p),find_complex_functions:p=>Os(r,p),propose_tags:p=>Ws(r,p),detect_features:p=>zs(r,p),get_type_graph:p=>Ks(r,p),get_module_responsibility:p=>Js(r,p),get_feature_graph:p=>Hs(r,p),get_call_graph:p=>Qs(r,p),get_api_surface:p=>Vs(r,p),query:p=>$s(r,p),get_workspace_packages:p=>Bs(r,p),get_workspace_affected:p=>Us(r,p),clear_cache:p=>qs(r,p),apply_tags:p=>Xs(r,p)}[s];if(!a)throw new Error(`Unknown tool: ${s}`);try{return Ms(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 qi(){let r=Be(),e=new en.StdioServerTransport;await r.connect(e)}qi().catch(console.error);0&&(module.exports={createMcpServer});
28
+ //# sourceMappingURL=mcp.js.map