@easbot/codebase 0.3.24 → 0.3.26

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.
Files changed (33) hide show
  1. package/dist/chunks/{chunk-5E5YY2J3.cjs → chunk-3IB5XZ2D.cjs} +22 -22
  2. package/dist/chunks/{chunk-EWVG3S6R.mjs → chunk-7CL37IYG.mjs} +6 -2
  3. package/dist/chunks/{chunk-STDI2Q67.mjs → chunk-ICEJ23S3.mjs} +1 -1
  4. package/dist/chunks/{chunk-NF6CVHEK.cjs → chunk-JCJFUUU2.cjs} +4 -4
  5. package/dist/chunks/chunk-QMTGRU63.mjs +47 -0
  6. package/dist/chunks/chunk-TGCR6O3S.cjs +62 -0
  7. package/dist/chunks/{chunk-PLI6SXTS.cjs → chunk-UHNJOT5S.cjs} +6 -2
  8. package/dist/chunks/chunk-WRM2FP4O.mjs +62 -0
  9. package/dist/chunks/cli-handler-FQ7LQDAN.cjs +1 -0
  10. package/dist/chunks/cli-handler-Z6VGOAMV.mjs +1 -0
  11. package/dist/chunks/code-base-BFLIOZXA.cjs +1 -0
  12. package/dist/chunks/{code-base-Y6HLPDF3.mjs → code-base-DMVLROV6.mjs} +1 -1
  13. package/dist/chunks/database-manager-GT3LOQUV.cjs +1 -0
  14. package/dist/chunks/database-manager-N5WLNG3F.mjs +1 -0
  15. package/dist/chunks/stdio-server-4X7YFQA2.mjs +30 -0
  16. package/dist/chunks/stdio-server-5UQVBBZP.cjs +30 -0
  17. package/dist/cli.cjs +1 -1
  18. package/dist/cli.mjs +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +26 -3
  21. package/dist/index.d.ts +26 -3
  22. package/dist/index.mjs +1 -1
  23. package/package.json +8 -8
  24. package/dist/chunks/chunk-AIUVBWJX.mjs +0 -47
  25. package/dist/chunks/chunk-SQJ64NFE.mjs +0 -58
  26. package/dist/chunks/chunk-WC5CUSXD.cjs +0 -58
  27. package/dist/chunks/cli-handler-SF3CJR3N.mjs +0 -1
  28. package/dist/chunks/cli-handler-WMBILZ4H.cjs +0 -1
  29. package/dist/chunks/code-base-DJZICYWH.cjs +0 -1
  30. package/dist/chunks/database-manager-MOJW62MZ.cjs +0 -1
  31. package/dist/chunks/database-manager-X7H4U45I.mjs +0 -1
  32. package/dist/chunks/stdio-server-OHQSGNMK.cjs +0 -47
  33. package/dist/chunks/stdio-server-OJGV4CSS.mjs +0 -47
@@ -1,58 +0,0 @@
1
- 'use strict';var chunkNF6CVHEK_cjs=require('./chunk-NF6CVHEK.cjs'),chunkM2YU5LAI_cjs=require('./chunk-M2YU5LAI.cjs'),utils=require('@easbot/utils'),types=require('@easbot/types');var T=class extends Error{constructor(n,c,a){super(n);chunkM2YU5LAI_cjs.a(this,"code",c);chunkM2YU5LAI_cjs.a(this,"details",a);this.name="ServiceError";}},w=class extends T{constructor(e,n=[]){super(`Node not found: ${e}`,"NOT_FOUND",{name:e,candidates:n});}},k=class extends T{constructor(e,n){super(`Ambiguous name "${e}" \u2014 ${n.length} candidates`,"AMBIGUOUS",{name:e,candidates:n});}};var re=utils.Log.create({service:"codebase-service"}),R=utils.Filesystem.toUnixPath;function Pe(t,e){let n={exact:1,qualified:.85,substring:.5}[t];return e?Math.min(1,n+.2):n}function Se(t,e){if(!e)return false;if(t===e)return true;let n=t.split(/[/\\]/).pop()??"",c=e.split(/[/\\]/).pop()??"";return !!(n&&c&&n===c||e.includes("/")&&t.endsWith("/"+e))}async function M(t,e,n){if(n.nodeId){let o=t.getNode(n.nodeId);if(!o)throw new w(`nodeId=${n.nodeId}`);return {node:o,candidates:[]}}if(!n.name)throw new T("Either name or nodeId is required","NOT_FOUND",n);let a=t.getDatabase().findNodesByName({name:n.name,file:n.file,kind:n.kind,limit:50});if(a.length===0)throw new w(n.name);let i=!!n.file,d=n.file?R(n.file):null,s=a.map(o=>{let p=d?Se(R(o.node.file_path),d):false;return {node:o.node,score:Pe(o.matchKind,p),matchKind:o.matchKind,inFile:p}});if(s.sort((o,p)=>p.score-o.score),s.length===1)return {node:s[0].node,candidates:s.map(o=>({node:o.node,score:o.score}))};let l=s[0].score,r=s.filter(o=>o.score===l);if(r.length===1)return {node:r[0].node,candidates:s.slice(0,10).map(o=>({node:o.node,score:o.score}))};if(i&&r.length>1){let o=r.filter(p=>p.inFile);if(o.length===1)return {node:o[0].node,candidates:s.slice(0,10).map(p=>({node:p.node,score:p.score}))}}throw new k(n.name,s.slice(0,10).map(o=>({node:o.node,score:o.score})))}async function P(t){let e=chunkNF6CVHEK_cjs.c(t.rootDir),n=new chunkNF6CVHEK_cjs.s({workspaceDir:t.workspaceDir,database:{path:e,walMode:true},embedding:types.DEFAULT_EMBEDDING_CONFIG,indexer:types.DEFAULT_INDEXER_CONFIG,parser:types.DEFAULT_PARSER_CONFIG,search:types.DEFAULT_SEARCH_CONFIG,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});return await n.initialize(),n}function oe(t,e,n,c){let a=n.map(()=>"?").join(","),i=e.name.split("@")[0]??e.name,d=i.includes(".")?i.split(".").pop()??i:i,s=new Set([`${e.language}:*:*:${i}`]);d!==i&&s.add(`${e.language}:*:*:${d}`);let l=[];d!==i&&l.push(`${e.language}:*:*:%${d}`);let r=Array.from(s),o=r.map(()=>"?").join(","),u=l.length>0?"OR LOWER(target) LIKE LOWER(?)":"";r.length>1&&re.warn("queryIncomingEdgesWithWildcard: multi-variant wildcards (bare+namespaced)",{rootName:e.name,wildcards:r,hint:"\u540C\u540D\u540C namespace \u4E0D\u540C file \u7684\u65B9\u6CD5\u53EF\u80FD\u90FD\u88AB\u547D\u4E2D\uFF0CLLM \u63A8\u7406\u8BF7\u7528 file \u8FC7\u6EE4\u8F85\u4F50"});let g=`
2
- SELECT id, source, target, relation, created_at FROM edges
3
- WHERE relation IN (${a})
4
- AND source != target
5
- AND (
6
- target = ?
7
- OR target IN (${o})
8
- ${u}
9
- )
10
- GROUP BY id
11
- LIMIT ?
12
- `;return t.queryAll(g,[...n,e.id,...r,...l,c])}function Ie(t){return t==="class_declaration"||t==="class_definition"||t==="interface_declaration"||t==="struct_declaration"||t==="struct_specifier"||t==="record_declaration"}function Te(t,e,n,c,a){let d=t.queryAll("SELECT id FROM nodes WHERE file_path = ? AND start_line >= ? AND end_line <= ? AND ast_type IN ('method_definition', 'method_declaration') LIMIT 1000",[e.file_path,e.start_line,e.end_line]).map(r=>r.id),s=new Set,l=[];for(let r of n)r.id&&!s.has(r.id)&&(s.add(r.id),l.push(r));if(d.length>0){let r=c.map(()=>"?").join(","),o=d.map(()=>"?").join(","),p=`
13
- SELECT id, source, target, relation, created_at FROM edges
14
- WHERE relation IN (${r})
15
- AND source != target
16
- AND source IN (${o})
17
- GROUP BY id
18
- LIMIT ?
19
- `,u=t.queryAll(p,[...c,...d,a]);for(let g of u)g.id&&!s.has(g.id)&&(s.add(g.id),l.push(g));}return l.slice(0,a)}function se(t,e,n,c){let i=`
20
- SELECT id, source, target, relation, created_at FROM edges
21
- WHERE relation IN (${n.map(()=>"?").join(",")})
22
- AND source != target
23
- AND source = ?
24
- LIMIT ?
25
- `;return t.queryAll(i,[...n,e.id,c])}function ie(t,e,n,c){let a=c==="in"?t.source:t.target;e.id;let d=n.getNodeById(a);if(!d&&a.includes(":*:")){let s=a.split(":").pop()??a,l=s.split("@")[0]??s;if(l&&l!==a){let r=n.findNodesByName({name:l}),o=e.file_path??"",p=o.split(/[/\\]/).pop()??"",u=r.find(g=>!g.node.file_path||!o?false:g.node.file_path===o||p&&g.node.file_path.split(/[/\\]/).pop()===p)??null;u&&(d=u.node);}}if(!d){let s=a.split(":").pop()??a;return {id:a,name:s,astType:"unresolved",filePath:"(unresolved)",startLine:0,relation:t.relation}}return {id:d.id,name:d.name,astType:d.ast_type,filePath:R(d.file_path),startLine:d.start_line??0,relation:t.relation}}async function ae(t,e){let n=Date.now(),d=await(await P(t)).getQuery().search(e.query??"",{maxResults:e.maxResults??10,language:e.language,filePath:e.file,astType:e.astType,includeEdges:true,enableFts:e.enableFts!==false,enableEmbedding:e.enableEmbedding!==false});if(e.kind){let r=e.kind.toLowerCase();d=d.filter(o=>o.ast_type.includes(r)||o.name.toLowerCase().includes(r));}if(e.file){let r=R(e.file);d=d.filter(o=>R(o.file_path).endsWith(r)||R(o.file_path).includes(r));}let s=e.maxEdgesPerNode??10,l=d.map(r=>({nodeId:r.id,name:r.name,kind:r.ast_type??"unknown",filePath:R(r.file_path),startLine:r.start_line,endLine:r.end_line,edges:(r.edges??[]).slice(0,s),source:"basic",score:0,snippet:(r.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:l.length,hits:l,durationMs:Date.now()-n,truncated:false}}async function Ce(t,e){let n=await P(t),c=n.getQuery(),a=n.getDatabase(),{node:i}=await M(c,t,e),d=[];if(e.includeEdges){let s=e.maxEdgesPerNode??10,l=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"],r=oe(a,i,l,s+1),o=se(a,i,l,s+1),p=new Set,u=[];for(let g of [...r,...o])g.id&&!p.has(g.id)&&(p.add(g.id),u.push(g));d=u.slice(0,s);}return {node:i,edges:d}}var Le=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function $e(t,e){let n=await P(t),c=n.getQuery(),a=n.getDatabase(),{node:i}=await M(c,t,e);if(!i)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let d=e.depth??2,s=e.maxNodes??100,l=e.direction??"both";e.maxEdgesPerNode??10;let o=new Map,p=[{nodeId:i.id,depth:0}];o.set(i.id,0);let u=[],g=false;for(;p.length>0;){let m=p.shift();if(m.depth>=d)continue;if(o.size>=s){g=true;break}let $=c.queryNeighbors(m.nodeId,{direction:l,relationTypes:e.relationTypes??Le,limit:s-o.size+1});for(let b of $.edges){u.push(b);let F=b.source===m.nodeId?b.target:b.source;if(!o.has(F)&&(o.set(F,m.depth+1),p.push({nodeId:F,depth:m.depth+1}),o.size>=s)){g=true;break}}if(g)break}let f=new Set,N=[];for(let m of u)!m.id||f.has(m.id)||(f.add(m.id),N.push(m));let h=Array.from(o.keys()),I=h.length>0?a.queryNodes({ids:h}):[],C=new Map(I.map(m=>[m.id,m])),E=[];for(let[m,$]of o.entries()){let b=C.get(m);b&&E.push({node:b,depth:$});}return {root:i,nodes:E,edges:N,truncated:g,totalNodes:E.length,totalEdges:u.length}}var Fe=["CALLS","IMPORTS","TYPE_REFERENCES"];async function _e(t,e){let n=await P(t),c=n.getQuery(),a=n.getDatabase(),{node:i}=await M(c,t,e);if(!i)return {root:null,totalImpacted:0,buckets:[]};let d=e.depth??2,s=e.maxResults??10,l=e.relationTypes??Fe,r=e.maxEdgesPerNode??10,o=new Set([i.id]),p=[],u=[i.id],g=new Map([[i.id,i.name]]);for(let f=1;f<=d&&!(u.length===0||o.size-1>=s);f++){u.map(()=>"?").join(",");let h=l.map(()=>"?").join(","),I=i,C=u.flatMap(x=>{let D=g.get(x)??"",_=D.split("@")[0]??D,A=new Set([`${I.language}:*:*:${_}`]);if(_.includes(".")){let Q=_.split(".").pop()??_;A.add(`${I.language}:*:*:${Q}`);}return Array.from(A)}),E=[...u,...C],m=E.map(()=>"?").join(","),$=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${m}) AND relation IN (${h}) LIMIT ?`,[...E,...l,r+1]),b=[],F=new Set;for(let x of $)if(!o.has(x.source)&&!F.has(x.source)&&(F.add(x.source),o.add(x.source),b.push(x.source),o.size-1>=s))break;if(b.length>0){let x=b.slice(0,10),D=a.queryNodes({ids:x}),_=new Map(D.map(y=>[y.id,y]));for(let y of D)y?.name&&!g.has(y.id)&&g.set(y.id,y.name);let A=new Map;for(let y of $)A.has(y.source)||A.set(y.source,y.relation);let Q=x.map(y=>{let Y=_.get(y);return {id:y,name:Y?.name??"(unknown)",filePath:Y?R(Y.file_path):"(unknown)",relation:A.get(y)??"CALLS"}});p.push({depth:f,count:b.length,sample:Q});}u=b;}return p.length===0&&re.warn("impact: no incoming edges found",{root:i.name,depth:d,relationTypes:l}),{root:i,totalImpacted:o.size-1,buckets:p}}var le=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function Ae(t,e){return ce(t,e)}async function we(t,e){return de(t,e)}async function ce(t,e){let n=await P(t),c=n.getQuery(),a=n.getDatabase(),{node:i}=await M(c,t,e);if(!i)return {root:null,callers:[],truncated:false};let d=e.maxResults??10,s=e.maxEdgesPerNode??d,l=e.relationTypes??le,r=oe(a,i,l,s+1),o=[];for(let u of r){let g=ie(u,i,a,"in");g&&o.push(g);}let p=o.length>d;return {root:i,callers:p?o.slice(0,d):o,truncated:p}}async function de(t,e){let n=await P(t),c=n.getQuery(),a=n.getDatabase(),{node:i}=await M(c,t,e);if(!i)return {root:null,callees:[],truncated:false};let d=e.maxResults??10,s=e.maxEdgesPerNode??d,l=e.relationTypes??le,r=se(a,i,l,s+1),o=Ie(i.ast_type)?Te(a,i,r,l,s+1):r,p=[];for(let g of o){let f=ie(g,i,a,"out");f&&p.push(f);}let u=p.length>d;return {root:i,callees:u?p.slice(0,d):p,truncated:u}}async function Oe(t,e){if(!e.query)throw new T("explore requires a non-empty query","NOT_FOUND",{query:e.query});let c=await P(t);c.getQuery();let i=c.getDatabase(),s=(await ae(t,{query:e.query,file:e.file,kind:e.kind,intent:e.intent,maxResults:e.maxFiles??5,enableFts:true,enableEmbedding:true})).hits,l=new Map;for(let u of s){let g=R(u.filePath),f=l.get(g);f?f.push(u):l.set(g,[u]);}let r=e.maxSymbols??3,o=e.maxEdgesPerNode??10,p=[];for(let[u,g]of l){let f=g.slice(0,r),N=[];for(let h of f){let I=await ce(t,{name:h.name,file:u,kind:e.kind,maxResults:o,maxEdgesPerNode:o}),C=await de(t,{name:h.name,file:u,kind:e.kind,maxResults:o,maxEdgesPerNode:o});N.push({node:(()=>{let E={id:h.nodeId,name:h.name,ast_type:h.kind,language:"ts",file_path:h.filePath,start_line:h.startLine??0,end_line:h.endLine??0};try{let m=i.getNodeById(h.nodeId);return {...E,text:m?.text??""}}catch{return {...E,text:""}}})(),callers:I.callers,callees:C.callees});}p.push({file:u,symbols:N});}return {query:e.query,entryPoints:p,totalHits:s.length}}async function De(t,e){return await(await P(t)).getStatus()}async function ke(t,e){return await(await P(t)).healthCheck()}var ue=utils.Filesystem.toUnixPath;function ve(t){let e=t.text??"";if(!e)return false;let n=e.slice(0,80);return /\bexport\s/.test(n)||/\bpublic\s/.test(n)?true:(false)}function He(t){let e=t.text??"";if(!e)return [];let n=e.slice(0,80),c=[];return /\basync\s/.test(n)&&c.push("async"),/\bstatic\s/.test(n)&&c.push("static"),/\babstract\s/.test(n)&&c.push("abstract"),/\breadonly\s/.test(n)&&c.push("readonly"),/\bconst\s/.test(n)&&c.push("const"),/\blet\s/.test(n)&&c.push("let"),c}function S(t){return {id:t.id,name:t.name,astType:t.ast_type,language:t.language,filePath:ue(t.file_path),startLine:t.start_line??0,endLine:t.end_line??0,isExported:ve(t),modifiers:He(t)}}function O(t,e){return {id:t.id,source:t.source,target:t.target,relation:t.relation,direction:e}}function X(t){return t.map(e=>({node:{id:e.nodeId,name:e.name,astType:e.kind,language:"typescript",filePath:ue(e.filePath),startLine:e.startLine??0,endLine:e.endLine??0,isExported:false,modifiers:[]},source:e.source,score:e.score,snippet:(e.snippet??"").slice(0,200),edges:(e.edges??[]).slice(0,10).map(n=>O({...n}))}))}function V(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var Be=utils.Log.create({service:"codebase-format-truncate"}),J="**`",Ue="**",pe=24e3,me=25e3;async function B(t,e={}){let n=e.softLimit??pe,c=e.hardCeiling??me,a=e.toolName??"codebase",i=e.writeToDisk!==false;if(t.length<=n)return {content:t,truncated:false};let d=t.slice(0,c),s=d.lastIndexOf(`
26
- ${J}`),l=d.lastIndexOf(`
27
- `),r;s>c*.5?r=s:l>0?r=l:r=-1;let o=r>0?d.slice(0,r):d,u=o+"\n\n... (output truncated to budget; the source above is complete and verbatim \u2014 treat it as already Read. For any area not covered, make ANOTHER `<tool>` targeting those names \u2014 do NOT Read these files.)";if(!i)return {content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${t.length-o.length}/${t.length} characters truncated ...`};try{let g=await utils.TruncateContent.truncate(t,{maxChars:o.length,direction:"head",label:`${a}-output`});return g.truncated?{content:u,truncated:!0,outputPath:g.outputPath,hint:utils.TruncateContent.formatHint(g),info:`... ${g.removedLength}/${g.originalLength} characters truncated ...`}:{content:u,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${t.length-o.length}/${t.length} characters truncated ...`}}catch(g){return Be.warn("TruncateContent.truncate failed, returning without disk hint",{error:g instanceof Error?g.message:String(g)}),{content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${t.length-o.length}/${t.length} characters truncated ...`}}}function U(t,e={}){let n=e.softLimit??pe,c=e.hardCeiling??me;if(t.length<=n)return {content:t,truncated:false};let a=t.slice(0,c),i=a.lastIndexOf(`
28
- ${J}`),d=a.lastIndexOf(`
29
- `),s;i>c*.5?s=i:d>0?s=d:s=-1;let l=s>0?a.slice(0,s):a;return {content:l+`
30
-
31
- ... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${t.length-l.length}/${t.length} characters truncated ...`}}function We(t,e=Date.now()){let n=Math.max(0,Math.floor((e-t)/1e3));return n>60?">60s ago":`${n}s ago`}function W(t,e){if(!t||t.length===0)return null;let n=t.filter(a=>e.has(a.path));return n.length===0?null:`\u26A0\uFE0F Index may be stale for: ${n.map(a=>`${a.path} (edited ${We(a.lastEventAt)})`).join(", ")}
32
-
33
- `}function v(t,e,n={}){return (fe[t]??fe.default).replace(/<(\w+)>/g,(a,i)=>i==="tool"?e:n[i]??`<${i}>`)}var fe={search:`---
34
-
35
- > **Complete source for N files is included above \u2014 do NOT re-read them.**
36
- > If your question also needs files/symbols listed under "Not shown above" (or any area this call didn't cover), make ANOTHER \`<tool>\` targeting those names \u2014 it returns the same source with line numbers and is cheaper and more complete than reading.`,impact:"---\n\n> **Risk: <riskLevel>**. Before editing `<root>`, review d=1 first \u2014 those WILL BREAK.\n> Use `<tool>` to read full source of any direct caller.",context:"---\n\n> **Use `impact` for blast-radius analysis. Use `explore` to read source.**",default:`---
37
-
38
- > **Output truncated to budget; the content above is the source of truth.**
39
- > For more detail, call \`<tool>\` with refined parameters.`};async function j(t,e){let{pendingFiles:n,toolName:c,sync:a=false}=e;if(t.length===0)return H(c,"No matches found.","Try broader search terms, or use `explore` to read source.");let i=Ge(t),d=new Set(i.keys()),s=[];s.push(W(n,d)??"");let l="[[codebase-search-summary]]";s.push(l+`
40
- `);let r=t.length;s.push(`**Files with matches:** ${i.size}
41
- `);for(let[g,f]of i){let N=f.map(E=>E.node.name),h=N.slice(0,5).join(", "),I=N.length>5?`, +${N.length-5} more`:"";s.push(`**\`${g}\`** \u2014 ${h}${I}
42
- `);let C=f[0]?.node.language??"";s.push("```"+C);for(let E of f)s.push(`L${E.node.startLine} ${E.snippet}`);s.push("```\n");}s.push(v("search",c,{}));let o=s.join(`
43
- `),p=`Found ${r} symbol${r===1?"":"s"} across ${i.size} file${i.size===1?"":"s"}.`,u=o.replace(l,p);return q(u,e,a)}async function G(t,e,n){let{pendingFiles:c,toolName:a,sync:i=false}=n;if(e.length===0||e.every(r=>r.count===0))return H(a,`No incoming edges for \`${t.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let d=e.reduce((r,o)=>r+o.count,0),s=je(d),l=[];l.push(W(c,new Set([t.filePath]))??""),l.push(`**Impact for \`${t.name}\`** (root: ${t.filePath}:${t.startLine}, total impacted: ${d})
44
- `);for(let r of e){l.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let o of r.samples.slice(0,5))l.push(` - \`${o.name}\` ${o.file}:${o.line} [${o.relation}]`);r.samples.length>5&&l.push(` - ... and ${r.samples.length-5} more`);}return l.push(v("impact",a,{root:t.name,riskLevel:s})),q(l.join(`
45
- `),n,i)}function je(t){return t>=100?"CRITICAL":t>=50?"HIGH":t>=10?"MEDIUM":"LOW"}function Z(t){return t===1?"WILL BREAK (direct callers)":t===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function ee(t,e){let{root:n,incoming:c,outgoing:a,neighbors:i}=t,{pendingFiles:d,toolName:s,sync:l=false}=e;if(c.length===0&&a.length===0&&i.length===0)return H(s,`No relations found for \`${n.name}\`.`,"This is a leaf node.");let r=[];r.push(W(d,new Set([n.filePath]))??""),r.push(`**Context for \`${n.name}\`** (${n.astType}, ${n.language}, ${n.filePath}:${n.startLine})
46
- `),r.push(`**Incoming** (${c.length}):`);for(let o of c.slice(0,10))r.push(`- ${o.source} \u2192 [${o.relation}] \u2192 \`${n.name}\``);c.length>10&&r.push(`- ... and ${c.length-10} more`),r.push(""),r.push(`**Outgoing** (${a.length}):`);for(let o of a.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${o.relation}] \u2192 ${o.target}`);if(a.length>10&&r.push(`- ... and ${a.length-10} more`),r.push(""),i.length>0){r.push(`**Neighbors** (${i.length}):`);for(let o of i.slice(0,20))r.push(`- [d=${o.depth}] \`${o.node.name}\` (${o.node.astType}) ${o.node.filePath}:${o.node.startLine}`);i.length>20&&r.push(`- ... and ${i.length-20} more`),r.push("");}return r.push(v("context",s,{})),q(r.join(`
47
- `),e,l)}async function K(t,e,n){let{pendingFiles:c,toolName:a,sync:i=false}=n;if(!t.id)return H(a,"Node not found.","Check the node ID or use `search` to find it.");let d=e.filter(r=>r.direction==="in"),s=e.filter(r=>r.direction==="out"),l=[];l.push(W(c,new Set([t.filePath]))??""),l.push(`**Node: \`${t.name}\`**
48
- `),l.push(`- ID: \`${t.id}\``),l.push(`- Kind: ${t.astType}`),l.push(`- Language: ${t.language}`),l.push(`- Location: ${t.filePath}:${t.startLine}-${t.endLine}`),l.push(`- Exported: ${t.isExported}`),t.modifiers.length>0&&l.push(`- Modifiers: ${t.modifiers.join(", ")}`),l.push(""),l.push(`**Edges** (incoming: ${d.length} / outgoing: ${s.length}):`);for(let r of d.slice(0,5))l.push(`- \u2190 [${r.relation}] ${r.source}`);for(let r of s.slice(0,5))l.push(`- \u2192 [${r.relation}] ${r.target}`);return e.length>10&&l.push(`- ... and ${e.length-10} more`),l.push(v("default",a,{})),q(l.join(`
49
- `),n,i)}async function he(t,e){let{entryPoints:n,totalHits:c,query:a}=t,{toolName:i,sync:d=false}=e;if(n.length===0)return H(i,`No matches for \`${a}\`.`,"Try broader search terms, or use `callers` / `callees` to traverse from a known symbol.");let s=[];s.push(`## Code Context
50
- `),s.push(`**Query:** ${a} `),s.push(`**Total hits:** ${c} `),s.push(`**Entry points:** ${n.length}
51
- `);for(let l of n){s.push(`**\`${l.file}\`** \u2014 ${l.symbols.length} symbol${l.symbols.length===1?"":"s"}
52
- `);for(let r of l.symbols){let o=(r.source??"").trim()||"(source not included)",p=r.node.language;if(s.push("```"+p),s.push(`L${r.node.startLine}-L${r.node.endLine} ${r.node.name} (${r.node.astType}${r.node.modifiers.length>0?`, ${r.node.modifiers.join(" ")}`:""})`),s.push(""),s.push(o),s.push("```\n"),r.callers.length>0){s.push(`**Callers of \`${r.node.name}\` (${r.callers.length}):**`);for(let u of r.callers.slice(0,5))s.push(`- [${u.relation}] \`${u.name}\` ${u.filePath}:${u.startLine}`);r.callers.length>5&&s.push(`- ... and ${r.callers.length-5} more`),s.push("");}if(r.callees.length>0){s.push(`**Callees of \`${r.node.name}\` (${r.callees.length}):**`);for(let u of r.callees.slice(0,5))s.push(`- [${u.relation}] \`${u.name}\` ${u.filePath}:${u.startLine}`);r.callees.length>5&&s.push(`- ... and ${r.callees.length-5} more`),s.push("");}}}return s.push(`---
53
- `),s.push(v("context",i,{})),q(s.join(`
54
- `),e,d)}function Ge(t){let e=new Map;for(let n of t){let c=n.node.filePath,a=e.get(c);a?a.push(n):e.set(c,[n]);}return e}function H(t,e,n){return `**${t}**
55
-
56
- ${e}
57
-
58
- > **Tip:** ${n}`}async function q(t,e,n){let c={softLimit:e.softLimit,hardCeiling:e.hardCeiling,toolName:e.toolName,writeToDisk:n?false:e.writeToDisk};return (n?U(t,c):await B(t,c)).content}var Qe=utils.Log.create({service:"codebase-format-render"});async function Ye(t,e){if(t.length===0)return j([],e);let n=X(t);return j(n,e)}async function ze(t,e,n){if(e.length===0)return G(S(t),[],n);let c=[{depth:1,count:e.length,riskLabel:Z(1),samples:e.slice(0,10).map(a=>({name:a.source.name,file:S(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return G(S(t),c,n)}async function Xe(t,e,n,c,a){let i=S(t),d=e.map(r=>O(r,"in")),s=n.map(r=>O(r,"out")),l=c.map(r=>({node:S(r),depth:1}));return ee({root:i,incoming:d,outgoing:s,neighbors:l},a)}async function Ve(t,e,n){if(!t)return K(V(),[],n);let c=S(t),a=e.map(i=>{let d=i.target===t.id?"in":"out";return O(i,d)});return K(c,a,n)}async function Je(t,e){let n={query:t.query,totalHits:t.totalHits,entryPoints:t.entryPoints.map(c=>({file:c.file,symbols:c.symbols.map(a=>({node:S(a.node),source:a.node.text??"",callers:a.callers.map(i=>({name:i.name,filePath:i.filePath,startLine:i.startLine,relation:i.relation})),callees:a.callees.map(i=>({name:i.name,filePath:i.filePath,startLine:i.startLine,relation:i.relation}))}))}))};return he(n,e)}Qe.debug("format/render.ts loaded");exports.A=ze;exports.B=Xe;exports.C=Ve;exports.D=Je;exports.a=T;exports.b=w;exports.c=k;exports.d=ae;exports.e=Ce;exports.f=$e;exports.g=_e;exports.h=Ae;exports.i=we;exports.j=Oe;exports.k=De;exports.l=ke;exports.m=S;exports.n=O;exports.o=X;exports.p=V;exports.q=J;exports.r=Ue;exports.s=B;exports.t=U;exports.u=j;exports.v=G;exports.w=Z;exports.x=ee;exports.y=K;exports.z=Ye;
@@ -1 +0,0 @@
1
- export{c as COMMANDS_HELP,d as handleCodebaseCli,e as mapCodebaseDoctor,a as renderBanner,b as renderHelp}from'./chunk-AIUVBWJX.mjs';import'./chunk-ZPEE2LSX.mjs';import'./chunk-SQJ64NFE.mjs';import'./chunk-STDI2Q67.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-EWVG3S6R.mjs';import'./chunk-GWCRGM4D.mjs';import'./chunk-2YMB6W5S.mjs';
@@ -1 +0,0 @@
1
- 'use strict';var chunk5E5YY2J3_cjs=require('./chunk-5E5YY2J3.cjs');require('./chunk-4HJ7RFP7.cjs'),require('./chunk-WC5CUSXD.cjs'),require('./chunk-NF6CVHEK.cjs'),require('./chunk-JVX6PHPN.cjs'),require('./chunk-PLI6SXTS.cjs'),require('./chunk-VPWALTY7.cjs'),require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.c}});Object.defineProperty(exports,"handleCodebaseCli",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.d}});Object.defineProperty(exports,"mapCodebaseDoctor",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.e}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.a}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.b}});
@@ -1 +0,0 @@
1
- 'use strict';var chunkNF6CVHEK_cjs=require('./chunk-NF6CVHEK.cjs');require('./chunk-JVX6PHPN.cjs');var chunkPLI6SXTS_cjs=require('./chunk-PLI6SXTS.cjs');require('./chunk-VPWALTY7.cjs'),require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"CodeBase",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.s}});Object.defineProperty(exports,"EdgeExtractor",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.m}});Object.defineProperty(exports,"FILE_EXTENSION_MAP",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.g}});Object.defineProperty(exports,"Indexer",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.o}});Object.defineProperty(exports,"NodeExtractor",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.k}});Object.defineProperty(exports,"ParserManager",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.h}});Object.defineProperty(exports,"QueryInterface",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.q}});Object.defineProperty(exports,"createCodebase",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.t}});Object.defineProperty(exports,"createEdgeExtractor",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.n}});Object.defineProperty(exports,"createIndexer",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.p}});Object.defineProperty(exports,"createNodeExtractor",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.l}});Object.defineProperty(exports,"createQueryInterface",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.r}});Object.defineProperty(exports,"getParserManager",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.i}});Object.defineProperty(exports,"resetParserManager",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.j}});Object.defineProperty(exports,"ConfigError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.e}});Object.defineProperty(exports,"DatabaseError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.b}});Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.n}});Object.defineProperty(exports,"FileSystemError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.c}});Object.defineProperty(exports,"IndexError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.f}});Object.defineProperty(exports,"ParserError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.a}});Object.defineProperty(exports,"QueryError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.g}});Object.defineProperty(exports,"SchemaError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.d}});Object.defineProperty(exports,"UnsupportedLanguageError",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.h}});
@@ -1 +0,0 @@
1
- 'use strict';var chunkPLI6SXTS_cjs=require('./chunk-PLI6SXTS.cjs');require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.n}});Object.defineProperty(exports,"EXTRACTION_VERSION",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.m}});Object.defineProperty(exports,"getDbPath",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.p}});Object.defineProperty(exports,"isClosed",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.o}});Object.defineProperty(exports,"transaction",{enumerable:true,get:function(){return chunkPLI6SXTS_cjs.q}});
@@ -1 +0,0 @@
1
- export{n as DatabaseManager,m as EXTRACTION_VERSION,p as getDbPath,o as isClosed,q as transaction}from'./chunk-EWVG3S6R.mjs';import'./chunk-2YMB6W5S.mjs';
@@ -1,47 +0,0 @@
1
- 'use strict';var chunkWC5CUSXD_cjs=require('./chunk-WC5CUSXD.cjs');require('./chunk-NF6CVHEK.cjs'),require('./chunk-JVX6PHPN.cjs'),require('./chunk-PLI6SXTS.cjs'),require('./chunk-VPWALTY7.cjs'),require('./chunk-M2YU5LAI.cjs');var mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var g=utils.Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"];exports.CodebaseStdioServer=void 0;(t=>{let o;function r(){return o||(g.debug("initializing CodebaseStdioServer state factory (lazy)"),o=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),o}async function a(n,s){let i=r()(),f=(process.env.EASBOT_MCP_TRUSTED_LOCAL??"true").toLowerCase()!=="false",u=new mcp.ToolRegistry;ce(u,n,f);let y=i.toolNames;g.info("starting codebase MCP stdio server",{id:s.id,name:s.name,toolCount:y.length});let h=await mcp.createAndStartStdioServer(s,u),x=null,D=new Promise(l=>{x=l;}),E=l=>{g.info("received signal, stopping MCP server",{signal:l}),x?.();},S=()=>E("SIGINT"),T=()=>E("SIGTERM");process.on("SIGINT",S),process.on("SIGTERM",T);try{await D;}finally{try{process.off("SIGINT",S),process.off("SIGTERM",T);}catch(l){g.warn("failed to remove signal handlers",{error:l instanceof Error?l.message:String(l)});}try{await h.stop();}catch(l){g.warn("server.stop failed during cleanup",{error:l instanceof Error?l.message:String(l)});}try{await n.close();}catch(l){g.warn("codebase.close failed during cleanup",{error:l instanceof Error?l.message:String(l)});}}return {id:s.id,name:s.name,version:s.version,tools:y}}t.start=a;function c(){return r()().toolNames}t.getToolNames=c;function e(){o=void 0;}t.__resetForTests=e;})(exports.CodebaseStdioServer||(exports.CodebaseStdioServer={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",additionalProperties:false,properties:{query:{type:"string",description:'Symbol name or partial name (e.g., "auth", "UserService"). Empty string returns recent nodes.'},kind:{type:"string",description:"Filter by node kind. One of: class, function, method, interface, type, variable, route, component, const.",enum:["class","function","method","interface","type","variable","route","component","const"]},file:{type:"string",description:'Filter by file path (substring match, e.g., "src/auth").'},intent:{type:"string",description:'LLM context for ranking (e.g., "adding OAuth support").'},includeContent:{type:"boolean",description:"Include source code snippets (default false; use `explore` for full code).",default:false},maxResults:{type:"number",description:"Maximum results",default:10,minimum:1,maximum:100},language:{type:"string",description:"Filter by programming language",enum:["ts","tsx","js","py","rs","go","c","cpp","csharp","java","scala","ruby","php","zig"]},astType:{type:"string",description:"Filter by AST node type (more specific than kind)."}},required:[]},X={type:"object",additionalProperties:false,properties:{name:{type:"string",description:'Symbol name (e.g., "AuthService"). Recommended \u2014 LLM workflow: query \u2192 use returned name.'},nodeId:{type:"string",description:"Node ID (direct lookup, zero ambiguity)."},file:{type:"string",description:"File path or basename to disambiguate when multiple same-named symbols exist."},kind:{type:"string",description:"Filter by node kind (class, function, method, interface, type, variable, route, component, const)."},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},includeEdges:{type:"boolean",description:"Include edge listing (incoming + outgoing).",default:true},maxEdgesPerNode:{type:"number",description:"Max edges to return (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},V={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"BFS depth (1 = direct only, 2 = default, 3 = max).",default:2,minimum:1,maximum:3},maxNodes:{type:"number",description:"Max nodes in result.",default:100,minimum:1,maximum:500},direction:{type:"string",description:"Edge direction filter",enum:["incoming","outgoing","both"],default:"both"},maxEdgesPerNode:{type:"number",description:"Max edges per direction per BFS level (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},z={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"Max BFS depth (1-3).",default:2,minimum:1,maximum:3},maxResults:{type:"number",description:"Max affected symbols (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max incoming edges per BFS level (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},K={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name to find callers for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callers to return (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max incoming edges (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},J={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name to find callees for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callees to return (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max outgoing edges (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},Z={type:"object",additionalProperties:false,properties:{query:{type:"string",description:'Symbol name or natural language query (e.g., "auth flow", "MemorySystem").'},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxFiles:{type:"number",description:"Max entry-point files.",default:5,minimum:1,maximum:20},maxSymbols:{type:"number",description:"Max symbols per file.",default:3,minimum:1,maximum:10},maxEdgesPerNode:{type:"number",description:"Max caller/callee edges per symbol (default 10; range [1, 100]).",default:10,minimum:1,maximum:100},depth:{type:"number",description:"Neighbor depth for callers/callees (default 1).",default:1,minimum:1,maximum:2},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},intent:{type:"string",description:"LLM context for ranking."}},required:["query"]},$={type:"object",additionalProperties:false,properties:{}},ee={query:'Hybrid search over indexed code nodes (FTS + vector + basic + name-segment). Returns symbol locations grouped by file with line-numbered snippets.\n\nWHEN TO USE: Quick lookup of "where is X defined?" \u2014 get symbol locations and snippets in one call. Use `context` to understand a symbol\'s surroundings; use `impact` to see blast radius; use `explore` to get the actual source.\n\nAFTER THIS: Use `node <name>` to fetch full details of one match; use `context` to walk neighbors; use `explore` to get source code.\n\nNOTES: Default FTS-only (fast). Pass `includeContent: true` to include code snippets in results. Use `kind` for friendlier semantic filter (class/function/method/...) instead of `astType`.',node:"Show details for a single symbol: kind, language, location, modifiers, source code, edges.\n\nWHEN TO USE: After `query` / `context` returns a list \u2014 fetch one match's full metadata and edge summary. Pass `name` (preferred) or `nodeId`.\n\nAFTER THIS: Use `context` to walk neighbors; use `impact` for blast radius; use `explore` to get source code + caller/callee trail.\n\nNOTES: `name` is the LLM-friendly input. `file` / `kind` disambiguate when multiple same-named symbols exist. Source code is included by default (set `includeContent: false` for metadata only).",context:"Build a sub-graph around a symbol (BFS to N-level neighbors). Returns incoming/outgoing edges and neighbor nodes grouped by depth.\n\nWHEN TO USE: Understand a symbol's surroundings \u2014 who calls it, what it calls, who extends it. Use after `query` / `node` to get the symbol.\n\nAFTER THIS: Use `impact` for blast-radius (callers only, deeper depth). Use `callers` / `callees` for a flat list. Use `query` to find related symbols.\n\nNOTES: `name` is the LLM-friendly input. Does NOT include source code (use `explore` for code). Set `direction` to narrow to incoming/outgoing only.",impact:"Blast radius of changing a symbol: BFS incoming edges (CALLS / IMPORTS / TYPE_REFERENCES), bucketed by depth. d=1 (WILL BREAK) / d=2 (LIKELY AFFECTED) / d=3 (MAY NEED TESTING).\n\nWHEN TO USE: Before refactoring a symbol \u2014 see what depends on it. Use after `query` to get the symbol.\n\nAFTER THIS: Review d=1 first (those WILL BREAK). Use `node <name>` on high-risk nodes to read their source.\n\nNOTES: `name` is the LLM-friendly input. Returns counts per depth bucket, not full lists. For flat caller list, use `callers`.",callers:'Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / METHOD_OVERRIDES).\n\nWHEN TO USE: Quick "who depends on this?" lookup. Use `impact` for bucketed risk analysis; use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a high-traffic caller to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callers (default 10). Use `file` / `kind` to disambiguate.',callees:'Flat list of what <symbol> calls (outgoing CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).\n\nWHEN TO USE: Quick "what does this function do?" lookup. Use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a key callee to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callees (default 10). Use `file` / `kind` to disambiguate.',explore:"**PRIMARY TOOL \u2014 call FIRST** for almost any question OR before an edit: how does X work, architecture, a bug, where/what is X, surveying an area, or symbols you are about to change.\n\nReturns verbatim source of relevant symbols grouped by file in ONE capped call (Read-equivalent \u2014 treat shown source as already Read; do NOT re-open those files), plus caller/callee trail.\n\nWHEN TO USE: Whenever you need to understand an area of the codebase or before refactoring. Query can be a symbol name or natural language.\n\nAFTER THIS: Use `node <name>` for metadata only; use `impact` for blast-radius; use `callers` / `callees` for flat lists.\n\nNOTES: Usually the ONLY call you need \u2014 more accurate context, in far fewer tokens and round-trips than search/Read/Grep loop. The single most cost-effective tool.",status:`Show index state, db path, node/edge counts, indexed files, meta config.
2
-
3
- WHEN TO USE: Diagnostic only \u2014 check whether the index is up-to-date or stale. Skip unless debugging.
4
-
5
- AFTER THIS: If index is stale, run \`easbot codebase sync\` from CLI; \`doctor\` for deeper health check.
6
-
7
- NOTES: Read-only. Output is a structured markdown summary.`,doctor:`Run health checks: db connection, FTS availability, parser status, node/edge counts.
8
-
9
- WHEN TO USE: Diagnostic only \u2014 check why queries return empty or fail. Skip unless debugging.
10
-
11
- AFTER THIS: If unhealthy, fix the reported issue (usually run \`easbot codebase index\` from CLI).
12
-
13
- NOTES: Read-only. Returns healthy/unhealthy + a list of issues.`};function d(o,r=false){return {content:[{type:"text",text:o}],...r&&{isError:true}}}function m(o){return {workspaceDir:o.getWorkspaceDir?.()??process.cwd(),rootDir:o.getWorkspaceDir?.()??process.cwd()}}function p(o,r,a){if(o instanceof chunkWC5CUSXD_cjs.b)return `**${r}** \u2014 node not found. Try \`query\` first to discover the symbol.`;if(o instanceof chunkWC5CUSXD_cjs.c){let c=o.details?.candidates??[],e=c.slice(0,5).map(t=>`- \`${t.node.name}\` in \`${t.node.file_path}\``).join(`
14
- `);return `**${r}** \u2014 ambiguous name. Specify \`file\` to disambiguate:
15
-
16
- ${e}
17
-
18
- ... and ${c.length-5} more candidates.`}return mcp.formatFailClosed(o,a)}function te(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.d(t,{query:e.query,kind:e.kind,file:e.file,intent:e.intent,includeContent:e.includeContent??!1,maxResults:e.maxResults??10,language:e.language,astType:e.astType,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=await chunkWC5CUSXD_cjs.z(n.hits,{pendingFiles:[],toolName:"query",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"query",r),true)}}}function ne(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.e(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,includeEdges:e.includeEdges??!0,includeContent:e.includeContent??!0,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=await chunkWC5CUSXD_cjs.C(n.node,n.edges,{pendingFiles:[],toolName:"node",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"node",r),true)}}}function oe(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.f(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxNodes:e.maxNodes??100,direction:e.direction??"both",maxEdgesPerNode:e.maxEdgesPerNode??10});if(!n.root)return d("**context** \u2014 node not found.");let s=[],i=[];for(let u of n.edges)u.target===n.root.id?s.push(u):i.push(u);let f=await chunkWC5CUSXD_cjs.B(n.root,s,i,n.nodes.map(u=>u.node),{pendingFiles:[],toolName:"context",writeToDisk:!1});return d(f)}catch(t){return d(p(t,"context",r),true)}}}function se(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.g(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10});if(!n.root)return d("**impact** \u2014 node not found.");let s=[],i=o.getDatabase();for(let u of n.buckets)for(let y of u.sample){let h=i.getNodeById(y.id);h&&s.push({source:h,relation:y.relation});}let f=await chunkWC5CUSXD_cjs.A(n.root,s,{pendingFiles:[],toolName:"impact",writeToDisk:!1});return d(f)}catch(t){return d(p(t,"impact",r),true)}}}function re(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.h(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=[];s.push(`**Callers of \`${n.root?.name??"?"}\`** (${n.callers.length}${n.truncated?"+":""})
19
- `);for(let i of n.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callers.length===0&&s.push("(no incoming edges)"),s.push("\n---\n> Use `node <name>` to read full source of any caller."),d(s.join(`
20
- `))}catch(t){return d(p(t,"callers",r),true)}}}function ae(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.i(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=[];s.push(`**Callees of \`${n.root?.name??"?"}\`** (${n.callees.length}${n.truncated?"+":""})
21
- `);for(let i of n.callees)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callees.length===0&&s.push("(no outgoing edges)"),s.push("\n---\n> Use `node <name>` to read full source of any callee."),d(s.join(`
22
- `))}catch(t){return d(p(t,"callees",r),true)}}}function ie(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await chunkWC5CUSXD_cjs.j(t,{query:e.query,file:e.file,kind:e.kind,maxFiles:e.maxFiles??5,maxSymbols:e.maxSymbols??3,maxEdgesPerNode:e.maxEdgesPerNode??10,depth:e.depth??1,includeContent:e.includeContent??!0,intent:e.intent}),s=await chunkWC5CUSXD_cjs.D(n,{pendingFiles:[],toolName:"explore",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"explore",r),true)}}}function de(o,r){return async(a,c)=>{try{let e=m(o),t=await chunkWC5CUSXD_cjs.k(e,{}),n=t.workspaceDir,s=t.meta.indexed_with_version??"unknown",i=t.meta.lastSync??"never",f=`**Codebase Status**
23
-
24
- - DB path: \`${t.dbPath}\`
25
- - Workspace: \`${n}\`
26
- - Nodes: ${t.nodeCount}
27
- - Edges: ${t.edgeCount}
28
- - Indexed files: ${t.indexedFiles}
29
- - Index state: \`${t.indexState??"unknown"}\`
30
- - Extraction version: ${t.extractionVersion??"unknown"}
31
- - Indexed with version: ${s}
32
- - Last sync: ${i}
33
- - Stale: ${t.isStale?"\u26A0\uFE0F yes (extraction_version mismatch)":"no"}
34
-
35
- > Use \`doctor\` for deeper health check.`;return d(f)}catch(e){return d(p(e,"status",r),true)}}}function le(o,r){return async(a,c)=>{try{let e=m(o),t=await chunkWC5CUSXD_cjs.l(e,{}),n=await chunkWC5CUSXD_cjs.k(e,{}),s=`**Codebase Health Check**
36
-
37
- - Healthy: ${t.healthy?"\u2713 yes":"\u2717 no"}
38
- - Nodes: ${n.nodeCount}
39
- - Edges: ${n.edgeCount}
40
- - Indexed files: ${n.indexedFiles}
41
- - DB path: \`${n.dbPath}\`
42
- - FTS available: ${t.ftsAvailable}
43
-
44
- ${t.issues.length>0?`**Issues:**
45
- ${t.issues.map(i=>`- ${i}`).join(`
46
- `)}
47
- `:""}> ${t.healthy?"Index is healthy. Use `query` to search.":"Index has issues. Check status details above."}`;return d(s)}catch(e){return d(p(e,"doctor",r),true)}}}function ce(o,r,a){let c=[{name:"query",schema:Q,factory:te},{name:"node",schema:X,factory:ne},{name:"context",schema:V,factory:oe},{name:"impact",schema:z,factory:se},{name:"callers",schema:K,factory:re},{name:"callees",schema:J,factory:ae},{name:"explore",schema:Z,factory:ie},{name:"status",schema:$,factory:de},{name:"doctor",schema:$,factory:le}];for(let e of c)o.register({name:e.name,description:ee[e.name]??"",inputSchema:e.schema,annotations:G,handler:e.factory(r,a)});}
@@ -1,47 +0,0 @@
1
- import {d as d$1,z as z$1,e,C,f,B,g as g$1,A,h,i,j,D,k,l,b,c}from'./chunk-SQJ64NFE.mjs';import'./chunk-STDI2Q67.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-EWVG3S6R.mjs';import'./chunk-GWCRGM4D.mjs';import'./chunk-2YMB6W5S.mjs';import {ToolRegistry,createAndStartStdioServer,formatFailClosed}from'@easbot/mcp';import {Log}from'@easbot/utils';var g=Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"],U;(t=>{let o;function r(){return o||(g.debug("initializing CodebaseStdioServer state factory (lazy)"),o=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),o}async function a(n,s){let i=r()(),f=(process.env.EASBOT_MCP_TRUSTED_LOCAL??"true").toLowerCase()!=="false",u=new ToolRegistry;ce(u,n,f);let y=i.toolNames;g.info("starting codebase MCP stdio server",{id:s.id,name:s.name,toolCount:y.length});let h=await createAndStartStdioServer(s,u),x=null,D=new Promise(l=>{x=l;}),E=l=>{g.info("received signal, stopping MCP server",{signal:l}),x?.();},S=()=>E("SIGINT"),T=()=>E("SIGTERM");process.on("SIGINT",S),process.on("SIGTERM",T);try{await D;}finally{try{process.off("SIGINT",S),process.off("SIGTERM",T);}catch(l){g.warn("failed to remove signal handlers",{error:l instanceof Error?l.message:String(l)});}try{await h.stop();}catch(l){g.warn("server.stop failed during cleanup",{error:l instanceof Error?l.message:String(l)});}try{await n.close();}catch(l){g.warn("codebase.close failed during cleanup",{error:l instanceof Error?l.message:String(l)});}}return {id:s.id,name:s.name,version:s.version,tools:y}}t.start=a;function c(){return r()().toolNames}t.getToolNames=c;function e(){o=void 0;}t.__resetForTests=e;})(U||(U={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",additionalProperties:false,properties:{query:{type:"string",description:'Symbol name or partial name (e.g., "auth", "UserService"). Empty string returns recent nodes.'},kind:{type:"string",description:"Filter by node kind. One of: class, function, method, interface, type, variable, route, component, const.",enum:["class","function","method","interface","type","variable","route","component","const"]},file:{type:"string",description:'Filter by file path (substring match, e.g., "src/auth").'},intent:{type:"string",description:'LLM context for ranking (e.g., "adding OAuth support").'},includeContent:{type:"boolean",description:"Include source code snippets (default false; use `explore` for full code).",default:false},maxResults:{type:"number",description:"Maximum results",default:10,minimum:1,maximum:100},language:{type:"string",description:"Filter by programming language",enum:["ts","tsx","js","py","rs","go","c","cpp","csharp","java","scala","ruby","php","zig"]},astType:{type:"string",description:"Filter by AST node type (more specific than kind)."}},required:[]},X={type:"object",additionalProperties:false,properties:{name:{type:"string",description:'Symbol name (e.g., "AuthService"). Recommended \u2014 LLM workflow: query \u2192 use returned name.'},nodeId:{type:"string",description:"Node ID (direct lookup, zero ambiguity)."},file:{type:"string",description:"File path or basename to disambiguate when multiple same-named symbols exist."},kind:{type:"string",description:"Filter by node kind (class, function, method, interface, type, variable, route, component, const)."},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},includeEdges:{type:"boolean",description:"Include edge listing (incoming + outgoing).",default:true},maxEdgesPerNode:{type:"number",description:"Max edges to return (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},V={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"BFS depth (1 = direct only, 2 = default, 3 = max).",default:2,minimum:1,maximum:3},maxNodes:{type:"number",description:"Max nodes in result.",default:100,minimum:1,maximum:500},direction:{type:"string",description:"Edge direction filter",enum:["incoming","outgoing","both"],default:"both"},maxEdgesPerNode:{type:"number",description:"Max edges per direction per BFS level (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},z={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"Max BFS depth (1-3).",default:2,minimum:1,maximum:3},maxResults:{type:"number",description:"Max affected symbols (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max incoming edges per BFS level (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},K={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name to find callers for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callers to return (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max incoming edges (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},J={type:"object",additionalProperties:false,properties:{name:{type:"string",description:"Symbol name to find callees for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callees to return (default 10; range [1, 200]).",default:10,minimum:1,maximum:200},maxEdgesPerNode:{type:"number",description:"Max outgoing edges (default 10; range [1, 100]).",default:10,minimum:1,maximum:100}},required:[]},Z={type:"object",additionalProperties:false,properties:{query:{type:"string",description:'Symbol name or natural language query (e.g., "auth flow", "MemorySystem").'},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxFiles:{type:"number",description:"Max entry-point files.",default:5,minimum:1,maximum:20},maxSymbols:{type:"number",description:"Max symbols per file.",default:3,minimum:1,maximum:10},maxEdgesPerNode:{type:"number",description:"Max caller/callee edges per symbol (default 10; range [1, 100]).",default:10,minimum:1,maximum:100},depth:{type:"number",description:"Neighbor depth for callers/callees (default 1).",default:1,minimum:1,maximum:2},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},intent:{type:"string",description:"LLM context for ranking."}},required:["query"]},$={type:"object",additionalProperties:false,properties:{}},ee={query:'Hybrid search over indexed code nodes (FTS + vector + basic + name-segment). Returns symbol locations grouped by file with line-numbered snippets.\n\nWHEN TO USE: Quick lookup of "where is X defined?" \u2014 get symbol locations and snippets in one call. Use `context` to understand a symbol\'s surroundings; use `impact` to see blast radius; use `explore` to get the actual source.\n\nAFTER THIS: Use `node <name>` to fetch full details of one match; use `context` to walk neighbors; use `explore` to get source code.\n\nNOTES: Default FTS-only (fast). Pass `includeContent: true` to include code snippets in results. Use `kind` for friendlier semantic filter (class/function/method/...) instead of `astType`.',node:"Show details for a single symbol: kind, language, location, modifiers, source code, edges.\n\nWHEN TO USE: After `query` / `context` returns a list \u2014 fetch one match's full metadata and edge summary. Pass `name` (preferred) or `nodeId`.\n\nAFTER THIS: Use `context` to walk neighbors; use `impact` for blast radius; use `explore` to get source code + caller/callee trail.\n\nNOTES: `name` is the LLM-friendly input. `file` / `kind` disambiguate when multiple same-named symbols exist. Source code is included by default (set `includeContent: false` for metadata only).",context:"Build a sub-graph around a symbol (BFS to N-level neighbors). Returns incoming/outgoing edges and neighbor nodes grouped by depth.\n\nWHEN TO USE: Understand a symbol's surroundings \u2014 who calls it, what it calls, who extends it. Use after `query` / `node` to get the symbol.\n\nAFTER THIS: Use `impact` for blast-radius (callers only, deeper depth). Use `callers` / `callees` for a flat list. Use `query` to find related symbols.\n\nNOTES: `name` is the LLM-friendly input. Does NOT include source code (use `explore` for code). Set `direction` to narrow to incoming/outgoing only.",impact:"Blast radius of changing a symbol: BFS incoming edges (CALLS / IMPORTS / TYPE_REFERENCES), bucketed by depth. d=1 (WILL BREAK) / d=2 (LIKELY AFFECTED) / d=3 (MAY NEED TESTING).\n\nWHEN TO USE: Before refactoring a symbol \u2014 see what depends on it. Use after `query` to get the symbol.\n\nAFTER THIS: Review d=1 first (those WILL BREAK). Use `node <name>` on high-risk nodes to read their source.\n\nNOTES: `name` is the LLM-friendly input. Returns counts per depth bucket, not full lists. For flat caller list, use `callers`.",callers:'Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / METHOD_OVERRIDES).\n\nWHEN TO USE: Quick "who depends on this?" lookup. Use `impact` for bucketed risk analysis; use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a high-traffic caller to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callers (default 10). Use `file` / `kind` to disambiguate.',callees:'Flat list of what <symbol> calls (outgoing CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).\n\nWHEN TO USE: Quick "what does this function do?" lookup. Use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a key callee to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callees (default 10). Use `file` / `kind` to disambiguate.',explore:"**PRIMARY TOOL \u2014 call FIRST** for almost any question OR before an edit: how does X work, architecture, a bug, where/what is X, surveying an area, or symbols you are about to change.\n\nReturns verbatim source of relevant symbols grouped by file in ONE capped call (Read-equivalent \u2014 treat shown source as already Read; do NOT re-open those files), plus caller/callee trail.\n\nWHEN TO USE: Whenever you need to understand an area of the codebase or before refactoring. Query can be a symbol name or natural language.\n\nAFTER THIS: Use `node <name>` for metadata only; use `impact` for blast-radius; use `callers` / `callees` for flat lists.\n\nNOTES: Usually the ONLY call you need \u2014 more accurate context, in far fewer tokens and round-trips than search/Read/Grep loop. The single most cost-effective tool.",status:`Show index state, db path, node/edge counts, indexed files, meta config.
2
-
3
- WHEN TO USE: Diagnostic only \u2014 check whether the index is up-to-date or stale. Skip unless debugging.
4
-
5
- AFTER THIS: If index is stale, run \`easbot codebase sync\` from CLI; \`doctor\` for deeper health check.
6
-
7
- NOTES: Read-only. Output is a structured markdown summary.`,doctor:`Run health checks: db connection, FTS availability, parser status, node/edge counts.
8
-
9
- WHEN TO USE: Diagnostic only \u2014 check why queries return empty or fail. Skip unless debugging.
10
-
11
- AFTER THIS: If unhealthy, fix the reported issue (usually run \`easbot codebase index\` from CLI).
12
-
13
- NOTES: Read-only. Returns healthy/unhealthy + a list of issues.`};function d(o,r=false){return {content:[{type:"text",text:o}],...r&&{isError:true}}}function m(o){return {workspaceDir:o.getWorkspaceDir?.()??process.cwd(),rootDir:o.getWorkspaceDir?.()??process.cwd()}}function p(o,r,a){if(o instanceof b)return `**${r}** \u2014 node not found. Try \`query\` first to discover the symbol.`;if(o instanceof c){let c=o.details?.candidates??[],e=c.slice(0,5).map(t=>`- \`${t.node.name}\` in \`${t.node.file_path}\``).join(`
14
- `);return `**${r}** \u2014 ambiguous name. Specify \`file\` to disambiguate:
15
-
16
- ${e}
17
-
18
- ... and ${c.length-5} more candidates.`}return formatFailClosed(o,a)}function te(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await d$1(t,{query:e.query,kind:e.kind,file:e.file,intent:e.intent,includeContent:e.includeContent??!1,maxResults:e.maxResults??10,language:e.language,astType:e.astType,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=await z$1(n.hits,{pendingFiles:[],toolName:"query",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"query",r),true)}}}function ne(o,r){return async(a,c)=>{let e$1=a;try{let t=m(o),n=await e(t,{name:e$1.name,nodeId:e$1.nodeId,file:e$1.file,kind:e$1.kind,includeEdges:e$1.includeEdges??!0,includeContent:e$1.includeContent??!0,maxEdgesPerNode:e$1.maxEdgesPerNode??10}),s=await C(n.node,n.edges,{pendingFiles:[],toolName:"node",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"node",r),true)}}}function oe(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await f(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxNodes:e.maxNodes??100,direction:e.direction??"both",maxEdgesPerNode:e.maxEdgesPerNode??10});if(!n.root)return d("**context** \u2014 node not found.");let s=[],i=[];for(let u of n.edges)u.target===n.root.id?s.push(u):i.push(u);let f$1=await B(n.root,s,i,n.nodes.map(u=>u.node),{pendingFiles:[],toolName:"context",writeToDisk:!1});return d(f$1)}catch(t){return d(p(t,"context",r),true)}}}function se(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await g$1(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10});if(!n.root)return d("**impact** \u2014 node not found.");let s=[],i=o.getDatabase();for(let u of n.buckets)for(let y of u.sample){let h=i.getNodeById(y.id);h&&s.push({source:h,relation:y.relation});}let f=await A(n.root,s,{pendingFiles:[],toolName:"impact",writeToDisk:!1});return d(f)}catch(t){return d(p(t,"impact",r),true)}}}function re(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await h(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=[];s.push(`**Callers of \`${n.root?.name??"?"}\`** (${n.callers.length}${n.truncated?"+":""})
19
- `);for(let i of n.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callers.length===0&&s.push("(no incoming edges)"),s.push("\n---\n> Use `node <name>` to read full source of any caller."),d(s.join(`
20
- `))}catch(t){return d(p(t,"callers",r),true)}}}function ae(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await i(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??10,maxEdgesPerNode:e.maxEdgesPerNode??10}),s=[];s.push(`**Callees of \`${n.root?.name??"?"}\`** (${n.callees.length}${n.truncated?"+":""})
21
- `);for(let i of n.callees)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callees.length===0&&s.push("(no outgoing edges)"),s.push("\n---\n> Use `node <name>` to read full source of any callee."),d(s.join(`
22
- `))}catch(t){return d(p(t,"callees",r),true)}}}function ie(o,r){return async(a,c)=>{let e=a;try{let t=m(o),n=await j(t,{query:e.query,file:e.file,kind:e.kind,maxFiles:e.maxFiles??5,maxSymbols:e.maxSymbols??3,maxEdgesPerNode:e.maxEdgesPerNode??10,depth:e.depth??1,includeContent:e.includeContent??!0,intent:e.intent}),s=await D(n,{pendingFiles:[],toolName:"explore",writeToDisk:!1});return d(s)}catch(t){return d(p(t,"explore",r),true)}}}function de(o,r){return async(a,c)=>{try{let e=m(o),t=await k(e,{}),n=t.workspaceDir,s=t.meta.indexed_with_version??"unknown",i=t.meta.lastSync??"never",f=`**Codebase Status**
23
-
24
- - DB path: \`${t.dbPath}\`
25
- - Workspace: \`${n}\`
26
- - Nodes: ${t.nodeCount}
27
- - Edges: ${t.edgeCount}
28
- - Indexed files: ${t.indexedFiles}
29
- - Index state: \`${t.indexState??"unknown"}\`
30
- - Extraction version: ${t.extractionVersion??"unknown"}
31
- - Indexed with version: ${s}
32
- - Last sync: ${i}
33
- - Stale: ${t.isStale?"\u26A0\uFE0F yes (extraction_version mismatch)":"no"}
34
-
35
- > Use \`doctor\` for deeper health check.`;return d(f)}catch(e){return d(p(e,"status",r),true)}}}function le(o,r){return async(a,c)=>{try{let e=m(o),t=await l(e,{}),n=await k(e,{}),s=`**Codebase Health Check**
36
-
37
- - Healthy: ${t.healthy?"\u2713 yes":"\u2717 no"}
38
- - Nodes: ${n.nodeCount}
39
- - Edges: ${n.edgeCount}
40
- - Indexed files: ${n.indexedFiles}
41
- - DB path: \`${n.dbPath}\`
42
- - FTS available: ${t.ftsAvailable}
43
-
44
- ${t.issues.length>0?`**Issues:**
45
- ${t.issues.map(i=>`- ${i}`).join(`
46
- `)}
47
- `:""}> ${t.healthy?"Index is healthy. Use `query` to search.":"Index has issues. Check status details above."}`;return d(s)}catch(e){return d(p(e,"doctor",r),true)}}}function ce(o,r,a){let c=[{name:"query",schema:Q,factory:te},{name:"node",schema:X,factory:ne},{name:"context",schema:V,factory:oe},{name:"impact",schema:z,factory:se},{name:"callers",schema:K,factory:re},{name:"callees",schema:J,factory:ae},{name:"explore",schema:Z,factory:ie},{name:"status",schema:$,factory:de},{name:"doctor",schema:$,factory:le}];for(let e of c)o.register({name:e.name,description:ee[e.name]??"",inputSchema:e.schema,annotations:G,handler:e.factory(r,a)});}export{U as CodebaseStdioServer};