@easbot/codebase 0.3.23 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chunk-4HJ7RFP7.cjs +1 -0
- package/dist/chunks/{chunk-UAWXUGY5.cjs → chunk-5E5YY2J3.cjs} +22 -22
- package/dist/chunks/{chunk-XXH7ZLAJ.mjs → chunk-AIUVBWJX.mjs} +22 -22
- package/dist/chunks/{chunk-GWR5LCUV.mjs → chunk-EWVG3S6R.mjs} +22 -22
- package/dist/chunks/chunk-NF6CVHEK.cjs +203 -0
- package/dist/chunks/{chunk-3NTIN3AN.cjs → chunk-PLI6SXTS.cjs} +22 -22
- package/dist/chunks/chunk-SQJ64NFE.mjs +58 -0
- package/dist/chunks/chunk-STDI2Q67.mjs +203 -0
- package/dist/chunks/chunk-WC5CUSXD.cjs +58 -0
- package/dist/chunks/chunk-ZPEE2LSX.mjs +1 -0
- package/dist/chunks/cli-handler-SF3CJR3N.mjs +1 -0
- package/dist/chunks/cli-handler-WMBILZ4H.cjs +1 -0
- package/dist/chunks/code-base-DJZICYWH.cjs +1 -0
- package/dist/chunks/{code-base-HAX5SGRL.mjs → code-base-Y6HLPDF3.mjs} +1 -1
- package/dist/chunks/database-manager-MOJW62MZ.cjs +1 -0
- package/dist/chunks/database-manager-X7H4U45I.mjs +1 -0
- package/dist/chunks/file-watcher-QS442D52.cjs +1 -0
- package/dist/chunks/file-watcher-X56TEWNY.mjs +1 -0
- package/dist/chunks/stdio-server-OHQSGNMK.cjs +47 -0
- package/dist/chunks/stdio-server-OJGV4CSS.mjs +47 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -8
- package/dist/chunks/chunk-A4EAKE3M.mjs +0 -49
- package/dist/chunks/chunk-DHH2XXGJ.mjs +0 -203
- package/dist/chunks/chunk-HRFLFP6O.cjs +0 -1
- package/dist/chunks/chunk-KU6UZET2.cjs +0 -49
- package/dist/chunks/chunk-QQXDOGRV.mjs +0 -1
- package/dist/chunks/chunk-YY3Z7NGV.cjs +0 -203
- package/dist/chunks/cli-handler-7XFZK7GK.cjs +0 -1
- package/dist/chunks/cli-handler-H6VHMEHB.mjs +0 -1
- package/dist/chunks/code-base-E5TX7O7M.cjs +0 -1
- package/dist/chunks/database-manager-WTV3TBJS.cjs +0 -1
- package/dist/chunks/database-manager-YGQQHLYR.mjs +0 -1
- package/dist/chunks/file-watcher-HVST5PAC.cjs +0 -1
- package/dist/chunks/file-watcher-LCQ55MPE.mjs +0 -1
- package/dist/chunks/stdio-server-2QHQ7ESX.cjs +0 -47
- package/dist/chunks/stdio-server-5YSJE5E5.mjs +0 -47
|
@@ -0,0 +1,47 @@
|
|
|
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)});}
|
|
@@ -0,0 +1,47 @@
|
|
|
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};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var chunkM2YU5LAI_cjs=require('./chunks/chunk-M2YU5LAI.cjs'),fs=require('fs'),path=require('path'),url=require('url');var G=path.dirname(url.fileURLToPath(chunkM2YU5LAI_cjs.b));function y(){try{let e=path.join(G,"..","package.json");return JSON.parse(fs.readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var d=new Set(["DEBUG","INFO","WARN","ERROR"]);function E(e){let n={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<e.length;s++){let t=e[s];if(t)if(t==="--cwd"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.cwd=o,s++);}else if(t.startsWith("--cwd="))n.cwd=t.slice(6);else if(t==="--config"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.configPath=o,s++);}else if(t.startsWith("--config="))n.configPath=t.slice(9);else if(t==="--log-level"&&s+1<e.length){let o=e[s+1];if(o&&!o.startsWith("-")){let a=o.toUpperCase();d.has(a)&&(n.logLevel=a,s++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();d.has(o)&&(n.logLevel=o);}else t==="--print-logs"?n.printLogs=true:t==="--debug"&&(n.debug=true);}return n}async function A(){let e=process.argv.slice(2),n=y(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=E(e),{Log:o}=await import('@easbot/utils'),{getXdgData:a}=await import('./chunks/interfaces-YX56SVRQ.cjs'),h=path.join(a(),"log");if(await o.init({logDir:h,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-
|
|
2
|
+
'use strict';var chunkM2YU5LAI_cjs=require('./chunks/chunk-M2YU5LAI.cjs'),fs=require('fs'),path=require('path'),url=require('url');var G=path.dirname(url.fileURLToPath(chunkM2YU5LAI_cjs.b));function y(){try{let e=path.join(G,"..","package.json");return JSON.parse(fs.readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var d=new Set(["DEBUG","INFO","WARN","ERROR"]);function E(e){let n={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<e.length;s++){let t=e[s];if(t)if(t==="--cwd"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.cwd=o,s++);}else if(t.startsWith("--cwd="))n.cwd=t.slice(6);else if(t==="--config"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.configPath=o,s++);}else if(t.startsWith("--config="))n.configPath=t.slice(9);else if(t==="--log-level"&&s+1<e.length){let o=e[s+1];if(o&&!o.startsWith("-")){let a=o.toUpperCase();d.has(a)&&(n.logLevel=a,s++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();d.has(o)&&(n.logLevel=o);}else t==="--print-logs"?n.printLogs=true:t==="--debug"&&(n.debug=true);}return n}async function A(){let e=process.argv.slice(2),n=y(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=E(e),{Log:o}=await import('@easbot/utils'),{getXdgData:a}=await import('./chunks/interfaces-YX56SVRQ.cjs'),h=path.join(a(),"log");if(await o.init({logDir:h,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-WMBILZ4H.cjs');l();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-WMBILZ4H.cjs');l();return}if(e[0]==="--version"||e[0]==="-v"){console.log(n);return}let r=t.cwd??process.cwd(),{handleCodebaseCli:m}=await import('./chunks/cli-handler-WMBILZ4H.cjs'),{setInstanceAdapter:w}=await import('./chunks/interfaces-YX56SVRQ.cjs');w({directory:r,worktree:r});let{Llm:b}=await import('./chunks/llm-BDMNIGOH.cjs'),{bootstrapLlm:u,setAdapterRegistry:L}=await import('@easbot/llm'),{getGlobal:i,getInstance:c}=await import('./chunks/interfaces-YX56SVRQ.cjs');L({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:i().Path.home,data:i().Path.data,cache:i().Path.cache,config:i().Path.config,state:i().Path.state,log:i().Path.log,bin:i().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-codebase/${n}`}}),await u({target:b,cwd:r,subConfigPath:".easbot/codebase.json",embedding:true});let g=await m(e,{version:n,cwd:r});g.code!==0&&(process.exitCode=g.code);}A().catch(e=>{console.error(e),process.exitCode=1;}).finally(async()=>{try{let{Log:e}=await import('@easbot/utils');await e.close();}catch{}process.exit(process.exitCode??0);});
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import'./chunks/chunk-2YMB6W5S.mjs';import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';var P=dirname(fileURLToPath(import.meta.url));function G(){try{let e=join(P,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function y(e){let n={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<e.length;s++){let t=e[s];if(t)if(t==="--cwd"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.cwd=o,s++);}else if(t.startsWith("--cwd="))n.cwd=t.slice(6);else if(t==="--config"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.configPath=o,s++);}else if(t.startsWith("--config="))n.configPath=t.slice(9);else if(t==="--log-level"&&s+1<e.length){let o=e[s+1];if(o&&!o.startsWith("-")){let a=o.toUpperCase();p.has(a)&&(n.logLevel=a,s++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();p.has(o)&&(n.logLevel=o);}else t==="--print-logs"?n.printLogs=true:t==="--debug"&&(n.debug=true);}return n}async function E(){let e=process.argv.slice(2),n=G(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=y(e),{Log:o}=await import('@easbot/utils'),{getXdgData:a}=await import('./chunks/interfaces-DPFLQBQ6.mjs'),f=join(a(),"log");if(await o.init({logDir:f,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-
|
|
2
|
+
import'./chunks/chunk-2YMB6W5S.mjs';import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';var P=dirname(fileURLToPath(import.meta.url));function G(){try{let e=join(P,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function y(e){let n={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<e.length;s++){let t=e[s];if(t)if(t==="--cwd"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.cwd=o,s++);}else if(t.startsWith("--cwd="))n.cwd=t.slice(6);else if(t==="--config"&&s+1<e.length){let o=e[s+1];o&&!o.startsWith("-")&&(n.configPath=o,s++);}else if(t.startsWith("--config="))n.configPath=t.slice(9);else if(t==="--log-level"&&s+1<e.length){let o=e[s+1];if(o&&!o.startsWith("-")){let a=o.toUpperCase();p.has(a)&&(n.logLevel=a,s++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();p.has(o)&&(n.logLevel=o);}else t==="--print-logs"?n.printLogs=true:t==="--debug"&&(n.debug=true);}return n}async function E(){let e=process.argv.slice(2),n=G(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=y(e),{Log:o}=await import('@easbot/utils'),{getXdgData:a}=await import('./chunks/interfaces-DPFLQBQ6.mjs'),f=join(a(),"log");if(await o.init({logDir:f,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-SF3CJR3N.mjs');l();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-SF3CJR3N.mjs');l();return}if(e[0]==="--version"||e[0]==="-v"){console.log(n);return}let r=t.cwd??process.cwd(),{handleCodebaseCli:h}=await import('./chunks/cli-handler-SF3CJR3N.mjs'),{setInstanceAdapter:m}=await import('./chunks/interfaces-DPFLQBQ6.mjs');m({directory:r,worktree:r});let{Llm:w}=await import('./chunks/llm-ADBGTSCV.mjs'),{bootstrapLlm:b,setAdapterRegistry:u}=await import('@easbot/llm'),{getGlobal:i,getInstance:c}=await import('./chunks/interfaces-DPFLQBQ6.mjs');u({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:i().Path.home,data:i().Path.data,cache:i().Path.cache,config:i().Path.config,state:i().Path.state,log:i().Path.log,bin:i().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-codebase/${n}`}}),await b({target:w,cwd:r,subConfigPath:".easbot/codebase.json",embedding:true});let g=await h(e,{version:n,cwd:r});g.code!==0&&(process.exitCode=g.code);}E().catch(e=>{console.error(e),process.exitCode=1;}).finally(async()=>{try{let{Log:e}=await import('@easbot/utils');await e.close();}catch{}process.exit(process.exitCode??0);});
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk5E5YY2J3_cjs=require('./chunks/chunk-5E5YY2J3.cjs');require('./chunks/chunk-4HJ7RFP7.cjs');var chunkWC5CUSXD_cjs=require('./chunks/chunk-WC5CUSXD.cjs'),chunkNF6CVHEK_cjs=require('./chunks/chunk-NF6CVHEK.cjs'),chunkJVX6PHPN_cjs=require('./chunks/chunk-JVX6PHPN.cjs'),chunkPLI6SXTS_cjs=require('./chunks/chunk-PLI6SXTS.cjs'),chunkVPWALTY7_cjs=require('./chunks/chunk-VPWALTY7.cjs');require('./chunks/chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"handleCodebaseCli",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.a}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk5E5YY2J3_cjs.b}});Object.defineProperty(exports,"AmbiguousError",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.c}});Object.defineProperty(exports,"NotFoundError",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.b}});Object.defineProperty(exports,"SECTION_END",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.r}});Object.defineProperty(exports,"SECTION_MARKER",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.q}});Object.defineProperty(exports,"ServiceError",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.a}});Object.defineProperty(exports,"callees",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.i}});Object.defineProperty(exports,"callers",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.h}});Object.defineProperty(exports,"context",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.f}});Object.defineProperty(exports,"defaultRiskLabel",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.w}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.l}});Object.defineProperty(exports,"emptyFormattedNode",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.p}});Object.defineProperty(exports,"explore",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.j}});Object.defineProperty(exports,"formatCodebaseEdge",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.n}});Object.defineProperty(exports,"formatCodebaseNode",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.m}});Object.defineProperty(exports,"formatCodebaseSearchHits",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.o}});Object.defineProperty(exports,"impact",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.g}});Object.defineProperty(exports,"node",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.e}});Object.defineProperty(exports,"renderContext",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.x}});Object.defineProperty(exports,"renderContextFromQuery",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.B}});Object.defineProperty(exports,"renderExploreFromResult",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.D}});Object.defineProperty(exports,"renderImpact",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.v}});Object.defineProperty(exports,"renderImpactFromTuples",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.A}});Object.defineProperty(exports,"renderNode",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.y}});Object.defineProperty(exports,"renderNodeDetail",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.C}});Object.defineProperty(exports,"renderSearch",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.z}});Object.defineProperty(exports,"renderSearchResult",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.u}});Object.defineProperty(exports,"search",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.d}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.k}});Object.defineProperty(exports,"truncateAtSectionBoundary",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.s}});Object.defineProperty(exports,"truncateAtSectionBoundarySync",{enumerable:true,get:function(){return chunkWC5CUSXD_cjs.t}});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,"codebaseConfigPath",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.b}});Object.defineProperty(exports,"codebaseDbPath",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.c}});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,"easbotDir",{enumerable:true,get:function(){return chunkNF6CVHEK_cjs.a}});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,"getGlobal",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.c}});Object.defineProperty(exports,"getHomeDir",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.g}});Object.defineProperty(exports,"getInstance",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.f}});Object.defineProperty(exports,"getProjectDirectory",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.l}});Object.defineProperty(exports,"getXdgCache",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.k}});Object.defineProperty(exports,"getXdgConfig",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.i}});Object.defineProperty(exports,"getXdgData",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.h}});Object.defineProperty(exports,"getXdgState",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.j}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.b}});Object.defineProperty(exports,"resetInstanceAdapter",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.e}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.a}});Object.defineProperty(exports,"setInstanceAdapter",{enumerable:true,get:function(){return chunkJVX6PHPN_cjs.d}});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}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkVPWALTY7_cjs.a}});Object.defineProperty(exports,"llm",{enumerable:true,get:function(){return chunkVPWALTY7_cjs.b}});
|
package/dist/index.d.cts
CHANGED
|
@@ -614,6 +614,7 @@ declare class AsyncWriteBackend {
|
|
|
614
614
|
private flushTimer;
|
|
615
615
|
readonly ready: Promise<void>;
|
|
616
616
|
private disposed;
|
|
617
|
+
private lastBatchError;
|
|
617
618
|
constructor(options: AsyncWriteBackendOptions);
|
|
618
619
|
private initRealAsync;
|
|
619
620
|
private installAckHandler;
|
|
@@ -625,6 +626,11 @@ declare class AsyncWriteBackend {
|
|
|
625
626
|
flush(timeoutMs?: number): Promise<void>;
|
|
626
627
|
dispose(): Promise<void>;
|
|
627
628
|
pendingCount(): number;
|
|
629
|
+
getLastBatchError(): {
|
|
630
|
+
error: Error;
|
|
631
|
+
timestamp: number;
|
|
632
|
+
} | null;
|
|
633
|
+
clearLastBatchError(): void;
|
|
628
634
|
}
|
|
629
635
|
|
|
630
636
|
declare class WriteProxy {
|
|
@@ -961,6 +967,7 @@ interface SearchParams {
|
|
|
961
967
|
astType?: string;
|
|
962
968
|
enableFts?: boolean;
|
|
963
969
|
enableEmbedding?: boolean;
|
|
970
|
+
maxEdgesPerNode?: number;
|
|
964
971
|
}
|
|
965
972
|
interface SearchHit {
|
|
966
973
|
nodeId: string;
|
|
@@ -988,7 +995,7 @@ interface NodeParams {
|
|
|
988
995
|
kind?: string;
|
|
989
996
|
includeEdges?: boolean;
|
|
990
997
|
includeContent?: boolean;
|
|
991
|
-
|
|
998
|
+
maxEdgesPerNode?: number;
|
|
992
999
|
}
|
|
993
1000
|
interface NodeResult {
|
|
994
1001
|
node: Node | null;
|
|
@@ -1007,6 +1014,7 @@ interface ContextParams {
|
|
|
1007
1014
|
maxNodes?: number;
|
|
1008
1015
|
direction?: 'incoming' | 'outgoing' | 'both';
|
|
1009
1016
|
relationTypes?: RelationType[];
|
|
1017
|
+
maxEdgesPerNode?: number;
|
|
1010
1018
|
}
|
|
1011
1019
|
interface ContextNode {
|
|
1012
1020
|
node: Node;
|
|
@@ -1028,6 +1036,7 @@ interface ImpactParams {
|
|
|
1028
1036
|
depth?: number;
|
|
1029
1037
|
relationTypes?: RelationType[];
|
|
1030
1038
|
maxResults?: number;
|
|
1039
|
+
maxEdgesPerNode?: number;
|
|
1031
1040
|
}
|
|
1032
1041
|
interface ImpactBucketEntry {
|
|
1033
1042
|
depth: number;
|
|
@@ -1051,6 +1060,7 @@ interface CallersParams {
|
|
|
1051
1060
|
kind?: string;
|
|
1052
1061
|
relationTypes?: RelationType[];
|
|
1053
1062
|
maxResults?: number;
|
|
1063
|
+
maxEdgesPerNode?: number;
|
|
1054
1064
|
}
|
|
1055
1065
|
interface CallerEntry {
|
|
1056
1066
|
id: string;
|
|
@@ -1072,6 +1082,7 @@ interface CalleesParams {
|
|
|
1072
1082
|
kind?: string;
|
|
1073
1083
|
relationTypes?: RelationType[];
|
|
1074
1084
|
maxResults?: number;
|
|
1085
|
+
maxEdgesPerNode?: number;
|
|
1075
1086
|
}
|
|
1076
1087
|
interface CalleeEntry {
|
|
1077
1088
|
id: string;
|
|
@@ -1092,6 +1103,7 @@ interface ExploreParams {
|
|
|
1092
1103
|
kind?: string;
|
|
1093
1104
|
maxFiles?: number;
|
|
1094
1105
|
maxSymbols?: number;
|
|
1106
|
+
maxEdgesPerNode?: number;
|
|
1095
1107
|
depth?: number;
|
|
1096
1108
|
includeContent?: boolean;
|
|
1097
1109
|
intent?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -614,6 +614,7 @@ declare class AsyncWriteBackend {
|
|
|
614
614
|
private flushTimer;
|
|
615
615
|
readonly ready: Promise<void>;
|
|
616
616
|
private disposed;
|
|
617
|
+
private lastBatchError;
|
|
617
618
|
constructor(options: AsyncWriteBackendOptions);
|
|
618
619
|
private initRealAsync;
|
|
619
620
|
private installAckHandler;
|
|
@@ -625,6 +626,11 @@ declare class AsyncWriteBackend {
|
|
|
625
626
|
flush(timeoutMs?: number): Promise<void>;
|
|
626
627
|
dispose(): Promise<void>;
|
|
627
628
|
pendingCount(): number;
|
|
629
|
+
getLastBatchError(): {
|
|
630
|
+
error: Error;
|
|
631
|
+
timestamp: number;
|
|
632
|
+
} | null;
|
|
633
|
+
clearLastBatchError(): void;
|
|
628
634
|
}
|
|
629
635
|
|
|
630
636
|
declare class WriteProxy {
|
|
@@ -961,6 +967,7 @@ interface SearchParams {
|
|
|
961
967
|
astType?: string;
|
|
962
968
|
enableFts?: boolean;
|
|
963
969
|
enableEmbedding?: boolean;
|
|
970
|
+
maxEdgesPerNode?: number;
|
|
964
971
|
}
|
|
965
972
|
interface SearchHit {
|
|
966
973
|
nodeId: string;
|
|
@@ -988,7 +995,7 @@ interface NodeParams {
|
|
|
988
995
|
kind?: string;
|
|
989
996
|
includeEdges?: boolean;
|
|
990
997
|
includeContent?: boolean;
|
|
991
|
-
|
|
998
|
+
maxEdgesPerNode?: number;
|
|
992
999
|
}
|
|
993
1000
|
interface NodeResult {
|
|
994
1001
|
node: Node | null;
|
|
@@ -1007,6 +1014,7 @@ interface ContextParams {
|
|
|
1007
1014
|
maxNodes?: number;
|
|
1008
1015
|
direction?: 'incoming' | 'outgoing' | 'both';
|
|
1009
1016
|
relationTypes?: RelationType[];
|
|
1017
|
+
maxEdgesPerNode?: number;
|
|
1010
1018
|
}
|
|
1011
1019
|
interface ContextNode {
|
|
1012
1020
|
node: Node;
|
|
@@ -1028,6 +1036,7 @@ interface ImpactParams {
|
|
|
1028
1036
|
depth?: number;
|
|
1029
1037
|
relationTypes?: RelationType[];
|
|
1030
1038
|
maxResults?: number;
|
|
1039
|
+
maxEdgesPerNode?: number;
|
|
1031
1040
|
}
|
|
1032
1041
|
interface ImpactBucketEntry {
|
|
1033
1042
|
depth: number;
|
|
@@ -1051,6 +1060,7 @@ interface CallersParams {
|
|
|
1051
1060
|
kind?: string;
|
|
1052
1061
|
relationTypes?: RelationType[];
|
|
1053
1062
|
maxResults?: number;
|
|
1063
|
+
maxEdgesPerNode?: number;
|
|
1054
1064
|
}
|
|
1055
1065
|
interface CallerEntry {
|
|
1056
1066
|
id: string;
|
|
@@ -1072,6 +1082,7 @@ interface CalleesParams {
|
|
|
1072
1082
|
kind?: string;
|
|
1073
1083
|
relationTypes?: RelationType[];
|
|
1074
1084
|
maxResults?: number;
|
|
1085
|
+
maxEdgesPerNode?: number;
|
|
1075
1086
|
}
|
|
1076
1087
|
interface CalleeEntry {
|
|
1077
1088
|
id: string;
|
|
@@ -1092,6 +1103,7 @@ interface ExploreParams {
|
|
|
1092
1103
|
kind?: string;
|
|
1093
1104
|
maxFiles?: number;
|
|
1094
1105
|
maxSymbols?: number;
|
|
1106
|
+
maxEdgesPerNode?: number;
|
|
1095
1107
|
depth?: number;
|
|
1096
1108
|
includeContent?: boolean;
|
|
1097
1109
|
intent?: 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-AIUVBWJX.mjs';import'./chunks/chunk-ZPEE2LSX.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-SQJ64NFE.mjs';export{s as CodeBase,m as EdgeExtractor,g as FILE_EXTENSION_MAP,o as Indexer,k as NodeExtractor,h as ParserManager,q as QueryInterface,b as codebaseConfigPath,c as codebaseDbPath,t as createCodebase,n as createEdgeExtractor,p as createIndexer,l as createNodeExtractor,r as createQueryInterface,a as easbotDir,i as getParserManager,j as resetParserManager}from'./chunks/chunk-STDI2Q67.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{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-EWVG3S6R.mjs';export{a as Llm,b as llm}from'./chunks/chunk-GWCRGM4D.mjs';import'./chunks/chunk-2YMB6W5S.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/codebase",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
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",
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
"web-tree-sitter": "^0.26.8",
|
|
74
74
|
"xdg-basedir": "^5.1.0",
|
|
75
75
|
"zod": "^4.4.3",
|
|
76
|
-
"@easbot/database": "0.3.
|
|
77
|
-
"@easbot/
|
|
78
|
-
"@easbot/
|
|
79
|
-
"@easbot/
|
|
80
|
-
"@easbot/mcp": "0.3.
|
|
81
|
-
"@easbot/types": "0.3.
|
|
82
|
-
"@easbot/utils": "0.3.
|
|
76
|
+
"@easbot/database": "0.3.24",
|
|
77
|
+
"@easbot/llm": "0.3.24",
|
|
78
|
+
"@easbot/terminal": "0.3.24",
|
|
79
|
+
"@easbot/local-model-sdk": "0.3.24",
|
|
80
|
+
"@easbot/mcp": "0.3.24",
|
|
81
|
+
"@easbot/types": "0.3.24",
|
|
82
|
+
"@easbot/utils": "0.3.24"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^25.9.5",
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {c,s}from'./chunk-DHH2XXGJ.mjs';import {a}from'./chunk-2YMB6W5S.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 T=class extends Error{constructor(n,c,a$1){super(n);a(this,"code",c);a(this,"details",a$1);this.name="ServiceError";}},L=class extends T{constructor(t,n=[]){super(`Node not found: ${t}`,"NOT_FOUND",{name:t,candidates:n});}},_=class extends T{constructor(t,n){super(`Ambiguous name "${t}" \u2014 ${n.length} candidates`,"AMBIGUOUS",{name:t,candidates:n});}};var xe=Log.create({service:"codebase-service"}),x=Filesystem.toUnixPath;function Ne(e,t){let n={exact:1,qualified:.85,substring:.5}[e];return t?Math.min(1,n+.2):n}async function k(e,t,n){if(n.nodeId){let l=e.getNode(n.nodeId);if(!l)throw new L(`nodeId=${n.nodeId}`);return {node:l,candidates:[]}}if(!n.name)throw new T("Either name or nodeId is required","NOT_FOUND",n);let a=e.getDatabase().findNodesByName({name:n.name,file:n.file,kind:n.kind,limit:50});if(a.length===0)throw new L(n.name);let s=!!n.file,d=n.file?x(n.file):null,o=a.map(l=>{let u=d?x(l.node.file_path).endsWith(d)||x(l.node.file_path).includes(d):false;return {node:l.node,score:Ne(l.matchKind,u),matchKind:l.matchKind,inFile:u}});if(o.sort((l,u)=>u.score-l.score),o.length===1)return {node:o[0].node,candidates:o.map(l=>({node:l.node,score:l.score}))};let i=o[0].score,r=o.filter(l=>l.score===i);if(r.length===1)return {node:r[0].node,candidates:o.slice(0,10).map(l=>({node:l.node,score:l.score}))};if(s&&r.length>1){let l=r.filter(u=>u.inFile);if(l.length===1)return {node:l[0].node,candidates:o.slice(0,10).map(u=>({node:u.node,score:u.score}))}}throw new _(n.name,o.slice(0,10).map(l=>({node:l.node,score:l.score})))}async function P(e){let t=c(e.rootDir),n=new s({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 Re(e,t,n,c){let s=`
|
|
2
|
-
SELECT id, source, target, relation, created_at FROM edges
|
|
3
|
-
WHERE relation IN (${n.map(()=>"?").join(",")})
|
|
4
|
-
AND source != target
|
|
5
|
-
AND (
|
|
6
|
-
target = ?
|
|
7
|
-
OR target = ?
|
|
8
|
-
)
|
|
9
|
-
LIMIT ?
|
|
10
|
-
`,d=t.name.split("@")[0]??t.name,o=`${t.language}:*:*:${d}`;return e.queryAll(s,[...n,t.id,o,c])}function Pe(e,t,n,c){let s=`
|
|
11
|
-
SELECT id, source, target, relation, created_at FROM edges
|
|
12
|
-
WHERE relation IN (${n.map(()=>"?").join(",")})
|
|
13
|
-
AND source != target
|
|
14
|
-
AND source = ?
|
|
15
|
-
LIMIT ?
|
|
16
|
-
`;return e.queryAll(s,[...n,t.id,c])}function ne(e,t,n,c){let a=c==="in"?e.source:e.target;t.id;let d=n.getNodeById(a);if(!d&&a.includes(":*:")){let o=a.split(":").pop()??a,i=o.split("@")[0]??o;if(i&&i!==a){let r=n.findNodesByName({name:i}),l=t.file_path??"",u=l.split(/[/\\]/).pop()??"",p=r.find(g=>!g.node.file_path||!l?false:g.node.file_path===l||u&&g.node.file_path.split(/[/\\]/).pop()===u)??r[0];p&&(d=p.node);}}if(!d){let o=a.split(":").pop()??a;return {id:a,name:o,astType:"unresolved",filePath:"(unresolved)",startLine:0,relation:e.relation}}return {id:d.id,name:d.name,astType:d.ast_type,filePath:x(d.file_path),startLine:d.start_line??0,relation:e.relation}}async function re(e,t){let n=Date.now(),d=await(await P(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 i=t.kind.toLowerCase();d=d.filter(r=>r.ast_type.includes(i)||r.name.toLowerCase().includes(i));}if(t.file){let i=x(t.file);d=d.filter(r=>x(r.file_path).endsWith(i)||x(r.file_path).includes(i));}let o=d.map(i=>({nodeId:i.id,name:i.name,kind:i.ast_type??"unknown",filePath:x(i.file_path),startLine:i.start_line,endLine:i.end_line,edges:i.edges??[],source:"basic",score:0,snippet:(i.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:o.length,hits:o,durationMs:Date.now()-n,truncated:false}}async function Ce(e,t){let n=await P(e),c=n.getQuery(),a=n.getDatabase(),{node:s}=await k(c,e,t),d=[];if(t.includeEdges){let o=t.edgesLimit??50;d=a.queryEdges({sourceOrTarget:[s.id],limit:o});}return {node:s,edges:d}}var Te=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function Se(e,t){let n=await P(e),c=n.getQuery(),a=n.getDatabase(),{node:s}=await k(c,e,t);if(!s)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let d=t.depth??2,o=t.maxNodes??100,i=t.direction??"both",r=new Map,l=[{nodeId:s.id,depth:0}];r.set(s.id,0);let u=[],p=false;for(;l.length>0;){let f=l.shift();if(f.depth>=d)continue;if(r.size>=o){p=true;break}let b=c.queryNeighbors(f.nodeId,{direction:i,relationTypes:t.relationTypes??Te,limit:o-r.size+1});for(let h of b.edges){u.push(h);let $=h.source===f.nodeId?h.target:h.source;if(!r.has($)&&(r.set($,f.depth+1),l.push({nodeId:$,depth:f.depth+1}),r.size>=o)){p=true;break}}if(p)break}let g=Array.from(r.keys()),N=g.length>0?a.queryNodes({ids:g}):[],m=new Map(N.map(f=>[f.id,f])),R=[];for(let[f,b]of r.entries()){let h=m.get(f);h&&R.push({node:h,depth:b});}return {root:s,nodes:R,edges:u,truncated:p,totalNodes:R.length,totalEdges:u.length}}var Ie=["CALLS","IMPORTS","TYPE_REFERENCES"];async function $e(e,t){let n=await P(e),c=n.getQuery(),a=n.getDatabase(),{node:s}=await k(c,e,t);if(!s)return {root:null,totalImpacted:0,buckets:[]};let d=t.depth??2,o=t.maxResults??50,i=t.relationTypes??Ie,r=new Set([s.id]),l=[],u=[s.id],p=new Map([[s.id,s.name]]);for(let g=1;g<=d&&!(u.length===0||r.size-1>=o);g++){u.map(()=>"?").join(",");let m=i.map(()=>"?").join(","),R=s,f=u.map(E=>{let A=p.get(E)??"",K=A.split("@")[0]??A;return `${R.language}:*:*:${K}`}),b=[...u,...f],h=b.map(()=>"?").join(","),$=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${h}) AND relation IN (${m})`,[...b,...i]),w=[],Z=new Set;for(let E of $)if(!r.has(E.source)&&!Z.has(E.source)&&(Z.add(E.source),r.add(E.source),w.push(E.source),r.size-1>=o))break;if(w.length>0){let E=w.slice(0,10),A=a.queryNodes({ids:E}),K=new Map(A.map(y=>[y.id,y]));for(let y of A)y?.name&&!p.has(y.id)&&p.set(y.id,y.name);let j=new Map;for(let y of $)j.has(y.source)||j.set(y.source,y.relation);let ge=E.map(y=>{let W=K.get(y);return {id:y,name:W?.name??"(unknown)",filePath:W?x(W.file_path):"(unknown)",relation:j.get(y)??"CALLS"}});l.push({depth:g,count:w.length,sample:ge});}u=w;}return l.length===0&&xe.warn("impact: no incoming edges found",{root:s.name,depth:d,relationTypes:i}),{root:s,totalImpacted:r.size-1,buckets:l}}var oe=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function Le(e,t){return se(e,t)}async function Fe(e,t){return ae(e,t)}async function se(e,t){let n=await P(e),c=n.getQuery(),a=n.getDatabase(),{node:s}=await k(c,e,t);if(!s)return {root:null,callers:[],truncated:false};let d=t.maxResults??20,o=t.relationTypes??oe,i=Re(a,s,o,d+1),r=[];for(let u of i){let p=ne(u,s,a,"in");p&&r.push(p);}let l=r.length>d;return {root:s,callers:l?r.slice(0,d):r,truncated:l}}async function ae(e,t){let n=await P(e),c=n.getQuery(),a=n.getDatabase(),{node:s}=await k(c,e,t);if(!s)return {root:null,callees:[],truncated:false};let d=t.maxResults??20,o=t.relationTypes??oe,i=Pe(a,s,o,d+1),r=[];for(let u of i){let p=ne(u,s,a,"out");p&&r.push(p);}let l=r.length>d;return {root:s,callees:l?r.slice(0,d):r,truncated:l}}async function we(e,t){if(!t.query)throw new T("explore requires a non-empty query","NOT_FOUND",{query:t.query});let c=await P(e);c.getQuery();let s=c.getDatabase(),o=(await re(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true})).hits,i=new Map;for(let u of o){let p=x(u.filePath),g=i.get(p);g?g.push(u):i.set(p,[u]);}let r=t.maxSymbols??3,l=[];for(let[u,p]of i){let g=p.slice(0,r),N=[];for(let m of g){let R=await se(e,{name:m.name,file:u,kind:t.kind,maxResults:5}),f=await ae(e,{name:m.name,file:u,kind:t.kind,maxResults:5});N.push({node:(()=>{let b={id:m.nodeId,name:m.name,ast_type:m.kind,language:"ts",file_path:m.filePath,start_line:m.startLine??0,end_line:m.endLine??0};try{let h=s.getNodeById(m.nodeId);return {...b,text:h?.text??""}}catch{return {...b,text:""}}})(),callers:R.callers,callees:f.callees});}l.push({file:u,symbols:N});}return {query:t.query,entryPoints:l,totalHits:o.length}}async function Ae(e,t){return await(await P(e)).getStatus()}async function _e(e,t){return await(await P(e)).healthCheck()}var ie=Filesystem.toUnixPath;function Oe(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 De(e){let t=e.text??"";if(!t)return [];let n=t.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 C(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:ie(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:Oe(e),modifiers:De(e)}}function F(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function z(e){return e.map(t=>({node:{id:t.nodeId,name:t.name,astType:t.kind,language:"typescript",filePath:ie(t.filePath),startLine:t.startLine??0,endLine:t.endLine??0,isExported:false,modifiers:[]},source:t.source,score:t.score,snippet:(t.snippet??"").slice(0,200),edges:(t.edges??[]).slice(0,10).map(n=>F({...n}))}))}function Y(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var qe=Log.create({service:"codebase-format-truncate"}),X="**`",Me="**",ce=24e3,de=25e3;async function q(e,t={}){let n=t.softLimit??ce,c=t.hardCeiling??de,a=t.toolName??"codebase",s=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let d=e.slice(0,c),o=d.lastIndexOf(`
|
|
17
|
-
${X}`),i=d.lastIndexOf(`
|
|
18
|
-
`),r;o>c*.5?r=o:i>0?r=i:r=-1;let l=r>0?d.slice(0,r):d,p=l+"\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(!s)return {content:p,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-l.length}/${e.length} characters truncated ...`};try{let g=await TruncateContent.truncate(e,{maxChars:l.length,direction:"head",label:`${a}-output`});return g.truncated?{content:p,truncated:!0,outputPath:g.outputPath,hint:TruncateContent.formatHint(g),info:`... ${g.removedLength}/${g.originalLength} characters truncated ...`}:{content:p,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-l.length}/${e.length} characters truncated ...`}}catch(g){return qe.warn("TruncateContent.truncate failed, returning without disk hint",{error:g instanceof Error?g.message:String(g)}),{content:p,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-l.length}/${e.length} characters truncated ...`}}}function M(e,t={}){let n=t.softLimit??ce,c=t.hardCeiling??de;if(e.length<=n)return {content:e,truncated:false};let a=e.slice(0,c),s=a.lastIndexOf(`
|
|
19
|
-
${X}`),d=a.lastIndexOf(`
|
|
20
|
-
`),o;s>c*.5?o=s:d>0?o=d:o=-1;let i=o>0?a.slice(0,o):a;return {content:i+`
|
|
21
|
-
|
|
22
|
-
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-i.length}/${e.length} characters truncated ...`}}function He(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 ${He(a.lastEventAt)})`).join(", ")}
|
|
23
|
-
|
|
24
|
-
`}function O(e,t,n={}){return (ue[e]??ue.default).replace(/<(\w+)>/g,(a,s)=>s==="tool"?t:n[s]??`<${s}>`)}var ue={search:`---
|
|
25
|
-
|
|
26
|
-
> **Complete source for N files is included above \u2014 do NOT re-read them.**
|
|
27
|
-
> 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:`---
|
|
28
|
-
|
|
29
|
-
> **Output truncated to budget; the content above is the source of truth.**
|
|
30
|
-
> For more detail, call \`<tool>\` with refined parameters.`};async function B(e,t){let{pendingFiles:n,toolName:c,sync:a=false}=t;if(e.length===0)return D(c,"No matches found.","Try broader search terms, or use `explore` to read source.");let s=Ue(e),d=new Set(s.keys()),o=[];o.push(H(n,d)??"");let i="[[codebase-search-summary]]";o.push(i+`
|
|
31
|
-
`);let r=e.length;o.push(`**Files with matches:** ${s.size}
|
|
32
|
-
`);for(let[g,N]of s){let m=N.map(h=>h.node.name),R=m.slice(0,5).join(", "),f=m.length>5?`, +${m.length-5} more`:"";o.push(`**\`${g}\`** \u2014 ${R}${f}
|
|
33
|
-
`);let b=N[0]?.node.language??"";o.push("```"+b);for(let h of N)o.push(`L${h.node.startLine} ${h.snippet}`);o.push("```\n");}o.push(O("search",c,{}));let l=o.join(`
|
|
34
|
-
`),u=`Found ${r} symbol${r===1?"":"s"} across ${s.size} file${s.size===1?"":"s"}.`,p=l.replace(i,u);return v(p,t,a)}async function U(e,t,n){let{pendingFiles:c,toolName:a,sync:s=false}=n;if(t.length===0||t.every(r=>r.count===0))return D(a,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let d=t.reduce((r,l)=>r+l.count,0),o=Be(d),i=[];i.push(H(c,new Set([e.filePath]))??""),i.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${d})
|
|
35
|
-
`);for(let r of t){i.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let l of r.samples.slice(0,5))i.push(` - \`${l.name}\` ${l.file}:${l.line} [${l.relation}]`);r.samples.length>5&&i.push(` - ... and ${r.samples.length-5} more`);}return i.push(O("impact",a,{root:e.name,riskLevel:o})),v(i.join(`
|
|
36
|
-
`),n,s)}function Be(e){return e>=100?"CRITICAL":e>=50?"HIGH":e>=10?"MEDIUM":"LOW"}function V(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function J(e,t){let{root:n,incoming:c,outgoing:a,neighbors:s}=e,{pendingFiles:d,toolName:o,sync:i=false}=t;if(c.length===0&&a.length===0&&s.length===0)return D(o,`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})
|
|
37
|
-
`),r.push(`**Incoming** (${c.length}):`);for(let l of c.slice(0,10))r.push(`- ${l.source} \u2192 [${l.relation}] \u2192 \`${n.name}\``);c.length>10&&r.push(`- ... and ${c.length-10} more`),r.push(""),r.push(`**Outgoing** (${a.length}):`);for(let l of a.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${l.relation}] \u2192 ${l.target}`);if(a.length>10&&r.push(`- ... and ${a.length-10} more`),r.push(""),s.length>0){r.push(`**Neighbors** (${s.length}):`);for(let l of s.slice(0,20))r.push(`- [d=${l.depth}] \`${l.node.name}\` (${l.node.astType}) ${l.node.filePath}:${l.node.startLine}`);s.length>20&&r.push(`- ... and ${s.length-20} more`),r.push("");}return r.push(O("context",o,{})),v(r.join(`
|
|
38
|
-
`),t,i)}async function G(e,t,n){let{pendingFiles:c,toolName:a,sync:s=false}=n;if(!e.id)return D(a,"Node not found.","Check the node ID or use `search` to find it.");let d=t.filter(r=>r.direction==="in"),o=t.filter(r=>r.direction==="out"),i=[];i.push(H(c,new Set([e.filePath]))??""),i.push(`**Node: \`${e.name}\`**
|
|
39
|
-
`),i.push(`- ID: \`${e.id}\``),i.push(`- Kind: ${e.astType}`),i.push(`- Language: ${e.language}`),i.push(`- Location: ${e.filePath}:${e.startLine}-${e.endLine}`),i.push(`- Exported: ${e.isExported}`),e.modifiers.length>0&&i.push(`- Modifiers: ${e.modifiers.join(", ")}`),i.push(""),i.push(`**Edges** (incoming: ${d.length} / outgoing: ${o.length}):`);for(let r of d.slice(0,5))i.push(`- \u2190 [${r.relation}] ${r.source}`);for(let r of o.slice(0,5))i.push(`- \u2192 [${r.relation}] ${r.target}`);return t.length>10&&i.push(`- ... and ${t.length-10} more`),i.push(O("default",a,{})),v(i.join(`
|
|
40
|
-
`),n,s)}async function pe(e,t){let{entryPoints:n,totalHits:c,query:a}=e,{toolName:s,sync:d=false}=t;if(n.length===0)return D(s,`No matches for \`${a}\`.`,"Try broader search terms, or use `callers` / `callees` to traverse from a known symbol.");let o=[];o.push(`## Code Context
|
|
41
|
-
`),o.push(`**Query:** ${a} `),o.push(`**Total hits:** ${c} `),o.push(`**Entry points:** ${n.length}
|
|
42
|
-
`);for(let i of n){o.push(`**\`${i.file}\`** \u2014 ${i.symbols.length} symbol${i.symbols.length===1?"":"s"}
|
|
43
|
-
`);for(let r of i.symbols){let l=(r.source??"").trim()||"(source not included)",u=r.node.language;if(o.push("```"+u),o.push(`L${r.node.startLine}-L${r.node.endLine} ${r.node.name} (${r.node.astType}${r.node.modifiers.length>0?`, ${r.node.modifiers.join(" ")}`:""})`),o.push(""),o.push(l),o.push("```\n"),r.callers.length>0){o.push(`**Callers of \`${r.node.name}\` (${r.callers.length}):**`);for(let p of r.callers.slice(0,5))o.push(`- [${p.relation}] \`${p.name}\` ${p.filePath}:${p.startLine}`);r.callers.length>5&&o.push(`- ... and ${r.callers.length-5} more`),o.push("");}if(r.callees.length>0){o.push(`**Callees of \`${r.node.name}\` (${r.callees.length}):**`);for(let p of r.callees.slice(0,5))o.push(`- [${p.relation}] \`${p.name}\` ${p.filePath}:${p.startLine}`);r.callees.length>5&&o.push(`- ... and ${r.callees.length-5} more`),o.push("");}}}return o.push(`---
|
|
44
|
-
`),o.push(O("context",s,{})),v(o.join(`
|
|
45
|
-
`),t,d)}function Ue(e){let t=new Map;for(let n of e){let c=n.node.filePath,a=t.get(c);a?a.push(n):t.set(c,[n]);}return t}function D(e,t,n){return `**${e}**
|
|
46
|
-
|
|
47
|
-
${t}
|
|
48
|
-
|
|
49
|
-
> **Tip:** ${n}`}async function v(e,t,n){let c={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?M(e,c):await q(e,c)).content}var Ke=Log.create({service:"codebase-format-render"});async function je(e,t){if(e.length===0)return B([],t);let n=z(e);return B(n,t)}async function We(e,t,n){if(t.length===0)return U(C(e),[],n);let c=[{depth:1,count:t.length,riskLabel:V(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:C(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return U(C(e),c,n)}async function Qe(e,t,n,c,a){let s=C(e),d=t.map(r=>F(r,"in")),o=n.map(r=>F(r,"out")),i=c.map(r=>({node:C(r),depth:1}));return J({root:s,incoming:d,outgoing:o,neighbors:i},a)}async function ze(e,t,n){if(!e)return G(Y(),[],n);let c=C(e),a=t.map(s=>{let d=s.target===e.id?"in":"out";return F(s,d)});return G(c,a,n)}async function Ye(e,t){let n={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(c=>({file:c.file,symbols:c.symbols.map(a=>({node:C(a.node),source:a.node.text??"",callers:a.callers.map(s=>({name:s.name,filePath:s.filePath,startLine:s.startLine,relation:s.relation})),callees:a.callees.map(s=>({name:s.name,filePath:s.filePath,startLine:s.startLine,relation:s.relation}))}))}))};return pe(n,t)}Ke.debug("format/render.ts loaded");export{We as A,Qe as B,ze as C,Ye as D,T as a,L as b,_ as c,re as d,Ce as e,Se as f,$e as g,Le as h,Fe as i,we as j,Ae as k,_e as l,C as m,F as n,z as o,Y as p,X as q,Me as r,q as s,M as t,B as u,U as v,V as w,J as x,G as y,je as z};
|