@easbot/codebase 0.3.14 → 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-F7PTGJKR.cjs → chunk-6CD6Y4F7.cjs} +22 -22
- package/dist/chunks/chunk-6ENRFRCH.cjs +34 -0
- package/dist/chunks/{chunk-LDFLM2CU.cjs → chunk-BEQN3CKO.cjs} +1 -1
- package/dist/chunks/{chunk-Z66TPGV5.mjs → chunk-BUHCT5PM.mjs} +23 -23
- package/dist/chunks/{chunk-TURKZSUP.mjs → chunk-CS4EBN3N.mjs} +1 -1
- package/dist/chunks/{chunk-7DCULBXU.cjs → chunk-K5CRL5DC.cjs} +6 -6
- package/dist/chunks/{chunk-CH3THMQI.mjs → chunk-LFH3RTD3.mjs} +2 -2
- package/dist/chunks/{chunk-3LYXIQYD.mjs → chunk-P6QT72IP.mjs} +1 -1
- package/dist/chunks/{chunk-4A5VTYP7.cjs → chunk-UTPNELRD.cjs} +2 -2
- package/dist/chunks/chunk-W2JWBAHR.mjs +34 -0
- package/dist/chunks/{chunk-ADKQ7Q5L.cjs → chunk-WSFETZ24.cjs} +1 -1
- package/dist/chunks/{chunk-ZL7LUJKP.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-EC3JAMYN.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-IKVZFMWU.mjs → interfaces-5HZADUYB.mjs} +1 -1
- package/dist/chunks/{interfaces-55GBUBWQ.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-AWWGTQOD.cjs +0 -34
- package/dist/chunks/chunk-CUMSGE6Z.mjs +0 -34
- package/dist/chunks/cli-handler-O4FJ3VNT.mjs +0 -1
- package/dist/chunks/cli-handler-VTJIOO3G.cjs +0 -1
- package/dist/chunks/code-base-FF7YI5C7.cjs +0 -1
- package/dist/chunks/database-manager-AR4NY5FD.mjs +0 -1
- package/dist/chunks/database-manager-WBTGLHRS.cjs +0 -1
- package/dist/chunks/file-watcher-DAS74BJ6.cjs +0 -1
- package/dist/chunks/file-watcher-OUSHAYHW.mjs +0 -1
- package/dist/chunks/stdio-server-6FUGUP2N.mjs +0 -47
- package/dist/chunks/stdio-server-P2JPIJI7.cjs +0 -47
- package/dist/chunks/sync-E3JJBUOP.mjs +0 -1
- package/dist/chunks/sync-EB2UCUW3.cjs +0 -1
- /package/dist/chunks/{chunk-NL2AZBPZ.cjs → chunk-NVGACA7W.cjs} +0 -0
- /package/dist/chunks/{chunk-TFZFSTQF.mjs → chunk-TMICZT3L.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-TMICZT3L.mjs';import {Log,Filesystem}from'@easbot/utils';import {createSyncSqliteConnection}from'@easbot/database';var F=class o extends Error{constructor(t,s,r){super(t);a(this,"name","ParserError");a(this,"filePath");a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `ParserError: ${this.message} at ${this.filePath}${t}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},g=class o extends Error{constructor(t,s,r){super(t);a(this,"name","DatabaseError");a(this,"operation");a(this,"cause");this.operation=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `DatabaseError: ${this.message} during ${this.operation}${t}`}toJSON(){return {name:this.name,message:this.message,operation:this.operation,cause:this.cause?.message}}},M=class o extends Error{constructor(t,s,r){super(t);a(this,"name","FileSystemError");a(this,"filePath");a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `FileSystemError: ${this.message} at ${this.filePath}${t}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},u=class o extends Error{constructor(t,s){super(t);a(this,"name","SchemaError");a(this,"missing");this.missing=s,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.missing?` (missing: ${this.missing.join(", ")})`:"";return `SchemaError: ${this.message}${t}`}toJSON(){return {name:this.name,message:this.message,missing:this.missing}}},A=class o extends Error{constructor(t,s){super(t);a(this,"name","ConfigError");a(this,"field");this.field=s,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.field?` (field: ${this.field})`:"";return `ConfigError: ${this.message}${t}`}toJSON(){return {name:this.name,message:this.message,field:this.field}}},v=class o extends Error{constructor(t,s,r){super(t);a(this,"name","IndexError");a(this,"filePath");a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=[this.message];return this.filePath&&t.push(`at ${this.filePath}`),this.cause&&t.push(`(caused by: ${this.cause.message})`),`IndexError: ${t.join(" ")}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},x=class o extends Error{constructor(t,s,r){super(t);a(this,"name","QueryError");a(this,"params");a(this,"cause");this.params=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.params?` (params: ${JSON.stringify(this.params)})`:"",s=this.cause?` (caused by: ${this.cause.message})`:"";return `QueryError: ${this.message}${t}${s}`}toJSON(){return {name:this.name,message:this.message,params:this.params,cause:this.cause?.message}}},w=class o extends Error{constructor(t,s){super(`Unsupported language: ${t}`);a(this,"name","UnsupportedLanguageError");a(this,"extension");a(this,"filePath");this.extension=t,this.filePath=s,Object.setPrototypeOf(this,o.prototype);}toString(){return `UnsupportedLanguageError: ${this.extension} at ${this.filePath}`}toJSON(){return {name:this.name,message:this.message,extension:this.extension,filePath:this.filePath}}};var D=Log.create({service:"codebase-schema-migrations"}),p=1,V=[{id:1,description:"v1 baseline: nodes / edges / file_hashes / nodes_fts / meta / embedding_cache / node_embeddings + unresolved_refs / name_segment_vocab / project_metadata / parse_errors + \u6027\u80FD index (nodes.file_path / edges.source/target)",up:[`CREATE TABLE IF NOT EXISTS nodes (
|
|
2
2
|
id TEXT PRIMARY KEY,
|
|
3
3
|
name TEXT NOT NULL,
|
|
4
4
|
ast_type TEXT NOT NULL,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkNVGACA7W_cjs=require('./chunk-NVGACA7W.cjs'),utils=require('@easbot/utils'),database=require('@easbot/database');var F=class o extends Error{constructor(t,s,r){super(t);chunkNVGACA7W_cjs.a(this,"name","ParserError");chunkNVGACA7W_cjs.a(this,"filePath");chunkNVGACA7W_cjs.a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `ParserError: ${this.message} at ${this.filePath}${t}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},g=class o extends Error{constructor(t,s,r){super(t);chunkNVGACA7W_cjs.a(this,"name","DatabaseError");chunkNVGACA7W_cjs.a(this,"operation");chunkNVGACA7W_cjs.a(this,"cause");this.operation=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `DatabaseError: ${this.message} during ${this.operation}${t}`}toJSON(){return {name:this.name,message:this.message,operation:this.operation,cause:this.cause?.message}}},M=class o extends Error{constructor(t,s,r){super(t);chunkNVGACA7W_cjs.a(this,"name","FileSystemError");chunkNVGACA7W_cjs.a(this,"filePath");chunkNVGACA7W_cjs.a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.cause?` (caused by: ${this.cause.message})`:"";return `FileSystemError: ${this.message} at ${this.filePath}${t}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},u=class o extends Error{constructor(t,s){super(t);chunkNVGACA7W_cjs.a(this,"name","SchemaError");chunkNVGACA7W_cjs.a(this,"missing");this.missing=s,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.missing?` (missing: ${this.missing.join(", ")})`:"";return `SchemaError: ${this.message}${t}`}toJSON(){return {name:this.name,message:this.message,missing:this.missing}}},A=class o extends Error{constructor(t,s){super(t);chunkNVGACA7W_cjs.a(this,"name","ConfigError");chunkNVGACA7W_cjs.a(this,"field");this.field=s,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.field?` (field: ${this.field})`:"";return `ConfigError: ${this.message}${t}`}toJSON(){return {name:this.name,message:this.message,field:this.field}}},v=class o extends Error{constructor(t,s,r){super(t);chunkNVGACA7W_cjs.a(this,"name","IndexError");chunkNVGACA7W_cjs.a(this,"filePath");chunkNVGACA7W_cjs.a(this,"cause");this.filePath=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=[this.message];return this.filePath&&t.push(`at ${this.filePath}`),this.cause&&t.push(`(caused by: ${this.cause.message})`),`IndexError: ${t.join(" ")}`}toJSON(){return {name:this.name,message:this.message,filePath:this.filePath,cause:this.cause?.message}}},x=class o extends Error{constructor(t,s,r){super(t);chunkNVGACA7W_cjs.a(this,"name","QueryError");chunkNVGACA7W_cjs.a(this,"params");chunkNVGACA7W_cjs.a(this,"cause");this.params=s,this.cause=r,Object.setPrototypeOf(this,o.prototype);}toString(){let t=this.params?` (params: ${JSON.stringify(this.params)})`:"",s=this.cause?` (caused by: ${this.cause.message})`:"";return `QueryError: ${this.message}${t}${s}`}toJSON(){return {name:this.name,message:this.message,params:this.params,cause:this.cause?.message}}},w=class o extends Error{constructor(t,s){super(`Unsupported language: ${t}`);chunkNVGACA7W_cjs.a(this,"name","UnsupportedLanguageError");chunkNVGACA7W_cjs.a(this,"extension");chunkNVGACA7W_cjs.a(this,"filePath");this.extension=t,this.filePath=s,Object.setPrototypeOf(this,o.prototype);}toString(){return `UnsupportedLanguageError: ${this.extension} at ${this.filePath}`}toJSON(){return {name:this.name,message:this.message,extension:this.extension,filePath:this.filePath}}};var P=utils.Log.create({service:"codebase-schema-migrations"}),p=1,W=[{id:1,description:"v1 baseline: nodes / edges / file_hashes / nodes_fts / meta / embedding_cache / node_embeddings + unresolved_refs / name_segment_vocab / project_metadata / parse_errors + \u6027\u80FD index (nodes.file_path / edges.source/target)",up:[`CREATE TABLE IF NOT EXISTS nodes (
|
|
2
2
|
id TEXT PRIMARY KEY,
|
|
3
3
|
name TEXT NOT NULL,
|
|
4
4
|
ast_type TEXT NOT NULL,
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
)`,"CREATE INDEX IF NOT EXISTS idx_parse_errors_file_path ON parse_errors(file_path)","CREATE INDEX IF NOT EXISTS idx_nodes_file_path ON nodes(file_path)","CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)"]}];function D(o,e=p,t={}){o.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
68
68
|
id INTEGER PRIMARY KEY,
|
|
69
69
|
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
70
|
-
)`);let s=o.prepare("SELECT id FROM schema_migrations").all(),r=new Set(s.map(a=>a.id)),n={applied:[],pending:[],errors:[],currentVersion:Math.max(0,...s.map(a=>a.id)),targetVersion:e};for(let a of W){if(a.id>e)break;if(r.has(a.id)){n.pending.push(a.id);continue}if(t.dryRun){n.applied.push(a.id);continue}try{o.execBatch([...a.up]),o.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(a.id),r.add(a.id),n.applied.push(a.id),P.info("migration applied",{id:a.id,description:a.description});}catch(i){let c=i instanceof Error?i.message:String(i),T=a.up[0]??"";n.errors.push({migrationId:a.id,sql:T,error:c}),P.warn("migration step failed (may be idempotent)",{id:a.id,error:c,sqlCount:a.up.length});}}return n}function X(o){try{let e=o.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(t=>t.id))}catch{return 0}}var l=utils.Filesystem.toUnixPath,E=utils.Log.create({service:"codebase-database"}),m=2,H=class{constructor(e){
|
|
70
|
+
)`);let s=o.prepare("SELECT id FROM schema_migrations").all(),r=new Set(s.map(a=>a.id)),n={applied:[],pending:[],errors:[],currentVersion:Math.max(0,...s.map(a=>a.id)),targetVersion:e};for(let a of W){if(a.id>e)break;if(r.has(a.id)){n.pending.push(a.id);continue}if(t.dryRun){n.applied.push(a.id);continue}try{o.execBatch([...a.up]),o.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(a.id),r.add(a.id),n.applied.push(a.id),P.info("migration applied",{id:a.id,description:a.description});}catch(i){let c=i instanceof Error?i.message:String(i),T=a.up[0]??"";n.errors.push({migrationId:a.id,sql:T,error:c}),P.warn("migration step failed (may be idempotent)",{id:a.id,error:c,sqlCount:a.up.length});}}return n}function X(o){try{let e=o.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(t=>t.id))}catch{return 0}}var l=utils.Filesystem.toUnixPath,E=utils.Log.create({service:"codebase-database"}),m=2,H=class{constructor(e){chunkNVGACA7W_cjs.a(this,"db");chunkNVGACA7W_cjs.a(this,"dbPath");chunkNVGACA7W_cjs.a(this,"closed",false);chunkNVGACA7W_cjs.a(this,"ftsAvailable",false);this.dbPath=e===":memory:"?e:utils.Filesystem.normalize(e),this.db=database.createSyncSqliteConnection({path:this.dbPath,backend:"better-sqlite3",walMode:true,foreignKeys:true,busyTimeoutMs:5e3}),this.db.initialize();try{this.db.pragma("synchronous = NORMAL"),this.db.pragma("cache_size = -64000"),this.db.pragma("foreign_keys = ON");}catch(t){E.warn("Failed to apply codebase PRAGMAs (synchronous / cache_size / foreign_keys)",{error:String(t)});}try{this.ensureSchema();let t=X(this.db);t>0&&this.setMeta("schema_version",String(t)),this.ftsAvailable=this.checkFtsAvailability(),this.detectAndMarkStaleOnInit();}catch(t){try{this.db.close();}catch{}throw this.closed=true,t}}ensureSchema(){try{D(this.db,p);let e=[["version","1.0.0"],["createdAt",new Date().toISOString()],["index_state","uninitialized"],["indexed_with_version","unknown"]],t=this.db.prepare("INSERT OR IGNORE INTO meta (key, value) VALUES (?, ?)");for(let[s,r]of e)t.run(s,r);}catch(e){throw E.error("ensureSchema failed",{message:e instanceof Error?e.message:String(e),cause:e instanceof Error?e.cause:void 0,stack:e instanceof Error?e.stack:void 0}),new u("Failed to create database schema",e instanceof Error?[e.message]:[String(e)])}}checkFtsAvailability(){try{return this.db.exec("SELECT * FROM nodes_fts WHERE nodes_fts MATCH 'test' LIMIT 1"),!0}catch{return false}}isFtsAvailable(){return this.ftsAvailable}insertNode(e){let t={...e,file_path:l(e.file_path)};this.db.prepare(`
|
|
71
71
|
INSERT OR REPLACE INTO nodes (id, name, ast_type, language, file_path, start_line, start_col, end_line, end_col, text, created_at)
|
|
72
72
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
73
73
|
`).run(t.id,t.name,t.ast_type,t.language,t.file_path,t.start_line,t.start_col,t.end_line,t.end_col,t.text,t.created_at),this.ftsAvailable&&this.updateFtsNode(t);}insertNodes(e){if(e.length===0)return;let t=e.map(n=>({...n,file_path:l(n.file_path)})),s=this.db.prepare(`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {o,l}from'./chunk-LFH3RTD3.mjs';import {c}from'./chunk-UTKA3WG3.mjs';import {a}from'./chunk-TMICZT3L.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 E=Filesystem.toUnixPath;async function _(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=E(n.file),r=a.filter(d=>E(d.file_path).endsWith(o)||E(d.file_path).includes(o));r.length>0&&(a=r);}if(n.kind){let o=n.kind.toLowerCase(),r=a.filter(d=>d.ast_type.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 c=l(n.name,a,{limit:10,minScore:.5});if(c.length===0)throw new P(n.name);if(c.length===1){let o=e.getNode(c[0].nodeId);if(!o)throw new P(n.name);return {node:o,candidates:c.map(r=>({node:o,score:r.score}))}}let s=[];for(let o of c){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 S(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 pe(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:E(i.file_path),startLine:i.start_line??0,relation:e.relation}:null}async function J(e,t){let n=Date.now(),c=await(await S(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();c=c.filter(r=>r.ast_type.includes(o)||r.name.toLowerCase().includes(o));}if(t.file){let o=E(t.file);c=c.filter(r=>E(r.file_path).endsWith(o)||E(r.file_path).includes(o));}let s=c.map(o=>({nodeId:o.id,name:o.name,kind:o.ast_type??"unknown",filePath:E(o.file_path),startLine:o.start_line,endLine:o.end_line,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 me(e,t){let n=await S(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await _(l,e,t),c=[];if(t.includeEdges){let s=t.edgesLimit??50;c=a.queryEdges({sourceOrTarget:[i.id],limit:s});}return {node:i,edges:c}}var ge=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function fe(e,t){let n=await S(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await _(l,e,t);if(!i)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let c=t.depth??2,s=t.maxNodes??100,o=t.direction??"both",r=new Map,d=[{nodeId:i.id,depth:0}];r.set(i.id,0);let p=[],u=false;for(;d.length>0;){let g=d.shift();if(g.depth>=c)continue;if(r.size>=s){u=true;break}let h=l.queryNeighbors(g.nodeId,{direction:o,relationTypes:t.relationTypes??ge,limit:s-r.size+1});for(let y of h.edges){p.push(y);let $=y.source===g.nodeId?y.target:y.source;if(!r.has($)&&(r.set($,g.depth+1),d.push({nodeId:$,depth:g.depth+1}),r.size>=s)){u=true;break}}if(u)break}let m=Array.from(r.keys()),b=m.length>0?a.queryNodes({ids:m}):[],f=new Map(b.map(g=>[g.id,g])),x=[];for(let[g,h]of r.entries()){let y=f.get(g);y&&x.push({node:y,depth:h});}return {root:i,nodes:x,edges:p,truncated:u,totalNodes:x.length,totalEdges:p.length}}var he=["CALLS","IMPORTS","TYPE_REFERENCES"];async function ye(e,t){let n=await S(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await _(l,e,t);if(!i)return {root:null,totalImpacted:0,buckets:[]};let c=t.depth??2,s=t.maxResults??50,o=t.relationTypes??he,r=new Set([i.id]),d=[],p=[i.id];for(let u=1;u<=c&&!(p.length===0||r.size-1>=s);u++){let m=p.map(()=>"?").join(","),b=o.map(()=>"?").join(","),f=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${m}) AND relation IN (${b})`,[...p,...o]),x=[],g=new Set;for(let h of f)if(!r.has(h.source)&&!g.has(h.source)&&(g.add(h.source),r.add(h.source),x.push(h.source),r.size-1>=s))break;if(x.length>0){let h=x.slice(0,10),y=a.queryNodes({ids:h}),$=new Map(y.map(L=>[L.id,L])),se=h.map(L=>{let U=$.get(L);return {id:L,name:U?.name??"(unknown)",filePath:U?E(U.file_path):"(unknown)",relation:"CALLS"}});d.push({depth:u,count:x.length,sample:se});}p=x;}return {root:i,totalImpacted:r.size-1,buckets:d}}var be=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function xe(e,t){return O(e,t,"incoming")}async function Ee(e,t){return O(e,t,"outgoing")}async function O(e,t,n,l){let a=await S(e),i=a.getQuery(),c=a.getDatabase(),{node:s}=await _(i,e,t);if(!s)return {root:null,callers:[],truncated:false};let o=t.maxResults??20,r=t.relationTypes??be,d=i.queryNeighbors(s.id,{direction:n,relationTypes:r,limit:o+1}),p=[];for(let m of d.edges){let b=pe(m,s.id,c,n==="incoming"?"in":"out");b&&p.push(b);}let u=p.length>o;return {root:s,callers:u?p.slice(0,o):p,truncated:u}}async function Ne(e,t){if(!t.query)throw new R("explore requires a non-empty query","NOT_FOUND",{query:t.query});let l=await S(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=E(p.filePath),m=o.get(u);m?m.push(p):o.set(u,[p]);}let r=t.maxSymbols??3,d=[];for(let[p,u]of o){let m=u.slice(0,r),b=[];for(let f of m){let x=await O(e,{name:f.name,file:p,kind:t.kind,maxResults:5},"incoming"),g=await O(e,{name:f.name,file:p,kind:t.kind,maxResults:5},"outgoing");b.push({node:{id:f.nodeId,name:f.name,ast_type:f.kind,language:"ts",file_path:f.filePath,start_line:f.startLine??0,end_line:f.endLine??0,text:""},callers:x.callers,callees:g.callers});}d.push({file:p,symbols:b});}return {query:t.query,entryPoints:d,totalHits:s.length}}async function Re(e,t){return await(await S(e)).getStatus()}async function Pe(e,t){return await(await S(e)).healthCheck()}var Z=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 Ie(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 N(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:Z(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:Ce(e),modifiers:Ie(e)}}function T(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function K(e){return e.map(t=>({node:{id:t.nodeId,name:t.name,astType:t.kind,language:"typescript",filePath:Z(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=>T({...n}))}))}function j(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var $e=Log.create({service:"codebase-format-truncate"}),z="**`",Le="**",te=24e3,ne=25e3;async function D(e,t={}){let n=t.softLimit??te,l=t.hardCeiling??ne,a=t.toolName??"codebase",i=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let c=e.slice(0,l),s=c.lastIndexOf(`
|
|
2
|
+
${z}`),o=c.lastIndexOf(`
|
|
3
|
+
`),r;s>l*.5?r=s:o>0?r=o:r=-1;let d=r>0?c.slice(0,r):c,u=d+"\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-d.length}/${e.length} characters truncated ...`};try{let m=await TruncateContent.truncate(e,{maxChars:d.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-d.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-d.length}/${e.length} characters truncated ...`}}}function v(e,t={}){let n=t.softLimit??te,l=t.hardCeiling??ne;if(e.length<=n)return {content:e,truncated:false};let a=e.slice(0,l),i=a.lastIndexOf(`
|
|
4
|
+
${z}`),c=a.lastIndexOf(`
|
|
5
|
+
`),s;i>l*.5?s=i:c>0?s=c: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 (re[e]??re.default).replace(/<(\w+)>/g,(a,i)=>i==="tool"?t:n[i]??`<${i}>`)}var re={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 k(l,"No matches found.","Try broader search terms, or use `explore` to read source.");let i=ke(e),c=new Set(i.keys()),s=[];s.push(H(n,c)??"");let o="[[codebase-search-summary]]";s.push(o+`
|
|
16
|
+
`);let r=e.length;s.push(`**Files with matches:** ${i.size}
|
|
17
|
+
`);for(let[m,b]of i){let f=b.map(y=>y.node.name),x=f.slice(0,5).join(", "),g=f.length>5?`, +${f.length-5} more`:"";s.push(`**\`${m}\`** \u2014 ${x}${g}
|
|
18
|
+
`);let h=b[0]?.node.language??"";s.push("```"+h);for(let y of b)s.push(`L${y.node.startLine} ${y.snippet}`);s.push("```\n");}s.push(w("search",l,{}));let d=s.join(`
|
|
19
|
+
`),p=`Found ${r} symbol${r===1?"":"s"} across ${i.size} file${i.size===1?"":"s"}.`,u=d.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 k(a,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let c=t.reduce((r,d)=>r+d.count,0),s=we(c),o=[];o.push(H(l,new Set([e.filePath]))??""),o.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${c})
|
|
20
|
+
`);for(let r of t){o.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let d of r.samples.slice(0,5))o.push(` - \`${d.name}\` ${d.file}:${d.line} [${d.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 Q(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function Y(e,t){let{root:n,incoming:l,outgoing:a,neighbors:i}=e,{pendingFiles:c,toolName:s,sync:o=false}=t;if(l.length===0&&a.length===0&&i.length===0)return k(s,`No relations found for \`${n.name}\`.`,"This is a leaf node.");let r=[];r.push(H(c,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 d of l.slice(0,10))r.push(`- ${d.source} \u2192 [${d.relation}] \u2192 \`${n.name}\``);l.length>10&&r.push(`- ... and ${l.length-10} more`),r.push(""),r.push(`**Outgoing** (${a.length}):`);for(let d of a.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${d.relation}] \u2192 ${d.target}`);if(a.length>10&&r.push(`- ... and ${a.length-10} more`),r.push(""),i.length>0){r.push(`**Neighbors** (${i.length}):`);for(let d of i.slice(0,20))r.push(`- [d=${d.depth}] \`${d.node.name}\` (${d.node.astType}) ${d.node.filePath}:${d.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 k(a,"Node not found.","Check the node ID or use `search` to find it.");let c=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: ${c.length} / outgoing: ${s.length}):`);for(let r of c.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 oe(e,t){let{entryPoints:n,totalHits:l,query:a}=e,{toolName:i,sync:c=false}=t;if(n.length===0)return k(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 d=(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(d),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,c)}function ke(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 k(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 D(e,l)).content}var Oe=Log.create({service:"codebase-format-render"});async function _e(e,t){if(e.length===0)return M([],t);let n=K(e);return M(n,t)}async function De(e,t,n){if(t.length===0)return q(N(e),[],n);let l=[{depth:1,count:t.length,riskLabel:Q(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:N(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return q(N(e),l,n)}async function ve(e,t,n,l,a){let i=N(e),c=t.map(r=>T(r,"in")),s=n.map(r=>T(r,"out")),o=l.map(r=>({node:N(r),depth:1}));return Y({root:i,incoming:c,outgoing:s,neighbors:o},a)}async function He(e,t,n){if(!e)return B(j(),[],n);let l=N(e),a=t.map(i=>{let c=i.target===e.id?"in":"out";return T(i,c)});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:N(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 oe(n,t)}Oe.debug("format/render.ts loaded");export{De as A,ve as B,He as C,Me as D,R as a,P as b,F as c,J as d,me as e,fe as f,ye as g,xe as h,Ee as i,Ne as j,Re as k,Pe as l,N as m,T as n,K as o,j as p,z as q,Le as r,D as s,v as t,M as u,q as v,Q as w,Y as x,B as y,_e as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkJVX6PHPN_cjs=require('./chunk-JVX6PHPN.cjs'),chunk7XCIIOM6_cjs=require('./chunk-7XCIIOM6.cjs'),path=require('path');function E(t){let e={},n=[];for(let s of t)s==="--json"?e.json=true:s==="--quiet"||s==="-q"?e.quiet=true:s==="--help"||s==="-h"?e.help=true:s==="--no-embed"?e.noEmbed=true:s==="--embed"?e.noEmbed=false:s.startsWith("-")||n.push(s);return e.dir=n[0],e}async function w(t){let e=t.dir&&path.isAbsolute(t.dir)?t.dir:path.join(chunkJVX6PHPN_cjs.l(),t.dir??"."),n=chunk7XCIIOM6_cjs.c(e),{CodeBase:s}=await import('./code-base-
|
|
1
|
+
'use strict';var chunkJVX6PHPN_cjs=require('./chunk-JVX6PHPN.cjs'),chunk7XCIIOM6_cjs=require('./chunk-7XCIIOM6.cjs'),path=require('path');function E(t){let e={},n=[];for(let s of t)s==="--json"?e.json=true:s==="--quiet"||s==="-q"?e.quiet=true:s==="--help"||s==="-h"?e.help=true:s==="--no-embed"?e.noEmbed=true:s==="--embed"?e.noEmbed=false:s.startsWith("-")||n.push(s);return e.dir=n[0],e}async function w(t){let e=t.dir&&path.isAbsolute(t.dir)?t.dir:path.join(chunkJVX6PHPN_cjs.l(),t.dir??"."),n=chunk7XCIIOM6_cjs.c(e),{CodeBase:s}=await import('./code-base-32T6G2FF.cjs'),{DEFAULT_EMBEDDING_CONFIG:p,DEFAULT_INDEXER_CONFIG:m,DEFAULT_PARSER_CONFIG:h}=await import('@easbot/types'),i=new s({workspaceDir:e,database:{path:n,walMode:true},embedding:t.noEmbed===false?p:void 0,indexer:m,parser:h,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),l,a={_lastPct:-1,_lastProgressAt:0};try{await i.initialize();let r=await i.sync(t.quiet?void 0:o=>{let b=Math.max(o.total,1),d=Math.min(100,Math.floor(o.processed/b*100)),c=Date.now(),g=d!==a._lastPct,y=c-a._lastProgressAt>3e4;if(g||y){let D=String(d).padStart(3," ");console.error(` \u{1F4A1} [${D}%] ${o.stage}: ${o.processed}/${o.total} files`),a._lastPct=d,a._lastProgressAt=c;}}),S=i.getDatabase().getIndexState();l={rootDir:e,success:r.success,filesAdded:r.filesAdded,filesUpdated:r.filesUpdated,filesDeleted:r.filesDeleted,filesSkipped:r.filesSkipped,nodesCreated:r.nodesCreated,edgesCreated:r.edgesCreated,errorCount:r.errors.length,errors:r.errors,durationMs:r.duration,indexState:S};}finally{await i.close();}return l}function M(t){let e=[];if(e.push("Codebase sync"),e.push(` rootDir: ${t.rootDir}`),e.push(` success: ${t.success?"\u2713":"\u2717"}`),e.push(` indexState: ${t.indexState}`),e.push(` files added: ${t.filesAdded}`),e.push(` files updated: ${t.filesUpdated}`),e.push(` files deleted: ${t.filesDeleted}`),e.push(` files skipped: ${t.filesSkipped}`),e.push(` nodes created: ${t.nodesCreated}`),e.push(` edges created: ${t.edgesCreated}`),e.push(` duration: ${t.durationMs}ms`),t.errorCount>0){e.push(` errors (${t.errorCount}):`);for(let n of t.errors.slice(0,10))e.push(` - ${n.filePath}: ${n.error}`);t.errors.length>10&&e.push(` ... and ${t.errors.length-10} more`);}return e.join(`
|
|
2
2
|
`)}exports.a=E;exports.b=w;exports.c=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-TMICZT3L.mjs';import {existsSync,readFileSync,promises}from'fs';import {isAbsolute,normalize,join}from'path';import {createRequire}from'module';import {Log,Ignore,PKG,Shell}from'@easbot/utils';var a=Log.create({service:"codebase-file-watcher"});function O(){return process.env.EASBOT_CACHE_PATH||join(process.cwd(),".easbot","cache")}var _=["node_modules/**",".git/**","dist/**","build/**","__pycache__/**","*.min.js","*.min.ts",".easbot/**",".codebase/**"],g=null,d=null;function S(){let r=process.platform==="linux"?`-${globalThis.EASBOT_LIBC||"glibc"}`:"";return `@parcel/watcher-${process.platform}-${process.arch}${r}`}async function A(){if(g)return g;if(d)throw new Error(d);let r=S(),e=O(),t;try{await R(r,e)?t=join(e,"node_modules",r):(a.info("Parcel watcher binding not found, attempting to install",{binding:r,cachePath:e}),t=await T(r,e));}catch(n){let u=n instanceof Error?n.message:String(n);throw d=`binding "${r}" not found and auto-install failed. Run manually: pnpm install ${r}. Error: ${u}`,a.error("failed to install parcel watcher binding",{error:n,binding:r}),new Error(d)}a.info("Loading Parcel watcher binding",{binding:r,modulePath:t});let{createWrapper:o}=await import('@parcel/watcher/wrapper.js'),i=createRequire(join(t,"package.json"))(r),c=o(i);return g=c,c}async function R(r,e){try{return !!await PKG.resolve(r,void 0,{extraPaths:[e]})}catch{return false}}async function T(r,e){return a.info("Installing Parcel watcher binding",{binding:r,cachePath:e}),await Shell.install(r,"latest",e),join(e,"node_modules",r)}function b(){return process.platform==="darwin"?"fs-events":process.platform==="linux"?"inotify":process.platform==="win32"?"windows":"brute-force"}var w=class{constructor(e){a$1(this,"workspaceDir");a$1(this,"backendOpt");a$1(this,"ignorePatterns");a$1(this,"onLoadFailure");a$1(this,"ignoreInstance");a$1(this,"listeners",new Set);a$1(this,"unsubscribe",null);a$1(this,"disposed",false);a$1(this,"running",false);this.workspaceDir=isAbsolute(e.workspaceDir)?e.workspaceDir:normalize(e.workspaceDir),this.backendOpt=e.backend??"auto",this.ignorePatterns=e.ignorePatterns??[..._],this.onLoadFailure=e.onLoadFailure??"throw",this.ignoreInstance=Ignore.create().add(this.ignorePatterns);}getIgnoreInstance(){return this.ignoreInstance}getIgnorePatterns(){return this.ignorePatterns}getActiveBackend(){return this.backendOpt==="auto"?b():this.backendOpt}on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async start(){if(this.running)return;this.running=true;let e=this.backendOpt==="auto"?b():this.backendOpt;a.info("FileWatcher start",{workspaceDir:this.workspaceDir,backend:e});let t;try{t=await A();}catch(o){if(this.running=false,this.onLoadFailure==="warn")return;throw o}await this.subscribeWithParcel(t,e);}async stop(){if(this.unsubscribe){try{await this.unsubscribe();}catch(e){a.warn("parcel unsubscribe error",{error:e});}this.unsubscribe=null;}this.running=false;}async dispose(){await this.stop(),this.disposed=true,this.listeners.clear();}isRunning(){return this.running}isDisposed(){return this.disposed}async subscribeWithParcel(e,t){if(this.disposed)throw new Error("FileWatcher disposed before subscribe");let o=(i,c)=>{if(this.disposed)return;let n=this.workspaceDir.replace(/\\/g,"/").replace(/\/$/,""),u=c.replace(/\\/g,"/"),p=c;if(u.startsWith(n+"/")&&(p=u.slice(n.length+1)),this.ignoreInstance.ignores(p,i==="create"&&p.endsWith("/")))return;let P=i==="create"?"add":i==="delete"?"unlink":"change";for(let v of this.listeners)try{v(P,p);}catch(k){a.warn("listener threw",{error:k});}},h=await e.subscribe(this.workspaceDir,(i,c)=>{if(i){a.error("parcel subscribe callback error",{error:i});return}for(let n of c)o(n.type,n.path);},{ignore:[...this.ignorePatterns],backend:t});if(this.disposed){await h.unsubscribe().catch(()=>{});return}this.unsubscribe=async()=>{await h.unsubscribe().catch(i=>{a.warn("parcel unsubscribe error",{error:i});});};}};function f(r){return join(r,".watcher.pid")}function N(r){let e=f(r);if(!existsSync(e))return null;try{let t=readFileSync(e,"utf-8").trim(),o=parseInt(t,10);return Number.isFinite(o)?o:null}catch{return null}}async function z(r,e){let t=f(r);await promises.writeFile(t,String(e),"utf-8");}async function K(r){let e=f(r);try{await promises.unlink(e);}catch{}}export{w as a,f as b,N as c,z as d,K as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk6CD6Y4F7_cjs=require('./chunk-6CD6Y4F7.cjs');require('./chunk-BEQN3CKO.cjs'),require('./chunk-WSFETZ24.cjs'),require('./chunk-JVX6PHPN.cjs'),require('./chunk-6ENRFRCH.cjs'),require('./chunk-K5CRL5DC.cjs'),require('./chunk-UTPNELRD.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.c}});Object.defineProperty(exports,"handleCodebaseCli",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.a}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as COMMANDS_HELP,d as handleCodebaseCli,a as renderBanner,b as renderHelp}from'./chunk-BUHCT5PM.mjs';import'./chunk-WXWENWCY.mjs';import'./chunk-CS4EBN3N.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-W2JWBAHR.mjs';import'./chunk-LFH3RTD3.mjs';import'./chunk-P6QT72IP.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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'./chunk-
|
|
1
|
+
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'./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'./chunk-P6QT72IP.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkK5CRL5DC_cjs=require('./chunk-K5CRL5DC.cjs'),chunkUTPNELRD_cjs=require('./chunk-UTPNELRD.cjs');require('./chunk-7XCIIOM6.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"CodeBase",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.o}});Object.defineProperty(exports,"EdgeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.h}});Object.defineProperty(exports,"FILE_EXTENSION_MAP",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.b}});Object.defineProperty(exports,"Indexer",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.j}});Object.defineProperty(exports,"NodeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.f}});Object.defineProperty(exports,"ParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.c}});Object.defineProperty(exports,"QueryInterface",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.m}});Object.defineProperty(exports,"createCodebase",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.p}});Object.defineProperty(exports,"createEdgeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.i}});Object.defineProperty(exports,"createIndexer",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.k}});Object.defineProperty(exports,"createNodeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.g}});Object.defineProperty(exports,"createQueryInterface",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.n}});Object.defineProperty(exports,"getParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.d}});Object.defineProperty(exports,"resetParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.e}});Object.defineProperty(exports,"ConfigError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.e}});Object.defineProperty(exports,"DatabaseError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.b}});Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.n}});Object.defineProperty(exports,"FileSystemError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.c}});Object.defineProperty(exports,"IndexError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.f}});Object.defineProperty(exports,"ParserError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.a}});Object.defineProperty(exports,"QueryError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.g}});Object.defineProperty(exports,"SchemaError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.d}});Object.defineProperty(exports,"UnsupportedLanguageError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.h}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{n as DatabaseManager,m as EXTRACTION_VERSION,p as getDbPath,o as isClosed,q as transaction}from'./chunk-P6QT72IP.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkUTPNELRD_cjs=require('./chunk-UTPNELRD.cjs');require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.n}});Object.defineProperty(exports,"EXTRACTION_VERSION",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.m}});Object.defineProperty(exports,"getDbPath",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.p}});Object.defineProperty(exports,"isClosed",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.o}});Object.defineProperty(exports,"transaction",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.q}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkBEQN3CKO_cjs=require('./chunk-BEQN3CKO.cjs');require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"FileWatcher",{enumerable:true,get:function(){return chunkBEQN3CKO_cjs.a}});Object.defineProperty(exports,"clearWatcherPid",{enumerable:true,get:function(){return chunkBEQN3CKO_cjs.e}});Object.defineProperty(exports,"getWatcherPidPath",{enumerable:true,get:function(){return chunkBEQN3CKO_cjs.b}});Object.defineProperty(exports,"readWatcherPid",{enumerable:true,get:function(){return chunkBEQN3CKO_cjs.c}});Object.defineProperty(exports,"writeWatcherPid",{enumerable:true,get:function(){return chunkBEQN3CKO_cjs.d}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as FileWatcher,e as clearWatcherPid,b as getWatcherPidPath,c as readWatcherPid,d as writeWatcherPid}from'./chunk-WXWENWCY.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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'./chunk-34CU2EU4.mjs';import'./chunk-
|
|
1
|
+
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'./chunk-34CU2EU4.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkJVX6PHPN_cjs=require('./chunk-JVX6PHPN.cjs');require('./chunk-
|
|
1
|
+
'use strict';var chunkJVX6PHPN_cjs=require('./chunk-JVX6PHPN.cjs');require('./chunk-NVGACA7W.cjs');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}});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';var chunk6ENRFRCH_cjs=require('./chunk-6ENRFRCH.cjs');require('./chunk-K5CRL5DC.cjs'),require('./chunk-UTPNELRD.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-NVGACA7W.cjs');var mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var g=utils.Log.create({service:"codebase-mcp-stdio"}),G=["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:[...G],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;le(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,q=new Promise(c=>{x=c;}),S=c=>{g.info("received signal, stopping MCP server",{signal:c}),x?.();},T=()=>S("SIGINT"),E=()=>S("SIGTERM");process.on("SIGINT",T),process.on("SIGTERM",E);try{await q;}finally{try{process.off("SIGINT",T),process.off("SIGTERM",E);}catch(c){g.warn("failed to remove signal handlers",{error:c instanceof Error?c.message:String(c)});}try{await h.stop();}catch(c){g.warn("server.stop failed during cleanup",{error:c instanceof Error?c.message:String(c)});}try{await n.close();}catch(c){g.warn("codebase.close failed during cleanup",{error:c instanceof Error?c.message:String(c)});}}return {id:s.id,name:s.name,version:s.version,tools:y}}t.start=a;function l(){return r()().toolNames}t.getToolNames=l;function e(){o=void 0;}t.__resetForTests=e;})(exports.CodebaseStdioServer||(exports.CodebaseStdioServer={}));var Q={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},X={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:[]},V={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:[]},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:"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:[]},K={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:[]},J=P,Z={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:{}},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 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 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 chunk6ENRFRCH_cjs.b)return `**${r}** \u2014 node not found. Try \`query\` first to discover the symbol.`;if(o instanceof chunk6ENRFRCH_cjs.c){let l=o.details?.candidates??[],e=l.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 ${l.length-5} more candidates.`}return mcp.formatFailClosed(o,a)}function te(o,r){return async(a,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_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}),s=await chunk6ENRFRCH_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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_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 chunk6ENRFRCH_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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_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(!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 chunk6ENRFRCH_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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_cjs.g(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,depth:e.depth??2,maxResults:e.maxResults??50});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 chunk6ENRFRCH_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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_cjs.h(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_cjs.i(t,{name:e.name,nodeId:e.nodeId,file:e.file,kind:e.kind,maxResults:e.maxResults??20}),s=[];s.push(`**Callees of \`${n.root?.name??"?"}\`** (${n.callers.length}${n.truncated?"+":""})
|
|
21
|
+
`);for(let i of n.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callers.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,l)=>{let e=a;try{let t=m(o),n=await chunk6ENRFRCH_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 chunk6ENRFRCH_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,l)=>{try{let e=m(o),t=await chunk6ENRFRCH_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 ce(o,r){return async(a,l)=>{try{let e=m(o),t=await chunk6ENRFRCH_cjs.l(e,{}),n=await chunk6ENRFRCH_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 le(o,r,a){let l=[{name:"query",schema:X,factory:te},{name:"node",schema:V,factory:ne},{name:"context",schema:z,factory:oe},{name:"impact",schema:K,factory:se},{name:"callers",schema:P,factory:re},{name:"callees",schema:J,factory:ae},{name:"explore",schema:Z,factory:ie},{name:"status",schema:D,factory:de},{name:"doctor",schema:D,factory:ce}];for(let e of l)o.register({name:e.name,description:ee[e.name]??"",inputSchema:e.schema,annotations:Q,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 as D$1,k,l,b,c}from'./chunk-W2JWBAHR.mjs';import'./chunk-LFH3RTD3.mjs';import'./chunk-P6QT72IP.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-TMICZT3L.mjs';import {ToolRegistry,createAndStartStdioServer,formatFailClosed}from'@easbot/mcp';import {Log}from'@easbot/utils';var g=Log.create({service:"codebase-mcp-stdio"}),G=["query","node","context","impact","callers","callees","explore","status","doctor"],$;(t=>{let o;function r(){return o||(g.debug("initializing CodebaseStdioServer state factory (lazy)"),o=()=>({toolNames:[...G],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;le(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,q=new Promise(c=>{x=c;}),S=c=>{g.info("received signal, stopping MCP server",{signal:c}),x?.();},T=()=>S("SIGINT"),E=()=>S("SIGTERM");process.on("SIGINT",T),process.on("SIGTERM",E);try{await q;}finally{try{process.off("SIGINT",T),process.off("SIGTERM",E);}catch(c){g.warn("failed to remove signal handlers",{error:c instanceof Error?c.message:String(c)});}try{await h.stop();}catch(c){g.warn("server.stop failed during cleanup",{error:c instanceof Error?c.message:String(c)});}try{await n.close();}catch(c){g.warn("codebase.close failed during cleanup",{error:c instanceof Error?c.message:String(c)});}}return {id:s.id,name:s.name,version:s.version,tools:y}}t.start=a;function l(){return r()().toolNames}t.getToolNames=l;function e(){o=void 0;}t.__resetForTests=e;})($||($={}));var Q={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},X={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:[]},V={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:[]},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:"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:[]},K={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:[]},J=P,Z={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:{}},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 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 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 l=o.details?.candidates??[],e=l.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 ${l.length-5} more candidates.`}return formatFailClosed(o,a)}function te(o,r){return async(a,l)=>{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}),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,l)=>{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,edgesLimit:e$1.edgesLimit??50}),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,l)=>{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"});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,l)=>{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??50});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,l)=>{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??20}),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,l)=>{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??20}),s=[];s.push(`**Callees of \`${n.root?.name??"?"}\`** (${n.callers.length}${n.truncated?"+":""})
|
|
21
|
+
`);for(let i of n.callers)s.push(`- [${i.relation}] \`${i.name}\` ${i.filePath}:${i.startLine}`);return n.callers.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,l)=>{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,depth:e.depth??1,includeContent:e.includeContent??!0,intent:e.intent}),s=await D$1(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,l)=>{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 ce(o,r){return async(a,l$1)=>{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 le(o,r,a){let l=[{name:"query",schema:X,factory:te},{name:"node",schema:V,factory:ne},{name:"context",schema:z,factory:oe},{name:"impact",schema:K,factory:se},{name:"callers",schema:P,factory:re},{name:"callees",schema:J,factory:ae},{name:"explore",schema:Z,factory:ie},{name:"status",schema:D,factory:de},{name:"doctor",schema:D,factory:ce}];for(let e of l)o.register({name:e.name,description:ee[e.name]??"",inputSchema:e.schema,annotations:Q,handler:e.factory(r,a)});}export{$ as CodebaseStdioServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as formatSyncText,a as parseSyncOptions,b as runSync}from'./chunk-CS4EBN3N.mjs';import'./chunk-34CU2EU4.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-TMICZT3L.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkWSFETZ24_cjs=require('./chunk-WSFETZ24.cjs');require('./chunk-JVX6PHPN.cjs'),require('./chunk-7XCIIOM6.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"formatSyncText",{enumerable:true,get:function(){return chunkWSFETZ24_cjs.c}});Object.defineProperty(exports,"parseSyncOptions",{enumerable:true,get:function(){return chunkWSFETZ24_cjs.a}});Object.defineProperty(exports,"runSync",{enumerable:true,get:function(){return chunkWSFETZ24_cjs.b}});
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),fs=require('fs'),path=require('path'),url=require('url');var m=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));function v(){try{let e=path.join(m,"..","package.json");return JSON.parse(fs.readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function O(e){let s={logLevel:"INFO",printLogs:false,debug:false};for(let n=0;n<e.length;n++){let t=e[n];if(t)if(t==="--cwd"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.cwd=o,n++);}else if(t.startsWith("--cwd="))s.cwd=t.slice(6);else if(t==="--config"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.configPath=o,n++);}else if(t.startsWith("--config="))s.configPath=t.slice(9);else if(t==="--log-level"&&n+1<e.length){let o=e[n+1];if(o&&!o.startsWith("-")){let i=o.toUpperCase();p.has(i)&&(s.logLevel=i,n++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();p.has(o)&&(s.logLevel=o);}else t==="--print-logs"?s.printLogs=true:t==="--debug"&&(s.debug=true);}return s}async function b(){let e=process.argv.slice(2),s=v(),{loadEnv:n}=await import('@easbot/utils');n(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=O(e),{Log:o}=await import('@easbot/utils'),{getXdgData:i}=await import('./chunks/interfaces-ORRCH4XV.cjs'),f=path.join(i(),"log");if(await o.init({logDir:f,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:r}=await import('./chunks/cli-handler-IDMIMEKA.cjs');r();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:r}=await import('./chunks/cli-handler-IDMIMEKA.cjs');r();return}if(e[0]==="--version"||e[0]==="-v"){console.log(s);return}let l=t.cwd??process.cwd(),{handleCodebaseCli:d}=await import('./chunks/cli-handler-IDMIMEKA.cjs'),{setInstanceAdapter:h}=await import('./chunks/interfaces-ORRCH4XV.cjs');h({directory:l,worktree:l});let c=await d(e,{version:s,cwd:l});c.code!==0&&(process.exitCode=c.code);}b().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-
|
|
2
|
+
import'./chunks/chunk-TMICZT3L.mjs';import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';var m=dirname(fileURLToPath(import.meta.url));function w(){try{let e=join(m,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var a=new Set(["DEBUG","INFO","WARN","ERROR"]);function v(e){let s={logLevel:"INFO",printLogs:false,debug:false};for(let n=0;n<e.length;n++){let t=e[n];if(t)if(t==="--cwd"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.cwd=o,n++);}else if(t.startsWith("--cwd="))s.cwd=t.slice(6);else if(t==="--config"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.configPath=o,n++);}else if(t.startsWith("--config="))s.configPath=t.slice(9);else if(t==="--log-level"&&n+1<e.length){let o=e[n+1];if(o&&!o.startsWith("-")){let i=o.toUpperCase();a.has(i)&&(s.logLevel=i,n++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();a.has(o)&&(s.logLevel=o);}else t==="--print-logs"?s.printLogs=true:t==="--debug"&&(s.debug=true);}return s}async function O(){let e=process.argv.slice(2),s=w(),{loadEnv:n}=await import('@easbot/utils');n(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=v(e),{Log:o}=await import('@easbot/utils'),{getXdgData:i}=await import('./chunks/interfaces-5HZADUYB.mjs'),g=join(i(),"log");if(await o.init({logDir:g,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-ZLJJGHMV.mjs');l();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-ZLJJGHMV.mjs');l();return}if(e[0]==="--version"||e[0]==="-v"){console.log(s);return}let r=t.cwd??process.cwd(),{handleCodebaseCli:f}=await import('./chunks/cli-handler-ZLJJGHMV.mjs'),{setInstanceAdapter:d}=await import('./chunks/interfaces-5HZADUYB.mjs');d({directory:r,worktree:r});let c=await f(e,{version:s,cwd:r});c.code!==0&&(process.exitCode=c.code);}O().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 chunk6CD6Y4F7_cjs=require('./chunks/chunk-6CD6Y4F7.cjs');require('./chunks/chunk-BEQN3CKO.cjs'),require('./chunks/chunk-WSFETZ24.cjs');var chunkJVX6PHPN_cjs=require('./chunks/chunk-JVX6PHPN.cjs'),chunk6ENRFRCH_cjs=require('./chunks/chunk-6ENRFRCH.cjs'),chunkK5CRL5DC_cjs=require('./chunks/chunk-K5CRL5DC.cjs'),chunkUTPNELRD_cjs=require('./chunks/chunk-UTPNELRD.cjs');require('./chunks/chunk-7XCIIOM6.cjs'),require('./chunks/chunk-NVGACA7W.cjs');Object.defineProperty(exports,"handleCodebaseCli",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.a}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk6CD6Y4F7_cjs.b}});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,"AmbiguousError",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.c}});Object.defineProperty(exports,"NotFoundError",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.b}});Object.defineProperty(exports,"SECTION_END",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.r}});Object.defineProperty(exports,"SECTION_MARKER",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.q}});Object.defineProperty(exports,"ServiceError",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.a}});Object.defineProperty(exports,"callees",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.i}});Object.defineProperty(exports,"callers",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.h}});Object.defineProperty(exports,"context",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.f}});Object.defineProperty(exports,"defaultRiskLabel",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.w}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.l}});Object.defineProperty(exports,"emptyFormattedNode",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.p}});Object.defineProperty(exports,"explore",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.j}});Object.defineProperty(exports,"formatCodebaseEdge",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.n}});Object.defineProperty(exports,"formatCodebaseNode",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.m}});Object.defineProperty(exports,"formatCodebaseSearchHits",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.o}});Object.defineProperty(exports,"impact",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.g}});Object.defineProperty(exports,"node",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.e}});Object.defineProperty(exports,"renderContext",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.x}});Object.defineProperty(exports,"renderContextFromQuery",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.B}});Object.defineProperty(exports,"renderExploreFromResult",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.D}});Object.defineProperty(exports,"renderImpact",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.v}});Object.defineProperty(exports,"renderImpactFromTuples",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.A}});Object.defineProperty(exports,"renderNode",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.y}});Object.defineProperty(exports,"renderNodeDetail",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.C}});Object.defineProperty(exports,"renderSearch",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.z}});Object.defineProperty(exports,"renderSearchResult",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.u}});Object.defineProperty(exports,"search",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.d}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.k}});Object.defineProperty(exports,"truncateAtSectionBoundary",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.s}});Object.defineProperty(exports,"truncateAtSectionBoundarySync",{enumerable:true,get:function(){return chunk6ENRFRCH_cjs.t}});Object.defineProperty(exports,"CodeBase",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.o}});Object.defineProperty(exports,"EdgeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.h}});Object.defineProperty(exports,"FILE_EXTENSION_MAP",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.b}});Object.defineProperty(exports,"Indexer",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.j}});Object.defineProperty(exports,"NodeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.f}});Object.defineProperty(exports,"ParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.c}});Object.defineProperty(exports,"QueryInterface",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.m}});Object.defineProperty(exports,"createCodebase",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.p}});Object.defineProperty(exports,"createEdgeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.i}});Object.defineProperty(exports,"createIndexer",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.k}});Object.defineProperty(exports,"createNodeExtractor",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.g}});Object.defineProperty(exports,"createQueryInterface",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.n}});Object.defineProperty(exports,"getParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.d}});Object.defineProperty(exports,"resetParserManager",{enumerable:true,get:function(){return chunkK5CRL5DC_cjs.e}});Object.defineProperty(exports,"ConfigError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.e}});Object.defineProperty(exports,"DatabaseError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.b}});Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.n}});Object.defineProperty(exports,"FileSystemError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.c}});Object.defineProperty(exports,"IndexError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.f}});Object.defineProperty(exports,"ParserError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.a}});Object.defineProperty(exports,"QueryError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.g}});Object.defineProperty(exports,"SchemaError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.d}});Object.defineProperty(exports,"UnsupportedLanguageError",{enumerable:true,get:function(){return chunkUTPNELRD_cjs.h}});
|
package/dist/index.d.cts
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;
|