@easbot/codebase 0.3.13 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +42 -0
- package/README.md +38 -0
- package/dist/chunks/{chunk-DMRAZKIP.cjs → chunk-6CD6Y4F7.cjs} +22 -22
- package/dist/chunks/chunk-6ENRFRCH.cjs +34 -0
- package/dist/chunks/{chunk-U5G7MP3K.cjs → chunk-BEQN3CKO.cjs} +1 -1
- package/dist/chunks/{chunk-PLRTEGLZ.mjs → chunk-BUHCT5PM.mjs} +23 -23
- package/dist/chunks/{chunk-P566CDI2.mjs → chunk-CS4EBN3N.mjs} +1 -1
- package/dist/chunks/{chunk-4KHRTABC.cjs → chunk-K5CRL5DC.cjs} +6 -6
- package/dist/chunks/{chunk-W25T3SKH.mjs → chunk-LFH3RTD3.mjs} +2 -2
- package/dist/chunks/{chunk-Z4Y3VCYS.mjs → chunk-P6QT72IP.mjs} +1 -1
- package/dist/chunks/{chunk-RLZHDTHY.cjs → chunk-UTPNELRD.cjs} +2 -2
- package/dist/chunks/chunk-W2JWBAHR.mjs +34 -0
- package/dist/chunks/{chunk-7PW7HWOC.cjs → chunk-WSFETZ24.cjs} +1 -1
- package/dist/chunks/{chunk-7ZBQQZOA.mjs → chunk-WXWENWCY.mjs} +1 -1
- package/dist/chunks/cli-handler-IDMIMEKA.cjs +1 -0
- package/dist/chunks/cli-handler-ZLJJGHMV.mjs +1 -0
- package/dist/chunks/{code-base-MC4K4ST4.mjs → code-base-2TXG4VK3.mjs} +1 -1
- package/dist/chunks/code-base-32T6G2FF.cjs +1 -0
- package/dist/chunks/database-manager-YEWLT7QF.mjs +1 -0
- package/dist/chunks/database-manager-YNQZSUVP.cjs +1 -0
- package/dist/chunks/file-watcher-GHRFHOQF.cjs +1 -0
- package/dist/chunks/file-watcher-OORREWFV.mjs +1 -0
- package/dist/chunks/{interfaces-KGAFAHKZ.mjs → interfaces-5HZADUYB.mjs} +1 -1
- package/dist/chunks/{interfaces-4KLR5CPG.cjs → interfaces-ORRCH4XV.cjs} +1 -1
- package/dist/chunks/stdio-server-EQGSXAMO.cjs +47 -0
- package/dist/chunks/stdio-server-OFN76NZA.mjs +47 -0
- package/dist/chunks/sync-6CALMRLC.mjs +1 -0
- package/dist/chunks/sync-TICACY4G.cjs +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +43 -7
- package/dist/index.d.ts +43 -7
- package/dist/index.mjs +1 -1
- package/package.json +16 -15
- package/dist/chunks/chunk-RPRDGNXG.cjs +0 -34
- package/dist/chunks/chunk-XQID3NKI.mjs +0 -34
- package/dist/chunks/cli-handler-47R23IC3.cjs +0 -1
- package/dist/chunks/cli-handler-KSSK773Z.mjs +0 -1
- package/dist/chunks/code-base-HBPZXJQZ.cjs +0 -1
- package/dist/chunks/database-manager-DRLNOQ6C.cjs +0 -1
- package/dist/chunks/database-manager-WOYUSWKD.mjs +0 -1
- package/dist/chunks/file-watcher-EASGLNDX.mjs +0 -1
- package/dist/chunks/file-watcher-P3ACFOV5.cjs +0 -1
- package/dist/chunks/stdio-server-C7OYLX4I.mjs +0 -47
- package/dist/chunks/stdio-server-UDX3QZNZ.cjs +0 -47
- package/dist/chunks/sync-6VAWF5IL.mjs +0 -1
- package/dist/chunks/sync-OSAGPUO2.cjs +0 -1
- /package/dist/chunks/{chunk-TS4OAYIJ.cjs → chunk-NVGACA7W.cjs} +0 -0
- /package/dist/chunks/{chunk-G3IYU6TZ.mjs → chunk-TMICZT3L.mjs} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -795,9 +795,23 @@ interface FormattedSearchHit {
|
|
|
795
795
|
}
|
|
796
796
|
declare function formatCodebaseNode(node: Node): FormattedNode;
|
|
797
797
|
declare function formatCodebaseEdge(edge: Edge, direction?: 'in' | 'out'): FormattedEdge;
|
|
798
|
-
declare function formatCodebaseSearchHits(
|
|
799
|
-
|
|
800
|
-
|
|
798
|
+
declare function formatCodebaseSearchHits(hits: Array<{
|
|
799
|
+
nodeId: string;
|
|
800
|
+
name: string;
|
|
801
|
+
kind: string;
|
|
802
|
+
filePath: string;
|
|
803
|
+
startLine?: number;
|
|
804
|
+
endLine?: number;
|
|
805
|
+
edges?: Array<{
|
|
806
|
+
id?: string;
|
|
807
|
+
source: string;
|
|
808
|
+
target: string;
|
|
809
|
+
relation: string;
|
|
810
|
+
}>;
|
|
811
|
+
source: string;
|
|
812
|
+
score: number;
|
|
813
|
+
snippet?: string;
|
|
814
|
+
}>): FormattedSearchHit[];
|
|
801
815
|
declare function emptyFormattedNode(): FormattedNode;
|
|
802
816
|
|
|
803
817
|
interface PendingFile {
|
|
@@ -877,11 +891,17 @@ interface SearchParams {
|
|
|
877
891
|
enableEmbedding?: boolean;
|
|
878
892
|
}
|
|
879
893
|
interface SearchHit {
|
|
880
|
-
|
|
881
|
-
|
|
894
|
+
nodeId: string;
|
|
895
|
+
name: string;
|
|
896
|
+
kind: NodeKind | string;
|
|
897
|
+
filePath: string;
|
|
898
|
+
startLine?: number;
|
|
899
|
+
endLine?: number;
|
|
882
900
|
source: string;
|
|
883
901
|
score: number;
|
|
884
902
|
snippet: string;
|
|
903
|
+
edges: Edge[];
|
|
904
|
+
originalScore?: number;
|
|
885
905
|
}
|
|
886
906
|
interface SearchResult {
|
|
887
907
|
total: number;
|
|
@@ -990,7 +1010,7 @@ interface ExploreParams {
|
|
|
990
1010
|
interface ExploreEntryPoint {
|
|
991
1011
|
file: string;
|
|
992
1012
|
symbols: Array<{
|
|
993
|
-
node: Node
|
|
1013
|
+
node: Pick<Node, 'id' | 'name' | 'ast_type' | 'language' | 'file_path' | 'start_line' | 'end_line' | 'text'>;
|
|
994
1014
|
callers: CallerEntry[];
|
|
995
1015
|
callees: CallerEntry[];
|
|
996
1016
|
}>;
|
|
@@ -1022,7 +1042,23 @@ declare class AmbiguousError extends ServiceError {
|
|
|
1022
1042
|
}>);
|
|
1023
1043
|
}
|
|
1024
1044
|
|
|
1025
|
-
declare function renderSearch(
|
|
1045
|
+
declare function renderSearch(hits: Array<{
|
|
1046
|
+
nodeId: string;
|
|
1047
|
+
name: string;
|
|
1048
|
+
kind: string;
|
|
1049
|
+
filePath: string;
|
|
1050
|
+
startLine?: number;
|
|
1051
|
+
endLine?: number;
|
|
1052
|
+
edges?: Array<{
|
|
1053
|
+
id: string;
|
|
1054
|
+
source: string;
|
|
1055
|
+
target: string;
|
|
1056
|
+
relation: string;
|
|
1057
|
+
}>;
|
|
1058
|
+
source: string;
|
|
1059
|
+
score: number;
|
|
1060
|
+
snippet?: string;
|
|
1061
|
+
}>, options: RenderOptions): Promise<string>;
|
|
1026
1062
|
declare function renderImpactFromTuples(root: Node, tuples: Array<{
|
|
1027
1063
|
source: Node;
|
|
1028
1064
|
relation: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as handleCodebaseCli,a as renderBanner,b as renderHelp}from'./chunks/chunk-
|
|
1
|
+
export{d as handleCodebaseCli,a as renderBanner,b as renderHelp}from'./chunks/chunk-BUHCT5PM.mjs';import'./chunks/chunk-WXWENWCY.mjs';import'./chunks/chunk-CS4EBN3N.mjs';export{c as getGlobal,g as getHomeDir,f as getInstance,l as getProjectDirectory,k as getXdgCache,i as getXdgConfig,h as getXdgData,j as getXdgState,b as resetGlobalAdapter,e as resetInstanceAdapter,a as setGlobalAdapter,d as setInstanceAdapter}from'./chunks/chunk-34CU2EU4.mjs';export{c as AmbiguousError,b as NotFoundError,r as SECTION_END,q as SECTION_MARKER,a as ServiceError,i as callees,h as callers,f as context,w as defaultRiskLabel,l as doctor,p as emptyFormattedNode,j as explore,n as formatCodebaseEdge,m as formatCodebaseNode,o as formatCodebaseSearchHits,g as impact,e as node,x as renderContext,B as renderContextFromQuery,D as renderExploreFromResult,v as renderImpact,A as renderImpactFromTuples,y as renderNode,C as renderNodeDetail,z as renderSearch,u as renderSearchResult,d as search,k as status,s as truncateAtSectionBoundary,t as truncateAtSectionBoundarySync}from'./chunks/chunk-W2JWBAHR.mjs';export{o as CodeBase,h as EdgeExtractor,b as FILE_EXTENSION_MAP,j as Indexer,f as NodeExtractor,c as ParserManager,m as QueryInterface,p as createCodebase,i as createEdgeExtractor,k as createIndexer,g as createNodeExtractor,n as createQueryInterface,d as getParserManager,e as resetParserManager}from'./chunks/chunk-LFH3RTD3.mjs';export{e as ConfigError,b as DatabaseError,n as DatabaseManager,c as FileSystemError,f as IndexError,a as ParserError,g as QueryError,d as SchemaError,h as UnsupportedLanguageError}from'./chunks/chunk-P6QT72IP.mjs';import'./chunks/chunk-UTKA3WG3.mjs';import'./chunks/chunk-TMICZT3L.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/codebase",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"description": "Code Knowledge Graph SDK for EASBot - Property Graph model for code indexing and querying with Tree-sitter parsing, FTS hybrid search, and incremental updates",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"LICENSE"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ai-sdk/provider": "^3.0.
|
|
53
|
-
"@ai-sdk/provider-utils": "^4.0.
|
|
54
|
-
"@ai-sdk/openai-compatible": "
|
|
55
|
-
"@ai-sdk/anthropic": "
|
|
52
|
+
"@ai-sdk/provider": "^3.0.15",
|
|
53
|
+
"@ai-sdk/provider-utils": "^4.0.45",
|
|
54
|
+
"@ai-sdk/openai-compatible": "3.0.30",
|
|
55
|
+
"@ai-sdk/anthropic": "3.0.110",
|
|
56
56
|
"@parcel/watcher": "^2.5.6",
|
|
57
57
|
"@tree-sitter-grammars/tree-sitter-zig": "^1.1.2",
|
|
58
|
-
"ai": "^6.0.
|
|
59
|
-
"better-sqlite3": "^13.0.
|
|
60
|
-
"commander": "^
|
|
58
|
+
"ai": "^6.0.253",
|
|
59
|
+
"better-sqlite3": "^13.0.3",
|
|
60
|
+
"commander": "^15.0.0",
|
|
61
61
|
"tree-sitter-c": "^0.24.1",
|
|
62
62
|
"tree-sitter-c-sharp": "^0.23.5",
|
|
63
63
|
"tree-sitter-cpp": "^0.23.4",
|
|
@@ -73,14 +73,15 @@
|
|
|
73
73
|
"web-tree-sitter": "^0.26.8",
|
|
74
74
|
"xdg-basedir": "^5.1.0",
|
|
75
75
|
"zod": "^4.4.3",
|
|
76
|
-
"@easbot/
|
|
77
|
-
"@easbot/
|
|
78
|
-
"@easbot/mcp": "0.3.
|
|
79
|
-
"@easbot/
|
|
80
|
-
"@easbot/
|
|
76
|
+
"@easbot/local-model-sdk": "0.3.16",
|
|
77
|
+
"@easbot/database": "0.3.16",
|
|
78
|
+
"@easbot/mcp": "0.3.16",
|
|
79
|
+
"@easbot/terminal": "0.3.16",
|
|
80
|
+
"@easbot/types": "0.3.16",
|
|
81
|
+
"@easbot/utils": "0.3.16"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@types/node": "^25.
|
|
84
|
+
"@types/node": "^25.9.5",
|
|
84
85
|
"@vitest/coverage-v8": "^4.1.5",
|
|
85
86
|
"dotenv": "^17.4.2",
|
|
86
87
|
"tsup": "^8.5.1",
|
|
@@ -88,7 +89,7 @@
|
|
|
88
89
|
"vitest": "^4.1.5"
|
|
89
90
|
},
|
|
90
91
|
"engines": {
|
|
91
|
-
"node": ">=22.22.
|
|
92
|
+
"node": ">=22.22.2"
|
|
92
93
|
},
|
|
93
94
|
"publishConfig": {
|
|
94
95
|
"access": "public"
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk4KHRTABC_cjs=require('./chunk-4KHRTABC.cjs'),chunk7XCIIOM6_cjs=require('./chunk-7XCIIOM6.cjs'),chunkTS4OAYIJ_cjs=require('./chunk-TS4OAYIJ.cjs'),utils=require('@easbot/utils'),types=require('@easbot/types');var R=class extends Error{constructor(n,l,a){super(n);chunkTS4OAYIJ_cjs.a(this,"code",l);chunkTS4OAYIJ_cjs.a(this,"details",a);this.name="ServiceError";}},P=class extends R{constructor(t,n=[]){super(`Node not found: ${t}`,"NOT_FOUND",{name:t,candidates:n});}},L=class extends R{constructor(t,n){super(`Ambiguous name "${t}" \u2014 ${n.length} candidates`,"AMBIGUOUS",{name:t,candidates:n});}};utils.Log.create({service:"codebase-service"});var N=utils.Filesystem.toUnixPath;async function k(e,t,n){if(n.nodeId){let o=e.getNode(n.nodeId);if(!o)throw new P(`nodeId=${n.nodeId}`);return {node:o,candidates:[]}}if(!n.name)throw new R("Either name or nodeId is required","NOT_FOUND",n);let a=e.queryNodes({limit:5e3});if(n.file){let o=N(n.file),r=a.filter(c=>N(c.file_path).endsWith(o)||N(c.file_path).includes(o));r.length>0&&(a=r);}if(n.kind){let o=n.kind.toLowerCase(),r=a.filter(c=>c.ast_type.includes(o)||c.name.toLowerCase().includes(o));r.length>0&&(a=r);}let i=a.find(o=>o.name===n.name||o.id.split(":").pop()===n.name);if(i)return {node:i,candidates:[]};let d=chunk4KHRTABC_cjs.l(n.name,a,{limit:10,minScore:.5});if(d.length===0)throw new P(n.name);if(d.length===1){let o=e.getNode(d[0].nodeId);if(!o)throw new P(n.name);return {node:o,candidates:d.map(r=>({node:o,score:r.score}))}}let s=[];for(let o of d){let r=e.getNode(o.nodeId);r&&s.push({node:r,score:o.score});}throw s.length===0?new P(n.name):new L(n.name,s)}async function C(e){let t=chunk7XCIIOM6_cjs.c(e.rootDir),n=new chunk4KHRTABC_cjs.o({workspaceDir:e.workspaceDir,database:{path:t,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 de(e,t,n,l){let a=l==="in"?e.source:e.target,i=n.getNodeById(a);return i?{id:i.id,name:i.name,astType:i.ast_type,filePath:N(i.file_path),startLine:i.start_line??0,relation:e.relation}:null}async function V(e,t){let n=Date.now(),d=await(await C(e)).getQuery().search(t.query??"",{maxResults:t.maxResults??10,language:t.language,filePath:t.file,astType:t.astType,includeEdges:true,enableFts:t.enableFts!==false,enableEmbedding:t.enableEmbedding!==false});if(t.kind){let o=t.kind.toLowerCase();d=d.filter(r=>r.ast_type.includes(o)||r.name.toLowerCase().includes(o));}if(t.file){let o=N(t.file);d=d.filter(r=>N(r.file_path).endsWith(o)||N(r.file_path).includes(o));}let s=d.map(o=>({node:o,edges:o.edges??[],source:"basic",score:0,snippet:(o.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:s.length,hits:s,durationMs:Date.now()-n,truncated:false}}async function ue(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await k(l,e,t),d=[];if(t.includeEdges){let s=t.edgesLimit??50;d=a.queryEdges({sourceOrTarget:[i.id],limit:s});}return {node:i,edges:d}}var pe=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function me(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await k(l,e,t);if(!i)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let d=t.depth??2,s=t.maxNodes??100,o=t.direction??"both",r=new Map,c=[{nodeId:i.id,depth:0}];r.set(i.id,0);let p=[],u=false;for(;c.length>0;){let g=c.shift();if(g.depth>=d)continue;if(r.size>=s){u=true;break}let f=l.queryNeighbors(g.nodeId,{direction:o,relationTypes:t.relationTypes??pe,limit:s-r.size+1});for(let h of f.edges){p.push(h);let $=h.source===g.nodeId?h.target:h.source;if(!r.has($)&&(r.set($,g.depth+1),c.push({nodeId:$,depth:g.depth+1}),r.size>=s)){u=true;break}}if(u)break}let m=Array.from(r.keys()),y=m.length>0?a.queryNodes({ids:m}):[],E=new Map(y.map(g=>[g.id,g])),b=[];for(let[g,f]of r.entries()){let h=E.get(g);h&&b.push({node:h,depth:f});}return {root:i,nodes:b,edges:p,truncated:u,totalNodes:b.length,totalEdges:p.length}}var ge=["CALLS","IMPORTS","TYPE_REFERENCES"];async function fe(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await k(l,e,t);if(!i)return {root:null,totalImpacted:0,buckets:[]};let d=t.depth??2,s=t.maxResults??50,o=t.relationTypes??ge,r=new Set([i.id]),c=[],p=[i.id];for(let u=1;u<=d&&!(p.length===0||r.size-1>=s);u++){let m=p.map(()=>"?").join(","),y=o.map(()=>"?").join(","),E=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${m}) AND relation IN (${y})`,[...p,...o]),b=[],g=new Set;for(let f of E)if(!r.has(f.source)&&!g.has(f.source)&&(g.add(f.source),r.add(f.source),b.push(f.source),r.size-1>=s))break;if(b.length>0){let f=b.slice(0,10),h=a.queryNodes({ids:f}),$=new Map(h.map(I=>[I.id,I])),re=f.map(I=>{let B=$.get(I);return {id:I,name:B?.name??"(unknown)",filePath:B?N(B.file_path):"(unknown)",relation:"CALLS"}});c.push({depth:u,count:b.length,sample:re});}p=b;}return {root:i,totalImpacted:r.size-1,buckets:c}}var he=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function ye(e,t){return A(e,t,"incoming")}async function be(e,t){return A(e,t,"outgoing")}async function A(e,t,n,l){let a=await C(e),i=a.getQuery(),d=a.getDatabase(),{node:s}=await k(i,e,t);if(!s)return {root:null,callers:[],truncated:false};let o=t.maxResults??20,r=t.relationTypes??he,c=i.queryNeighbors(s.id,{direction:n,relationTypes:r,limit:o+1}),p=[];for(let m of c.edges){let y=de(m,s.id,d,n==="incoming"?"in":"out");y&&p.push(y);}let u=p.length>o;return {root:s,callers:u?p.slice(0,o):p,truncated:u}}async function Ee(e,t){if(!t.query)throw new R("explore requires a non-empty query","NOT_FOUND",{query:t.query});let l=await C(e);l.getQuery();l.getDatabase();let s=(await V(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true})).hits,o=new Map;for(let p of s){let u=N(p.node.file_path),m=o.get(u);m?m.push(p):o.set(u,[p]);}let r=t.maxSymbols??3,c=[];for(let[p,u]of o){let m=u.slice(0,r),y=[];for(let E of m){let b=await A(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"incoming"),g=await A(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"outgoing");y.push({node:E.node,callers:b.callers,callees:g.callers});}c.push({file:p,symbols:y});}return {query:t.query,entryPoints:c,totalHits:s.length}}async function xe(e,t){return await(await C(e)).getStatus()}async function Ne(e,t){return await(await C(e)).healthCheck()}var Pe=utils.Filesystem.toUnixPath;function Ce(e){let t=e.text??"";if(!t)return false;let n=t.slice(0,80);return /\bexport\s/.test(n)||/\bpublic\s/.test(n)?true:(false)}function Se(e){let t=e.text??"";if(!t)return [];let n=t.slice(0,80),l=[];return /\basync\s/.test(n)&&l.push("async"),/\bstatic\s/.test(n)&&l.push("static"),/\babstract\s/.test(n)&&l.push("abstract"),/\breadonly\s/.test(n)&&l.push("readonly"),/\bconst\s/.test(n)&&l.push("const"),/\blet\s/.test(n)&&l.push("let"),l}function x(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:Pe(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:Ce(e),modifiers:Se(e)}}function T(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function G(e,t,n){return e.map((l,a)=>({node:x(l),source:t[a]??"basic",score:n[a]??0,snippet:(l.text??"").slice(0,200).replace(/\s+/g," ").trim(),edges:(l.edges??[]).slice(0,10).map(i=>T(i))}))}function j(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var $e=utils.Log.create({service:"codebase-format-truncate"}),z="**`",Ie="**",Z=24e3,ee=25e3;async function D(e,t={}){let n=t.softLimit??Z,l=t.hardCeiling??ee,a=t.toolName??"codebase",i=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let d=e.slice(0,l),s=d.lastIndexOf(`
|
|
2
|
-
${z}`),o=d.lastIndexOf(`
|
|
3
|
-
`),r;s>l*.5?r=s:o>0?r=o:r=-1;let c=r>0?d.slice(0,r):d,u=c+"\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:`... ${e.length-c.length}/${e.length} characters truncated ...`};try{let m=await utils.TruncateContent.truncate(e,{maxChars:c.length,direction:"head",label:`${a}-output`});return m.truncated?{content:u,truncated:!0,outputPath:m.outputPath,hint:utils.TruncateContent.formatHint(m),info:`... ${m.removedLength}/${m.originalLength} characters truncated ...`}:{content:u,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}catch(m){return $e.warn("TruncateContent.truncate failed, returning without disk hint",{error:m instanceof Error?m.message:String(m)}),{content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}}function _(e,t={}){let n=t.softLimit??Z,l=t.hardCeiling??ee;if(e.length<=n)return {content:e,truncated:false};let a=e.slice(0,l),i=a.lastIndexOf(`
|
|
4
|
-
${z}`),d=a.lastIndexOf(`
|
|
5
|
-
`),s;i>l*.5?s=i:d>0?s=d:s=-1;let o=s>0?a.slice(0,s):a;return {content:o+`
|
|
6
|
-
|
|
7
|
-
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-o.length}/${e.length} characters truncated ...`}}function Le(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));return n>60?">60s ago":`${n}s ago`}function v(e,t){if(!e||e.length===0)return null;let n=e.filter(a=>t.has(a.path));return n.length===0?null:`\u26A0\uFE0F Index may be stale for: ${n.map(a=>`${a.path} (edited ${Le(a.lastEventAt)})`).join(", ")}
|
|
8
|
-
|
|
9
|
-
`}function F(e,t,n={}){return (te[e]??te.default).replace(/<(\w+)>/g,(a,i)=>i==="tool"?t:n[i]??`<${i}>`)}var te={search:`---
|
|
10
|
-
|
|
11
|
-
> **Complete source for N files is included above \u2014 do NOT re-read them.**
|
|
12
|
-
> 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:`---
|
|
13
|
-
|
|
14
|
-
> **Output truncated to budget; the content above is the source of truth.**
|
|
15
|
-
> For more detail, call \`<tool>\` with refined parameters.`};async function H(e,t){let{pendingFiles:n,toolName:l,sync:a=false}=t;if(e.length===0)return w(l,"No matches found.","Try broader search terms, or use `explore` to read source.");let i=we(e),d=new Set(i.keys()),s=[];s.push(v(n,d)??"");let o="[[codebase-search-summary]]";s.push(o+`
|
|
16
|
-
`);let r=e.length;s.push(`**Files with matches:** ${i.size}
|
|
17
|
-
`);for(let[m,y]of i){let E=y.map(h=>h.node.name),b=E.slice(0,5).join(", "),g=E.length>5?`, +${E.length-5} more`:"";s.push(`**\`${m}\`** \u2014 ${b}${g}
|
|
18
|
-
`);let f=y[0]?.node.language??"";s.push("```"+f);for(let h of y)s.push(`L${h.node.startLine} ${h.snippet}`);s.push("```\n");}s.push(F("search",l,{}));let c=s.join(`
|
|
19
|
-
`),p=`Found ${r} symbol${r===1?"":"s"} across ${i.size} file${i.size===1?"":"s"}.`,u=c.replace(o,p);return O(u,t,a)}async function M(e,t,n){let{pendingFiles:l,toolName:a,sync:i=false}=n;if(t.length===0||t.every(r=>r.count===0))return w(a,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let d=t.reduce((r,c)=>r+c.count,0),s=Fe(d),o=[];o.push(v(l,new Set([e.filePath]))??""),o.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${d})
|
|
20
|
-
`);for(let r of t){o.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let c of r.samples.slice(0,5))o.push(` - \`${c.name}\` ${c.file}:${c.line} [${c.relation}]`);r.samples.length>5&&o.push(` - ... and ${r.samples.length-5} more`);}return o.push(F("impact",a,{root:e.name,riskLevel:s})),O(o.join(`
|
|
21
|
-
`),n,i)}function Fe(e){return e>=100?"CRITICAL":e>=50?"HIGH":e>=10?"MEDIUM":"LOW"}function Q(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function K(e,t){let{root:n,incoming:l,outgoing:a,neighbors:i}=e,{pendingFiles:d,toolName:s,sync:o=false}=t;if(l.length===0&&a.length===0&&i.length===0)return w(s,`No relations found for \`${n.name}\`.`,"This is a leaf node.");let r=[];r.push(v(d,new Set([n.filePath]))??""),r.push(`**Context for \`${n.name}\`** (${n.astType}, ${n.language}, ${n.filePath}:${n.startLine})
|
|
22
|
-
`),r.push(`**Incoming** (${l.length}):`);for(let c of l.slice(0,10))r.push(`- ${c.source} \u2192 [${c.relation}] \u2192 \`${n.name}\``);l.length>10&&r.push(`- ... and ${l.length-10} more`),r.push(""),r.push(`**Outgoing** (${a.length}):`);for(let c of a.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${c.relation}] \u2192 ${c.target}`);if(a.length>10&&r.push(`- ... and ${a.length-10} more`),r.push(""),i.length>0){r.push(`**Neighbors** (${i.length}):`);for(let c of i.slice(0,20))r.push(`- [d=${c.depth}] \`${c.node.name}\` (${c.node.astType}) ${c.node.filePath}:${c.node.startLine}`);i.length>20&&r.push(`- ... and ${i.length-20} more`),r.push("");}return r.push(F("context",s,{})),O(r.join(`
|
|
23
|
-
`),t,o)}async function q(e,t,n){let{pendingFiles:l,toolName:a,sync:i=false}=n;if(!e.id)return w(a,"Node not found.","Check the node ID or use `search` to find it.");let d=t.filter(r=>r.direction==="in"),s=t.filter(r=>r.direction==="out"),o=[];o.push(v(l,new Set([e.filePath]))??""),o.push(`**Node: \`${e.name}\`**
|
|
24
|
-
`),o.push(`- ID: \`${e.id}\``),o.push(`- Kind: ${e.astType}`),o.push(`- Language: ${e.language}`),o.push(`- Location: ${e.filePath}:${e.startLine}-${e.endLine}`),o.push(`- Exported: ${e.isExported}`),e.modifiers.length>0&&o.push(`- Modifiers: ${e.modifiers.join(", ")}`),o.push(""),o.push(`**Edges** (incoming: ${d.length} / outgoing: ${s.length}):`);for(let r of d.slice(0,5))o.push(`- \u2190 [${r.relation}] ${r.source}`);for(let r of s.slice(0,5))o.push(`- \u2192 [${r.relation}] ${r.target}`);return t.length>10&&o.push(`- ... and ${t.length-10} more`),o.push(F("default",a,{})),O(o.join(`
|
|
25
|
-
`),n,i)}async function ne(e,t){let{entryPoints:n,totalHits:l,query:a}=e,{toolName:i,sync:d=false}=t;if(n.length===0)return w(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
|
|
26
|
-
`),s.push(`**Query:** ${a} `),s.push(`**Total hits:** ${l} `),s.push(`**Entry points:** ${n.length}
|
|
27
|
-
`);for(let o of n){s.push(`**\`${o.file}\`** \u2014 ${o.symbols.length} symbol${o.symbols.length===1?"":"s"}
|
|
28
|
-
`);for(let r of o.symbols){let c=(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(c),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(`---
|
|
29
|
-
`),s.push(F("context",i,{})),O(s.join(`
|
|
30
|
-
`),t,d)}function we(e){let t=new Map;for(let n of e){let l=n.node.filePath,a=t.get(l);a?a.push(n):t.set(l,[n]);}return t}function w(e,t,n){return `**${e}**
|
|
31
|
-
|
|
32
|
-
${t}
|
|
33
|
-
|
|
34
|
-
> **Tip:** ${n}`}async function O(e,t,n){let l={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?_(e,l):await D(e,l)).content}var Ae=utils.Log.create({service:"codebase-format-render"});async function ke(e,t){if(e.length===0)return H([],t);let n=G(e,e.map(()=>"basic"),e.map(()=>0));return H(n,t)}async function De(e,t,n){if(t.length===0)return M(x(e),[],n);let l=[{depth:1,count:t.length,riskLabel:Q(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:x(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return M(x(e),l,n)}async function _e(e,t,n,l,a){let i=x(e),d=t.map(r=>T(r,"in")),s=n.map(r=>T(r,"out")),o=l.map(r=>({node:x(r),depth:1}));return K({root:i,incoming:d,outgoing:s,neighbors:o},a)}async function ve(e,t,n){if(!e)return q(j(),[],n);let l=x(e),a=t.map(i=>{let d=i.target===e.id?"in":"out";return T(i,d)});return q(l,a,n)}async function He(e,t){let n={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(l=>({file:l.file,symbols:l.symbols.map(a=>({node:x(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 ne(n,t)}Ae.debug("format/render.ts loaded");exports.A=De;exports.B=_e;exports.C=ve;exports.D=He;exports.a=R;exports.b=P;exports.c=L;exports.d=V;exports.e=ue;exports.f=me;exports.g=fe;exports.h=ye;exports.i=be;exports.j=Ee;exports.k=xe;exports.l=Ne;exports.m=x;exports.n=T;exports.o=G;exports.p=j;exports.q=z;exports.r=Ie;exports.s=D;exports.t=_;exports.u=H;exports.v=M;exports.w=Q;exports.x=K;exports.y=q;exports.z=ke;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {o,l}from'./chunk-W25T3SKH.mjs';import {c}from'./chunk-UTKA3WG3.mjs';import {a}from'./chunk-G3IYU6TZ.mjs';import {Log,Filesystem,TruncateContent}from'@easbot/utils';import {DEFAULT_SEARCH_CONFIG,DEFAULT_PARSER_CONFIG,DEFAULT_INDEXER_CONFIG,DEFAULT_EMBEDDING_CONFIG}from'@easbot/types';var R=class extends Error{constructor(n,l,a$1){super(n);a(this,"code",l);a(this,"details",a$1);this.name="ServiceError";}},P=class extends R{constructor(t,n=[]){super(`Node not found: ${t}`,"NOT_FOUND",{name:t,candidates:n});}},F=class extends R{constructor(t,n){super(`Ambiguous name "${t}" \u2014 ${n.length} candidates`,"AMBIGUOUS",{name:t,candidates:n});}};Log.create({service:"codebase-service"});var N=Filesystem.toUnixPath;async function D(e,t,n){if(n.nodeId){let o=e.getNode(n.nodeId);if(!o)throw new P(`nodeId=${n.nodeId}`);return {node:o,candidates:[]}}if(!n.name)throw new R("Either name or nodeId is required","NOT_FOUND",n);let a=e.queryNodes({limit:5e3});if(n.file){let o=N(n.file),r=a.filter(c=>N(c.file_path).endsWith(o)||N(c.file_path).includes(o));r.length>0&&(a=r);}if(n.kind){let o=n.kind.toLowerCase(),r=a.filter(c=>c.ast_type.includes(o)||c.name.toLowerCase().includes(o));r.length>0&&(a=r);}let i=a.find(o=>o.name===n.name||o.id.split(":").pop()===n.name);if(i)return {node:i,candidates:[]};let d=l(n.name,a,{limit:10,minScore:.5});if(d.length===0)throw new P(n.name);if(d.length===1){let o=e.getNode(d[0].nodeId);if(!o)throw new P(n.name);return {node:o,candidates:d.map(r=>({node:o,score:r.score}))}}let s=[];for(let o of d){let r=e.getNode(o.nodeId);r&&s.push({node:r,score:o.score});}throw s.length===0?new P(n.name):new F(n.name,s)}async function C(e){let t=c(e.rootDir),n=new o({workspaceDir:e.workspaceDir,database:{path:t,walMode:true},embedding:DEFAULT_EMBEDDING_CONFIG,indexer:DEFAULT_INDEXER_CONFIG,parser:DEFAULT_PARSER_CONFIG,search:DEFAULT_SEARCH_CONFIG,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});return await n.initialize(),n}function ue(e,t,n,l){let a=l==="in"?e.source:e.target,i=n.getNodeById(a);return i?{id:i.id,name:i.name,astType:i.ast_type,filePath:N(i.file_path),startLine:i.start_line??0,relation:e.relation}:null}async function J(e,t){let n=Date.now(),d=await(await C(e)).getQuery().search(t.query??"",{maxResults:t.maxResults??10,language:t.language,filePath:t.file,astType:t.astType,includeEdges:true,enableFts:t.enableFts!==false,enableEmbedding:t.enableEmbedding!==false});if(t.kind){let o=t.kind.toLowerCase();d=d.filter(r=>r.ast_type.includes(o)||r.name.toLowerCase().includes(o));}if(t.file){let o=N(t.file);d=d.filter(r=>N(r.file_path).endsWith(o)||N(r.file_path).includes(o));}let s=d.map(o=>({node:o,edges:o.edges??[],source:"basic",score:0,snippet:(o.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:s.length,hits:s,durationMs:Date.now()-n,truncated:false}}async function pe(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t),d=[];if(t.includeEdges){let s=t.edgesLimit??50;d=a.queryEdges({sourceOrTarget:[i.id],limit:s});}return {node:i,edges:d}}var me=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function ge(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t);if(!i)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let d=t.depth??2,s=t.maxNodes??100,o=t.direction??"both",r=new Map,c=[{nodeId:i.id,depth:0}];r.set(i.id,0);let p=[],u=false;for(;c.length>0;){let g=c.shift();if(g.depth>=d)continue;if(r.size>=s){u=true;break}let f=l.queryNeighbors(g.nodeId,{direction:o,relationTypes:t.relationTypes??me,limit:s-r.size+1});for(let h of f.edges){p.push(h);let I=h.source===g.nodeId?h.target:h.source;if(!r.has(I)&&(r.set(I,g.depth+1),c.push({nodeId:I,depth:g.depth+1}),r.size>=s)){u=true;break}}if(u)break}let m=Array.from(r.keys()),y=m.length>0?a.queryNodes({ids:m}):[],E=new Map(y.map(g=>[g.id,g])),b=[];for(let[g,f]of r.entries()){let h=E.get(g);h&&b.push({node:h,depth:f});}return {root:i,nodes:b,edges:p,truncated:u,totalNodes:b.length,totalEdges:p.length}}var fe=["CALLS","IMPORTS","TYPE_REFERENCES"];async function he(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t);if(!i)return {root:null,totalImpacted:0,buckets:[]};let d=t.depth??2,s=t.maxResults??50,o=t.relationTypes??fe,r=new Set([i.id]),c=[],p=[i.id];for(let u=1;u<=d&&!(p.length===0||r.size-1>=s);u++){let m=p.map(()=>"?").join(","),y=o.map(()=>"?").join(","),E=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${m}) AND relation IN (${y})`,[...p,...o]),b=[],g=new Set;for(let f of E)if(!r.has(f.source)&&!g.has(f.source)&&(g.add(f.source),r.add(f.source),b.push(f.source),r.size-1>=s))break;if(b.length>0){let f=b.slice(0,10),h=a.queryNodes({ids:f}),I=new Map(h.map(L=>[L.id,L])),oe=f.map(L=>{let U=I.get(L);return {id:L,name:U?.name??"(unknown)",filePath:U?N(U.file_path):"(unknown)",relation:"CALLS"}});c.push({depth:u,count:b.length,sample:oe});}p=b;}return {root:i,totalImpacted:r.size-1,buckets:c}}var ye=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function be(e,t){return k(e,t,"incoming")}async function Ee(e,t){return k(e,t,"outgoing")}async function k(e,t,n,l){let a=await C(e),i=a.getQuery(),d=a.getDatabase(),{node:s}=await D(i,e,t);if(!s)return {root:null,callers:[],truncated:false};let o=t.maxResults??20,r=t.relationTypes??ye,c=i.queryNeighbors(s.id,{direction:n,relationTypes:r,limit:o+1}),p=[];for(let m of c.edges){let y=ue(m,s.id,d,n==="incoming"?"in":"out");y&&p.push(y);}let u=p.length>o;return {root:s,callers:u?p.slice(0,o):p,truncated:u}}async function xe(e,t){if(!t.query)throw new R("explore requires a non-empty query","NOT_FOUND",{query:t.query});let l=await C(e);l.getQuery();l.getDatabase();let s=(await J(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true})).hits,o=new Map;for(let p of s){let u=N(p.node.file_path),m=o.get(u);m?m.push(p):o.set(u,[p]);}let r=t.maxSymbols??3,c=[];for(let[p,u]of o){let m=u.slice(0,r),y=[];for(let E of m){let b=await k(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"incoming"),g=await k(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"outgoing");y.push({node:E.node,callers:b.callers,callees:g.callers});}c.push({file:p,symbols:y});}return {query:t.query,entryPoints:c,totalHits:s.length}}async function Ne(e,t){return await(await C(e)).getStatus()}async function Re(e,t){return await(await C(e)).healthCheck()}var Ce=Filesystem.toUnixPath;function Se(e){let t=e.text??"";if(!t)return false;let n=t.slice(0,80);return /\bexport\s/.test(n)||/\bpublic\s/.test(n)?true:(false)}function Te(e){let t=e.text??"";if(!t)return [];let n=t.slice(0,80),l=[];return /\basync\s/.test(n)&&l.push("async"),/\bstatic\s/.test(n)&&l.push("static"),/\babstract\s/.test(n)&&l.push("abstract"),/\breadonly\s/.test(n)&&l.push("readonly"),/\bconst\s/.test(n)&&l.push("const"),/\blet\s/.test(n)&&l.push("let"),l}function x(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:Ce(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:Se(e),modifiers:Te(e)}}function $(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function j(e,t,n){return e.map((l,a)=>({node:x(l),source:t[a]??"basic",score:n[a]??0,snippet:(l.text??"").slice(0,200).replace(/\s+/g," ").trim(),edges:(l.edges??[]).slice(0,10).map(i=>$(i))}))}function z(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var Ie=Log.create({service:"codebase-format-truncate"}),Q="**`",Le="**",ee=24e3,te=25e3;async function _(e,t={}){let n=t.softLimit??ee,l=t.hardCeiling??te,a=t.toolName??"codebase",i=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let d=e.slice(0,l),s=d.lastIndexOf(`
|
|
2
|
-
${Q}`),o=d.lastIndexOf(`
|
|
3
|
-
`),r;s>l*.5?r=s:o>0?r=o:r=-1;let c=r>0?d.slice(0,r):d,u=c+"\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:`... ${e.length-c.length}/${e.length} characters truncated ...`};try{let m=await TruncateContent.truncate(e,{maxChars:c.length,direction:"head",label:`${a}-output`});return m.truncated?{content:u,truncated:!0,outputPath:m.outputPath,hint:TruncateContent.formatHint(m),info:`... ${m.removedLength}/${m.originalLength} characters truncated ...`}:{content:u,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}catch(m){return Ie.warn("TruncateContent.truncate failed, returning without disk hint",{error:m instanceof Error?m.message:String(m)}),{content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}}function v(e,t={}){let n=t.softLimit??ee,l=t.hardCeiling??te;if(e.length<=n)return {content:e,truncated:false};let a=e.slice(0,l),i=a.lastIndexOf(`
|
|
4
|
-
${Q}`),d=a.lastIndexOf(`
|
|
5
|
-
`),s;i>l*.5?s=i:d>0?s=d:s=-1;let o=s>0?a.slice(0,s):a;return {content:o+`
|
|
6
|
-
|
|
7
|
-
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-o.length}/${e.length} characters truncated ...`}}function Fe(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));return n>60?">60s ago":`${n}s ago`}function H(e,t){if(!e||e.length===0)return null;let n=e.filter(a=>t.has(a.path));return n.length===0?null:`\u26A0\uFE0F Index may be stale for: ${n.map(a=>`${a.path} (edited ${Fe(a.lastEventAt)})`).join(", ")}
|
|
8
|
-
|
|
9
|
-
`}function w(e,t,n={}){return (ne[e]??ne.default).replace(/<(\w+)>/g,(a,i)=>i==="tool"?t:n[i]??`<${i}>`)}var ne={search:`---
|
|
10
|
-
|
|
11
|
-
> **Complete source for N files is included above \u2014 do NOT re-read them.**
|
|
12
|
-
> 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:`---
|
|
13
|
-
|
|
14
|
-
> **Output truncated to budget; the content above is the source of truth.**
|
|
15
|
-
> For more detail, call \`<tool>\` with refined parameters.`};async function M(e,t){let{pendingFiles:n,toolName:l,sync:a=false}=t;if(e.length===0)return O(l,"No matches found.","Try broader search terms, or use `explore` to read source.");let i=Oe(e),d=new Set(i.keys()),s=[];s.push(H(n,d)??"");let o="[[codebase-search-summary]]";s.push(o+`
|
|
16
|
-
`);let r=e.length;s.push(`**Files with matches:** ${i.size}
|
|
17
|
-
`);for(let[m,y]of i){let E=y.map(h=>h.node.name),b=E.slice(0,5).join(", "),g=E.length>5?`, +${E.length-5} more`:"";s.push(`**\`${m}\`** \u2014 ${b}${g}
|
|
18
|
-
`);let f=y[0]?.node.language??"";s.push("```"+f);for(let h of y)s.push(`L${h.node.startLine} ${h.snippet}`);s.push("```\n");}s.push(w("search",l,{}));let c=s.join(`
|
|
19
|
-
`),p=`Found ${r} symbol${r===1?"":"s"} across ${i.size} file${i.size===1?"":"s"}.`,u=c.replace(o,p);return A(u,t,a)}async function q(e,t,n){let{pendingFiles:l,toolName:a,sync:i=false}=n;if(t.length===0||t.every(r=>r.count===0))return O(a,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let d=t.reduce((r,c)=>r+c.count,0),s=we(d),o=[];o.push(H(l,new Set([e.filePath]))??""),o.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${d})
|
|
20
|
-
`);for(let r of t){o.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let c of r.samples.slice(0,5))o.push(` - \`${c.name}\` ${c.file}:${c.line} [${c.relation}]`);r.samples.length>5&&o.push(` - ... and ${r.samples.length-5} more`);}return o.push(w("impact",a,{root:e.name,riskLevel:s})),A(o.join(`
|
|
21
|
-
`),n,i)}function we(e){return e>=100?"CRITICAL":e>=50?"HIGH":e>=10?"MEDIUM":"LOW"}function K(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function W(e,t){let{root:n,incoming:l,outgoing:a,neighbors:i}=e,{pendingFiles:d,toolName:s,sync:o=false}=t;if(l.length===0&&a.length===0&&i.length===0)return O(s,`No relations found for \`${n.name}\`.`,"This is a leaf node.");let r=[];r.push(H(d,new Set([n.filePath]))??""),r.push(`**Context for \`${n.name}\`** (${n.astType}, ${n.language}, ${n.filePath}:${n.startLine})
|
|
22
|
-
`),r.push(`**Incoming** (${l.length}):`);for(let c of l.slice(0,10))r.push(`- ${c.source} \u2192 [${c.relation}] \u2192 \`${n.name}\``);l.length>10&&r.push(`- ... and ${l.length-10} more`),r.push(""),r.push(`**Outgoing** (${a.length}):`);for(let c of a.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${c.relation}] \u2192 ${c.target}`);if(a.length>10&&r.push(`- ... and ${a.length-10} more`),r.push(""),i.length>0){r.push(`**Neighbors** (${i.length}):`);for(let c of i.slice(0,20))r.push(`- [d=${c.depth}] \`${c.node.name}\` (${c.node.astType}) ${c.node.filePath}:${c.node.startLine}`);i.length>20&&r.push(`- ... and ${i.length-20} more`),r.push("");}return r.push(w("context",s,{})),A(r.join(`
|
|
23
|
-
`),t,o)}async function B(e,t,n){let{pendingFiles:l,toolName:a,sync:i=false}=n;if(!e.id)return O(a,"Node not found.","Check the node ID or use `search` to find it.");let d=t.filter(r=>r.direction==="in"),s=t.filter(r=>r.direction==="out"),o=[];o.push(H(l,new Set([e.filePath]))??""),o.push(`**Node: \`${e.name}\`**
|
|
24
|
-
`),o.push(`- ID: \`${e.id}\``),o.push(`- Kind: ${e.astType}`),o.push(`- Language: ${e.language}`),o.push(`- Location: ${e.filePath}:${e.startLine}-${e.endLine}`),o.push(`- Exported: ${e.isExported}`),e.modifiers.length>0&&o.push(`- Modifiers: ${e.modifiers.join(", ")}`),o.push(""),o.push(`**Edges** (incoming: ${d.length} / outgoing: ${s.length}):`);for(let r of d.slice(0,5))o.push(`- \u2190 [${r.relation}] ${r.source}`);for(let r of s.slice(0,5))o.push(`- \u2192 [${r.relation}] ${r.target}`);return t.length>10&&o.push(`- ... and ${t.length-10} more`),o.push(w("default",a,{})),A(o.join(`
|
|
25
|
-
`),n,i)}async function re(e,t){let{entryPoints:n,totalHits:l,query:a}=e,{toolName:i,sync:d=false}=t;if(n.length===0)return O(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
|
|
26
|
-
`),s.push(`**Query:** ${a} `),s.push(`**Total hits:** ${l} `),s.push(`**Entry points:** ${n.length}
|
|
27
|
-
`);for(let o of n){s.push(`**\`${o.file}\`** \u2014 ${o.symbols.length} symbol${o.symbols.length===1?"":"s"}
|
|
28
|
-
`);for(let r of o.symbols){let c=(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(c),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(`---
|
|
29
|
-
`),s.push(w("context",i,{})),A(s.join(`
|
|
30
|
-
`),t,d)}function Oe(e){let t=new Map;for(let n of e){let l=n.node.filePath,a=t.get(l);a?a.push(n):t.set(l,[n]);}return t}function O(e,t,n){return `**${e}**
|
|
31
|
-
|
|
32
|
-
${t}
|
|
33
|
-
|
|
34
|
-
> **Tip:** ${n}`}async function A(e,t,n){let l={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?v(e,l):await _(e,l)).content}var ke=Log.create({service:"codebase-format-render"});async function De(e,t){if(e.length===0)return M([],t);let n=j(e,e.map(()=>"basic"),e.map(()=>0));return M(n,t)}async function _e(e,t,n){if(t.length===0)return q(x(e),[],n);let l=[{depth:1,count:t.length,riskLabel:K(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:x(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return q(x(e),l,n)}async function ve(e,t,n,l,a){let i=x(e),d=t.map(r=>$(r,"in")),s=n.map(r=>$(r,"out")),o=l.map(r=>({node:x(r),depth:1}));return W({root:i,incoming:d,outgoing:s,neighbors:o},a)}async function He(e,t,n){if(!e)return B(z(),[],n);let l=x(e),a=t.map(i=>{let d=i.target===e.id?"in":"out";return $(i,d)});return B(l,a,n)}async function Me(e,t){let n={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(l=>({file:l.file,symbols:l.symbols.map(a=>({node:x(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 re(n,t)}ke.debug("format/render.ts loaded");export{_e as A,ve as B,He as C,Me as D,R as a,P as b,F as c,J as d,pe as e,ge as f,he as g,be as h,Ee as i,xe as j,Ne as k,Re as l,x as m,$ as n,j as o,z as p,Q as q,Le as r,_ as s,v as t,M as u,q as v,K as w,W as x,B as y,De as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkDMRAZKIP_cjs=require('./chunk-DMRAZKIP.cjs');require('./chunk-U5G7MP3K.cjs'),require('./chunk-7PW7HWOC.cjs'),require('./chunk-JVX6PHPN.cjs'),require('./chunk-RPRDGNXG.cjs'),require('./chunk-4KHRTABC.cjs'),require('./chunk-RLZHDTHY.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkDMRAZKIP_cjs.c}});Object.defineProperty(exports,"handleCodebaseCli",{enumerable:true,get:function(){return chunkDMRAZKIP_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkDMRAZKIP_cjs.a}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkDMRAZKIP_cjs.b}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{c as COMMANDS_HELP,d as handleCodebaseCli,a as renderBanner,b as renderHelp}from'./chunk-PLRTEGLZ.mjs';import'./chunk-7ZBQQZOA.mjs';import'./chunk-P566CDI2.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-XQID3NKI.mjs';import'./chunk-W25T3SKH.mjs';import'./chunk-Z4Y3VCYS.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk4KHRTABC_cjs=require('./chunk-4KHRTABC.cjs'),chunkRLZHDTHY_cjs=require('./chunk-RLZHDTHY.cjs');require('./chunk-7XCIIOM6.cjs'),require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"CodeBase",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.o}});Object.defineProperty(exports,"EdgeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.h}});Object.defineProperty(exports,"FILE_EXTENSION_MAP",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.b}});Object.defineProperty(exports,"Indexer",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.j}});Object.defineProperty(exports,"NodeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.f}});Object.defineProperty(exports,"ParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.c}});Object.defineProperty(exports,"QueryInterface",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.m}});Object.defineProperty(exports,"createCodebase",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.p}});Object.defineProperty(exports,"createEdgeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.i}});Object.defineProperty(exports,"createIndexer",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.k}});Object.defineProperty(exports,"createNodeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.g}});Object.defineProperty(exports,"createQueryInterface",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.n}});Object.defineProperty(exports,"getParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.d}});Object.defineProperty(exports,"resetParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.e}});Object.defineProperty(exports,"ConfigError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.e}});Object.defineProperty(exports,"DatabaseError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.b}});Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.n}});Object.defineProperty(exports,"FileSystemError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.c}});Object.defineProperty(exports,"IndexError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.f}});Object.defineProperty(exports,"ParserError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.a}});Object.defineProperty(exports,"QueryError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.g}});Object.defineProperty(exports,"SchemaError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.d}});Object.defineProperty(exports,"UnsupportedLanguageError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.h}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkRLZHDTHY_cjs=require('./chunk-RLZHDTHY.cjs');require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.n}});Object.defineProperty(exports,"EXTRACTION_VERSION",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.m}});Object.defineProperty(exports,"getDbPath",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.p}});Object.defineProperty(exports,"isClosed",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.o}});Object.defineProperty(exports,"transaction",{enumerable:true,get:function(){return chunkRLZHDTHY_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-Z4Y3VCYS.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as FileWatcher,e as clearWatcherPid,b as getWatcherPidPath,c as readWatcherPid,d as writeWatcherPid}from'./chunk-7ZBQQZOA.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkU5G7MP3K_cjs=require('./chunk-U5G7MP3K.cjs');require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"FileWatcher",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.a}});Object.defineProperty(exports,"clearWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.e}});Object.defineProperty(exports,"getWatcherPidPath",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.b}});Object.defineProperty(exports,"readWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.c}});Object.defineProperty(exports,"writeWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.d}});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {d,z as z$1,e,C,f as f$1,B,g,A,h,i,j,D as D$1,k,l,b,c,a as a$1}from'./chunk-XQID3NKI.mjs';import'./chunk-W25T3SKH.mjs';import'./chunk-Z4Y3VCYS.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';import {ToolRegistry,createAndStartStdioServer}from'@easbot/mcp';import {Log}from'@easbot/utils';var f=Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"],U;(o=>{let n;function r(){return n||(f.debug("initializing CodebaseStdioServer state factory (lazy)"),n=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),n}async function c(s,i){let u=r()(),l=new ToolRegistry;ce(l,s);let g=u.toolNames;f.info("starting codebase MCP stdio server",{id:i.id,name:i.name,toolCount:g.length});let y=await createAndStartStdioServer(i,l),b=null,q=new Promise(d=>{b=d;}),S=d=>{f.info("received signal, stopping MCP server",{signal:d}),b?.();},x=()=>S("SIGINT"),T=()=>S("SIGTERM");process.on("SIGINT",x),process.on("SIGTERM",T);try{await q;}finally{try{process.off("SIGINT",x),process.off("SIGTERM",T);}catch(d){f.warn("failed to remove signal handlers",{error:d instanceof Error?d.message:String(d)});}try{await y.stop();}catch(d){f.warn("server.stop failed during cleanup",{error:d instanceof Error?d.message:String(d)});}try{await s.close();}catch(d){f.warn("codebase.close failed during cleanup",{error:d instanceof Error?d.message:String(d)});}}return {id:i.id,name:i.name,version:i.version,tools:g}}o.start=c;function e(){return r()().toolNames}o.getToolNames=e;function t(){n=void 0;}o.__resetForTests=t;})(U||(U={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",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",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},edgesLimit:{type:"number",description:"Max edges to return (default 50).",default:50}},required:[]},V={type:"object",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"}},required:[]},z={type:"object",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:50,minimum:1,maximum:200}},required:[]},P={type:"object",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:20,minimum:1,maximum:200}},required:[]},K=P,J={type:"object",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},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"]},D={type:"object",properties:{}},Z={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 20). 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 20). 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 a(n,r=false){return {content:[{type:"text",text:n}],...r&&{isError:true}}}function m(n){return {workspaceDir:n.getWorkspaceDir?.()??process.cwd(),rootDir:n.getWorkspaceDir?.()??process.cwd()}}function p(n,r){if(n instanceof b)return `**${r}** \u2014 node not found. Try \`query\` first to discover the symbol.`;if(n instanceof c){let c=n.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 n instanceof a$1?`**${r}** \u2014 ${n.message}`:n instanceof Error?`**${r}** \u2014 internal error: ${n.message}`:`**${r}** \u2014 internal error: ${String(n)}`}function ee(n){return async(r,c)=>{let e=r;try{let t=m(n),s=(await 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})).hits.map(u=>u.node),i=await z$1(s,{pendingFiles:[],toolName:"query",writeToDisk:!1});return a(i)}catch(t){return a(p(t,"query"),true)}}}function te(n){return async(r,c)=>{let e$1=r;try{let t=m(n),o=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,edgesLimit:e$1.edgesLimit??50}),s=await C(o.node,o.edges,{pendingFiles:[],toolName:"node",writeToDisk:!1});return a(s)}catch(t){return a(p(t,"node"),true)}}}function ne(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await f$1(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"});if(!o.root)return a("**context** \u2014 node not found.");let s=[],i=[];for(let l of o.edges)l.target===o.root.id?s.push(l):i.push(l);let u=await B(o.root,s,i,o.nodes.map(l=>l.node),{pendingFiles:[],toolName:"context",writeToDisk:!1});return a(u)}catch(t){return a(p(t,"context"),true)}}}function oe(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await g(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxResults:e.maxResults??50});if(!o.root)return a("**impact** \u2014 node not found.");let s=[],i=n.getDatabase();for(let l of o.buckets)for(let g of l.sample){let y=i.getNodeById(g.id);y&&s.push({source:y,relation:g.relation});}let u=await A(o.root,s,{pendingFiles:[],toolName:"impact",writeToDisk:!1});return a(u)}catch(t){return a(p(t,"impact"),true)}}}function se(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await h(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),s=[];s.push(`**Callers of \`${o.root?.name??"?"}\`** (${o.callers.length}${o.truncated?"+":""})
|
|
19
|
-
`);for(let i of o.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return o.callers.length===0&&s.push("(no incoming edges)"),s.push("\n---\n> Use `node <name>` to read full source of any caller."),a(s.join(`
|
|
20
|
-
`))}catch(t){return a(p(t,"callers"),true)}}}function re(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await i(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),s=[];s.push(`**Callees of \`${o.root?.name??"?"}\`** (${o.callers.length}${o.truncated?"+":""})
|
|
21
|
-
`);for(let i of o.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return o.callers.length===0&&s.push("(no outgoing edges)"),s.push("\n---\n> Use `node <name>` to read full source of any callee."),a(s.join(`
|
|
22
|
-
`))}catch(t){return a(p(t,"callees"),true)}}}function ie(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await j(t,{query:e.query,file:e.file,kind:e.kind,maxFiles:e.maxFiles??5,maxSymbols:e.maxSymbols??3,depth:e.depth??1,includeContent:e.includeContent??!0,intent:e.intent}),s=await D$1(o,{pendingFiles:[],toolName:"explore",writeToDisk:!1});return a(s)}catch(t){return a(p(t,"explore"),true)}}}function ae(n){return async(r,c)=>{try{let e=m(n),t=await k(e,{}),o=t.workspaceDir,s=t.meta.indexed_with_version??"unknown",i=t.meta.lastSync??"never",u=`**Codebase Status**
|
|
23
|
-
|
|
24
|
-
- DB path: \`${t.dbPath}\`
|
|
25
|
-
- Workspace: \`${o}\`
|
|
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 a(u)}catch(e){return a(p(e,"status"),true)}}}function de(n){return async(r,c)=>{try{let e=m(n),t=await l(e,{}),o=await k(e,{}),s=`**Codebase Health Check**
|
|
36
|
-
|
|
37
|
-
- Healthy: ${t.healthy?"\u2713 yes":"\u2717 no"}
|
|
38
|
-
- Nodes: ${o.nodeCount}
|
|
39
|
-
- Edges: ${o.edgeCount}
|
|
40
|
-
- Indexed files: ${o.indexedFiles}
|
|
41
|
-
- DB path: \`${o.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 a(s)}catch(e){return a(p(e,"doctor"),true)}}}function ce(n,r){let c=[{name:"query",schema:Q,factory:ee},{name:"node",schema:X,factory:te},{name:"context",schema:V,factory:ne},{name:"impact",schema:z,factory:oe},{name:"callers",schema:P,factory:se},{name:"callees",schema:K,factory:re},{name:"explore",schema:J,factory:ie},{name:"status",schema:D,factory:ae},{name:"doctor",schema:D,factory:de}];for(let e of c)n.register({name:e.name,description:Z[e.name]??"",inputSchema:e.schema,annotations:G,handler:e.factory(r)});}async function ye(n){throw new Error("startMcpStdioServer \u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u6539\u7528 CodebaseStdioServer.start(codebase, config)\u3002")}function he(n){throw new Error("buildCodebaseMcpTools \u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u6539\u7528 CodebaseStdioServer.start(codebase, config)\u3002")}export{U as CodebaseStdioServer,he as buildCodebaseMcpTools,ye as startMcpStdioServer};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkRPRDGNXG_cjs=require('./chunk-RPRDGNXG.cjs');require('./chunk-4KHRTABC.cjs'),require('./chunk-RLZHDTHY.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-TS4OAYIJ.cjs');var mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var f=utils.Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"];exports.CodebaseStdioServer=void 0;(o=>{let n;function r(){return n||(f.debug("initializing CodebaseStdioServer state factory (lazy)"),n=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),n}async function c(s,i){let u=r()(),l=new mcp.ToolRegistry;ce(l,s);let g=u.toolNames;f.info("starting codebase MCP stdio server",{id:i.id,name:i.name,toolCount:g.length});let y=await mcp.createAndStartStdioServer(i,l),b=null,q=new Promise(d=>{b=d;}),S=d=>{f.info("received signal, stopping MCP server",{signal:d}),b?.();},x=()=>S("SIGINT"),T=()=>S("SIGTERM");process.on("SIGINT",x),process.on("SIGTERM",T);try{await q;}finally{try{process.off("SIGINT",x),process.off("SIGTERM",T);}catch(d){f.warn("failed to remove signal handlers",{error:d instanceof Error?d.message:String(d)});}try{await y.stop();}catch(d){f.warn("server.stop failed during cleanup",{error:d instanceof Error?d.message:String(d)});}try{await s.close();}catch(d){f.warn("codebase.close failed during cleanup",{error:d instanceof Error?d.message:String(d)});}}return {id:i.id,name:i.name,version:i.version,tools:g}}o.start=c;function e(){return r()().toolNames}o.getToolNames=e;function t(){n=void 0;}o.__resetForTests=t;})(exports.CodebaseStdioServer||(exports.CodebaseStdioServer={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",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",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},edgesLimit:{type:"number",description:"Max edges to return (default 50).",default:50}},required:[]},V={type:"object",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"}},required:[]},z={type:"object",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:50,minimum:1,maximum:200}},required:[]},P={type:"object",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:20,minimum:1,maximum:200}},required:[]},K=P,J={type:"object",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},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"]},D={type:"object",properties:{}},Z={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 20). 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 20). 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 a(n,r=false){return {content:[{type:"text",text:n}],...r&&{isError:true}}}function m(n){return {workspaceDir:n.getWorkspaceDir?.()??process.cwd(),rootDir:n.getWorkspaceDir?.()??process.cwd()}}function p(n,r){if(n instanceof chunkRPRDGNXG_cjs.b)return `**${r}** \u2014 node not found. Try \`query\` first to discover the symbol.`;if(n instanceof chunkRPRDGNXG_cjs.c){let c=n.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 n instanceof chunkRPRDGNXG_cjs.a?`**${r}** \u2014 ${n.message}`:n instanceof Error?`**${r}** \u2014 internal error: ${n.message}`:`**${r}** \u2014 internal error: ${String(n)}`}function ee(n){return async(r,c)=>{let e=r;try{let t=m(n),s=(await chunkRPRDGNXG_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})).hits.map(u=>u.node),i=await chunkRPRDGNXG_cjs.z(s,{pendingFiles:[],toolName:"query",writeToDisk:!1});return a(i)}catch(t){return a(p(t,"query"),true)}}}function te(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_cjs.e(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,includeEdges:e.includeEdges??!0,includeContent:e.includeContent??!0,edgesLimit:e.edgesLimit??50}),s=await chunkRPRDGNXG_cjs.C(o.node,o.edges,{pendingFiles:[],toolName:"node",writeToDisk:!1});return a(s)}catch(t){return a(p(t,"node"),true)}}}function ne(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_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"});if(!o.root)return a("**context** \u2014 node not found.");let s=[],i=[];for(let l of o.edges)l.target===o.root.id?s.push(l):i.push(l);let u=await chunkRPRDGNXG_cjs.B(o.root,s,i,o.nodes.map(l=>l.node),{pendingFiles:[],toolName:"context",writeToDisk:!1});return a(u)}catch(t){return a(p(t,"context"),true)}}}function oe(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_cjs.g(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxResults:e.maxResults??50});if(!o.root)return a("**impact** \u2014 node not found.");let s=[],i=n.getDatabase();for(let l of o.buckets)for(let g of l.sample){let y=i.getNodeById(g.id);y&&s.push({source:y,relation:g.relation});}let u=await chunkRPRDGNXG_cjs.A(o.root,s,{pendingFiles:[],toolName:"impact",writeToDisk:!1});return a(u)}catch(t){return a(p(t,"impact"),true)}}}function se(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_cjs.h(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),s=[];s.push(`**Callers of \`${o.root?.name??"?"}\`** (${o.callers.length}${o.truncated?"+":""})
|
|
19
|
-
`);for(let i of o.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return o.callers.length===0&&s.push("(no incoming edges)"),s.push("\n---\n> Use `node <name>` to read full source of any caller."),a(s.join(`
|
|
20
|
-
`))}catch(t){return a(p(t,"callers"),true)}}}function re(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_cjs.i(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),s=[];s.push(`**Callees of \`${o.root?.name??"?"}\`** (${o.callers.length}${o.truncated?"+":""})
|
|
21
|
-
`);for(let i of o.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return o.callers.length===0&&s.push("(no outgoing edges)"),s.push("\n---\n> Use `node <name>` to read full source of any callee."),a(s.join(`
|
|
22
|
-
`))}catch(t){return a(p(t,"callees"),true)}}}function ie(n){return async(r,c)=>{let e=r;try{let t=m(n),o=await chunkRPRDGNXG_cjs.j(t,{query:e.query,file:e.file,kind:e.kind,maxFiles:e.maxFiles??5,maxSymbols:e.maxSymbols??3,depth:e.depth??1,includeContent:e.includeContent??!0,intent:e.intent}),s=await chunkRPRDGNXG_cjs.D(o,{pendingFiles:[],toolName:"explore",writeToDisk:!1});return a(s)}catch(t){return a(p(t,"explore"),true)}}}function ae(n){return async(r,c)=>{try{let e=m(n),t=await chunkRPRDGNXG_cjs.k(e,{}),o=t.workspaceDir,s=t.meta.indexed_with_version??"unknown",i=t.meta.lastSync??"never",u=`**Codebase Status**
|
|
23
|
-
|
|
24
|
-
- DB path: \`${t.dbPath}\`
|
|
25
|
-
- Workspace: \`${o}\`
|
|
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 a(u)}catch(e){return a(p(e,"status"),true)}}}function de(n){return async(r,c)=>{try{let e=m(n),t=await chunkRPRDGNXG_cjs.l(e,{}),o=await chunkRPRDGNXG_cjs.k(e,{}),s=`**Codebase Health Check**
|
|
36
|
-
|
|
37
|
-
- Healthy: ${t.healthy?"\u2713 yes":"\u2717 no"}
|
|
38
|
-
- Nodes: ${o.nodeCount}
|
|
39
|
-
- Edges: ${o.edgeCount}
|
|
40
|
-
- Indexed files: ${o.indexedFiles}
|
|
41
|
-
- DB path: \`${o.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 a(s)}catch(e){return a(p(e,"doctor"),true)}}}function ce(n,r){let c=[{name:"query",schema:Q,factory:ee},{name:"node",schema:X,factory:te},{name:"context",schema:V,factory:ne},{name:"impact",schema:z,factory:oe},{name:"callers",schema:P,factory:se},{name:"callees",schema:K,factory:re},{name:"explore",schema:J,factory:ie},{name:"status",schema:D,factory:ae},{name:"doctor",schema:D,factory:de}];for(let e of c)n.register({name:e.name,description:Z[e.name]??"",inputSchema:e.schema,annotations:G,handler:e.factory(r)});}async function ge(n){throw new Error("startMcpStdioServer \u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u6539\u7528 CodebaseStdioServer.start(codebase, config)\u3002")}function ye(n){throw new Error("buildCodebaseMcpTools \u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u6539\u7528 CodebaseStdioServer.start(codebase, config)\u3002")}exports.buildCodebaseMcpTools=ye;exports.startMcpStdioServer=ge;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{c as formatSyncText,a as parseSyncOptions,b as runSync}from'./chunk-P566CDI2.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk7PW7HWOC_cjs=require('./chunk-7PW7HWOC.cjs');require('./chunk-JVX6PHPN.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"formatSyncText",{enumerable:true,get:function(){return chunk7PW7HWOC_cjs.c}});Object.defineProperty(exports,"parseSyncOptions",{enumerable:true,get:function(){return chunk7PW7HWOC_cjs.a}});Object.defineProperty(exports,"runSync",{enumerable:true,get:function(){return chunk7PW7HWOC_cjs.b}});
|
|
File without changes
|
|
File without changes
|