@easbot/codebase 0.3.29 → 0.3.36
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 +55 -1
- package/README.md +55 -1
- package/dist/chunks/cache-CSRIBDNY.cjs +1 -0
- package/dist/chunks/cache-EZ3VLUUC.mjs +1 -0
- package/dist/chunks/chunk-3DAM6EZN.cjs +203 -0
- package/dist/chunks/chunk-43WAI4Z7.mjs +1 -0
- package/dist/chunks/chunk-47LKNS74.mjs +1 -0
- package/dist/chunks/chunk-6NYX22KV.cjs +48 -0
- package/dist/chunks/{chunk-YJK7F6NJ.cjs → chunk-AARBEAIB.cjs} +22 -22
- package/dist/chunks/chunk-D5NDNAKA.cjs +1 -0
- package/dist/chunks/chunk-ECMVXJH2.mjs +1 -0
- package/dist/chunks/chunk-EH2QTB6S.cjs +37 -0
- package/dist/chunks/chunk-ESA2CL57.mjs +37 -0
- package/dist/chunks/chunk-ETCTXAXR.mjs +1 -0
- package/dist/chunks/{chunk-4XKCGYFF.mjs → chunk-EU2I2AMK.mjs} +22 -22
- package/dist/chunks/chunk-FZNMPXUO.mjs +62 -0
- package/dist/chunks/chunk-H4VZF3ZQ.mjs +1 -0
- package/dist/chunks/chunk-J7Z3MIR7.cjs +1 -0
- package/dist/chunks/chunk-KTSR5VPT.mjs +1 -0
- package/dist/chunks/chunk-OUJNWRIY.mjs +48 -0
- package/dist/chunks/chunk-QZMJ5EUF.mjs +203 -0
- package/dist/chunks/chunk-R32346OA.cjs +1 -0
- package/dist/chunks/chunk-VXLUR7M5.cjs +62 -0
- package/dist/chunks/chunk-VZCOLSBF.cjs +1 -0
- package/dist/chunks/chunk-W5SMGCKO.cjs +1 -0
- package/dist/chunks/chunk-Y7JDLK56.cjs +1 -0
- package/dist/chunks/cli-handler-7HKSS3UW.mjs +1 -0
- package/dist/chunks/cli-handler-OU2TC2SB.cjs +1 -0
- package/dist/chunks/code-base-OBQSRCQ3.mjs +1 -0
- package/dist/chunks/code-base-WZ3L5IE5.cjs +1 -0
- package/dist/chunks/database-manager-T43UZZ45.cjs +1 -0
- package/dist/chunks/database-manager-ZC46AHSS.mjs +1 -0
- package/dist/chunks/file-watcher-GUS2OVZU.cjs +1 -0
- package/dist/chunks/file-watcher-RAO72GUL.mjs +1 -0
- package/dist/chunks/{interfaces-S7TJGWWS.mjs → interfaces-UUDPRWI6.mjs} +1 -1
- package/dist/chunks/interfaces-YGSG2MI4.cjs +1 -0
- package/dist/chunks/llm-NWYEBR5K.mjs +1 -0
- package/dist/chunks/llm-UYBJKQ3S.cjs +1 -0
- package/dist/chunks/{stdio-server-DFKFFRSM.cjs → stdio-server-37QG6AO2.cjs} +2 -2
- package/dist/chunks/stdio-server-QAEXVFSI.mjs +30 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +149 -41
- package/dist/index.d.ts +149 -41
- package/dist/index.mjs +1 -1
- package/package.json +10 -11
- package/dist/chunks/chunk-23YR2LAM.cjs +0 -1
- package/dist/chunks/chunk-2YMB6W5S.mjs +0 -1
- package/dist/chunks/chunk-3RVRPGJC.mjs +0 -1
- package/dist/chunks/chunk-3UGOMK4F.cjs +0 -62
- package/dist/chunks/chunk-5M2N7JFP.cjs +0 -1
- package/dist/chunks/chunk-A4YJ5ZVE.cjs +0 -203
- package/dist/chunks/chunk-J7AIRI5N.mjs +0 -203
- package/dist/chunks/chunk-LLO6DDXU.mjs +0 -48
- package/dist/chunks/chunk-LQVKXVBS.mjs +0 -51
- package/dist/chunks/chunk-LZLPJAB6.mjs +0 -62
- package/dist/chunks/chunk-M2YU5LAI.cjs +0 -1
- package/dist/chunks/chunk-MZHDSOD7.mjs +0 -1
- package/dist/chunks/chunk-OGTQ7MWV.cjs +0 -51
- package/dist/chunks/chunk-V6PHJ4DG.cjs +0 -48
- package/dist/chunks/cli-handler-B7WPIZRE.cjs +0 -1
- package/dist/chunks/cli-handler-EJX27R4Q.mjs +0 -1
- package/dist/chunks/code-base-FSOSU46G.mjs +0 -1
- package/dist/chunks/code-base-OWYMNEQG.cjs +0 -1
- package/dist/chunks/database-manager-7D7NDXJK.mjs +0 -1
- package/dist/chunks/database-manager-X4DMAUWC.cjs +0 -1
- package/dist/chunks/file-watcher-E2JROVI7.cjs +0 -1
- package/dist/chunks/file-watcher-KSLBUUPP.mjs +0 -1
- package/dist/chunks/interfaces-URUTHSR2.cjs +0 -1
- package/dist/chunks/llm-R2ZLKZDO.cjs +0 -1
- package/dist/chunks/llm-U57HNTZO.mjs +0 -1
- package/dist/chunks/stdio-server-NV5YAXJD.mjs +0 -30
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {f as f$1}from'./chunk-MZHDSOD7.mjs';import {c,e,a as a$1,d}from'./chunk-3RVRPGJC.mjs';import {g,F,f as f$2,e as e$1,d as d$1,b}from'./chunk-LZLPJAB6.mjs';import {i,a,c as c$1,b as b$2,k,d as d$2}from'./chunk-J7AIRI5N.mjs';import {g as g$1,j,h,f as f$3,i as i$1,b as b$1,k as k$1}from'./chunk-4XKCGYFF.mjs';import {a as a$2}from'./chunk-LQVKXVBS.mjs';import {existsSync,mkdirSync,writeFileSync,readFileSync,copyFileSync,rmSync,statSync}from'fs';import {Log,State,ConfigFileParse,errorMeta,resolveLocaleLang,NameErrors,ServiceError}from'@easbot/utils';import {dirname,join}from'path';import {probeEmbeddingDims,syncMeta}from'@easbot/llm';import {createRequire}from'module';import {EMBEDDING_DIMS_CONSISTENCY_CHECK}from'@easbot/types';import {emitJsonError,emitJsonOk,printHuman,formatKnowledgeDoctor,formatKnowledgeStatus,formatKnowledgeInit,registerActiveProgressLine,clearActiveProgressLine,unregisterActiveProgressLine}from'@easbot/terminal';import {fileURLToPath}from'url';import {ServerTransportType}from'@easbot/mcp';var G=Log.create({service:"codebase-cache"}),Co=[".easbot","codebase.json"];function Eo(){try{let e=f$1().directory;if(e&&e.length>0)return e}catch{}return process.cwd()}function oe(o){return join(o,...Co)}async function Ro(o){let e=oe(o);if(!existsSync(e))return {codebaseJson:{},exists:false,rootDir:o};try{return {codebaseJson:await ConfigFileParse.loadFile(e,{schema:i}),exists:!0,rootDir:o}}catch(t){return G.warn("codebase.json parse failed",{configPath:e,error:errorMeta(t)}),{codebaseJson:void 0,exists:true,rootDir:o}}}var Ne=State.holder(()=>{try{return f$1().directory||"__codebase_cache_global__"}catch{return "__codebase_cache_global__"}},async()=>Ro(Eo())),f;(p=>{let o=false;async function e(){return Ne.get()}p.state=e;function n(){Ne.clear(),o=false;}p.resetState=n;async function t(){o||(o=true,G.info("CodebaseCache init"),await e());}p.init=t;async function i$1(){return (await e()).codebaseJson}p.getCodebaseJson=i$1;async function r(){return (await e()).exists}p.exists=r;async function l(){return (await e()).rootDir}p.getRootDir=l;async function s(c){let m=await e(),g=oe(m.rootDir),d=ConfigFileParse.merge([m.codebaseJson??{},c]),x=i.safeParse(d);if(!x.success)throw G.error("codebase.json validation failed on write",{configPath:g,issues:x.error.issues}),new Error(`codebase.json validation failed: ${x.error.message}`);let u=dirname(g);existsSync(u)||mkdirSync(u,{recursive:true});try{writeFileSync(g,JSON.stringify(x.data,null,2),"utf-8");}catch(y){throw G.error("codebase.json write failed",{configPath:g,error:errorMeta(y)}),y}return n(),G.debug("codebase.json written",{configPath:g}),x.data}p.writeCodebaseJson=s;async function a(){let c=await e();return oe(c.rootDir)}p.getConfigPath=a;})(f||(f={}));var ne=Log.create({service:"codebase.init"});function Oe(o){let e={},n=[];for(let t of o)t==="--force"||t==="-f"?e.force=true:t==="--help"||t==="-h"?e.help=true:t==="--json"?e.json=true:t.startsWith("-")||n.push(t);return e}async function D(o={}){let e=await f.getRootDir();try{let m=await k();m.source==="monorepo"?ne.debug("better-sqlite3 resolved (monorepo)",{path:m.absolutePath}):ne.debug("better-sqlite3 auto-installed to cache",{source:m.source,path:m.absolutePath});}catch(m){ne.warn("better-sqlite3 resolve / install failed; index/sync/mcp may still fail later",{error:errorMeta(m),hint:"Run `npm i -g better-sqlite3` then retry, or set EASBOT_CACHE_PATH to a writable directory before running `easbot codebase init`."});}let n=a(e),t=await f.getConfigPath(),i=c$1(e);if(await f.exists()&&!o.force)return {configPath:t,dbPath:i,created:false,skipped:true,backend:"better-sqlite3",schemaVersion:f$3,migrationsApplied:0,tablesCreated:0,durationMs:0};if(existsSync(n)||mkdirSync(n,{recursive:true}),await f.writeCodebaseJson({version:1,schema_version:f$3,extraction_version:j,backend:"better-sqlite3",created_at:new Date().toISOString()}),o.force)for(let m of [i,`${i}-wal`,`${i}-shm`])try{rmSync(m,{force:!0});}catch{}d$2(e);let r=false,l=0,s=0,a$1=Date.now(),p=new k$1(i);try{let m=p.getMeta("index_state"),g=p.getMeta("createdAt"),d=p.getMeta("version"),x=p.getMeta("indexed_with_version");r=m!==null&&g!==null&&d!==null&&x!==null;try{l=p.countSqliteObjects();}catch{}let u=p.getMeta("schema_version");s=u?Number.parseInt(u,10)||f$3:f$3;}finally{p.close();}let c=Date.now()-a$1;return {configPath:t,dbPath:i,created:true,skipped:false,metaInitialized:r,backend:"better-sqlite3",schemaVersion:f$3,migrationsApplied:s,tablesCreated:l,durationMs:c}}async function V(o){let e=await f.getRootDir(),t=await f.getConfigPath(),i=c$1(e),r=await f.exists(),l=existsSync(i),s;if(l)try{s=statSync(i).size;}catch{}let a={initialized:false,capabilities:{embedding:false,graphLlm:false}},p={},c,m,g,d=0,x=0,u,y,w,b=false,S,h=false,C;if(r)try{let I=await f.getCodebaseJson();I&&(c=I.index_state,y=I.schema_version,m=I.extraction_version,u=I.backend);}catch{}if(l&&i)try{let{DatabaseManager:I}=await import('./database-manager-7D7NDXJK.mjs'),F=new I(i);try{let $=F.getStatus();c=$.indexState??c,m=$.extractionVersion??m,g=$.isStale,d=$.nodeCount,x=$.edgeCount;for(let[U,fo]of Object.entries($.meta))p[U]=fo;S=$.meta.lastSyncAt,y=parseInt($.meta.schema_version??"",10)||y,u=$.meta.backend??u,b=$.meta.vector_enabled==="true"||$.meta.vector_enabled==="1",w=parseInt($.meta.embeddingDims??"",10)||void 0;try{let{stats:U}=F.checkIntegrity();C={...U};}catch{}h=F.isFtsAvailable();}finally{F.close();}}catch{}let N=a$2.isInitialized();if(N){a.initialized=true;let I=a$2.capabilities();a.capabilities={embedding:I.embedding===true,graphLlm:I.graphLlm===true},a.embeddingModel=a.capabilities.embedding?"configured":void 0,a.graphModel=a.capabilities.graphLlm?"configured":void 0;}if(N&&a.capabilities.embedding&&i)try{let I=a$2.getEmbeddingLlm();if(I){let F=await probeEmbeddingDims(I,{timeoutMs:5e3});if(typeof F=="number"){w=F;try{let{DatabaseManager:$}=await import('./database-manager-7D7NDXJK.mjs'),U=new $(i);try{syncMeta(U,[["embeddingDims",String(F)]]);}finally{U.close();}}catch{}}}}catch{}let P=l&&r&&!g&&c!=="failed"&&c!=="stale",T;return r?l?c==="failed"?T="Last sync failed \u2014 run `easbot codebase index` to retry.":g?T="Index is stale (extraction version mismatch) \u2014 run `easbot codebase recreate` to rebuild.":c==="uninitialized"?T="Config exists but index never built \u2014 run `easbot codebase index` to populate.":c==="partial"&&(T="Last sync partially succeeded \u2014 re-run `easbot codebase index` to fill missing files."):T="Run `easbot codebase index` to build the index.":T="Run `easbot codebase init` to initialize the configuration.",{package:"codebase",rootDir:e,dbPath:i,dbSize:s,configPath:t,configExists:r,schemaVersion:y,extractionVersion:m,lastSyncAt:S,indexState:c,vectorEnabled:b,embeddingDims:w,llm:a,backend:u,meta:p,recommendation:T,healthy:P,dbStats:C,dbExists:l,nodeCount:d,edgeCount:x,ftsAvailable:h}}var L=()=>Date.now();async function Te(o){let e=L(),n=await V(),t=[],i,r=L(),l;if(n.dbExists?n.configExists?l=v("database","ok",`db readable at ${n.dbPath}`,Date.now()-r):l=v("database","warn","config not found \u2014 run `easbot codebase init` first",Date.now()-r):l=v("database","info","db not initialized \u2014 run `easbot codebase index` to build",Date.now()-r),t.push(l),n.dbExists){let u=L();t.push(v("fts","ok","fts sync checked in integrity pass",Date.now()-u));}if(n.dbExists){let u=L();t.push(v("vector",n.vectorEnabled?"ok":"info",n.vectorEnabled?`vector index enabled (dims=${n.embeddingDims??"unknown"})`:"vector index disabled (set config.vector.enabled to enable)",Date.now()-u));}if(n.dbExists){let u=L();t.push(v("schema",n.isStale===true?"warn":"ok",n.isStale===true?`extraction_version mismatch (current=${n.extractionVersion??0})`:`schema_version=${n.schemaVersion??"unknown"}`,Date.now()-u));}t.push(v("lock","ok","no lock contention observed",0)),t.push(v("disk_space","ok","no disk space check (v0.5.1 placeholder)",0));let s=L(),a={"better-sqlite3":false,"node:sqlite":false,"@tursodatabase/database":false},p=createRequire(import.meta.url);try{p.resolve("better-sqlite3"),a["better-sqlite3"]=!0;}catch{}a["node:sqlite"]=typeof process.versions.sqlite=="string";try{p.resolve("@tursodatabase/database"),a["@tursodatabase/database"]=!0;}catch{}let c="ok",m=`backend available: ${n.backend??"unknown"}`;!a["better-sqlite3"]&&!a["node:sqlite"]?(c="error",m="no SQLite backend available (install better-sqlite3 or use Node 22.5+)"):n.configExists&&n.backend&&!a[n.backend]&&(c="error",m=`configured backend "${n.backend}" not available in this environment`),t.push(v("backend",c,m,Date.now()-s));let g=L(),d;if(!n.llm.initialized||!n.llm.capabilities.embedding)d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","llm not initialized; probe skipped",Date.now()-g);else if(!n.dbExists)d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","db not initialized; probe skipped",Date.now()-g);else try{let u=a$2.getEmbeddingLlm();if(!u)d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","embedding llm not exposed; probe skipped",Date.now()-g);else {let y=await probeEmbeddingDims(u,{timeoutMs:5e3});typeof y!="number"?d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","probe failed (network / model error)",Date.now()-g):n.embeddingDims===void 0?d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info",`probe=${y}, meta missing \u2014 next status will sync`,Date.now()-g):y!==n.embeddingDims?d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"warn",`probe=${y} but meta.embeddingDims=${n.embeddingDims} (drift detected)`,Date.now()-g,{probed:y,recorded:n.embeddingDims}):d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"ok",`probe=${y} matches meta`,Date.now()-g,{probed:y});}}catch(u){d=v(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info",`probe threw: ${errorMeta(u).message}`,Date.now()-g);}if(t.push(d),n.dbExists){let u=L();try{let{DatabaseManager:y}=await import('./database-manager-7D7NDXJK.mjs'),w=new y(n.dbPath);try{let{issues:b,stats:S}=w.checkIntegrity();i=S;for(let h of b)t.push(v("integrity_stats",h.severity,h.message,0,{source:"database.checkIntegrity"}));i.parse_errors===0&&t.push(v("parse_errors_zero","info","parse_errors: 0 (no parse errors recorded)",0)),i.unresolved_refs===0&&t.push(v("unresolved_refs_zero","info","unresolved_refs: 0 (resolution pipeline not active)",0)),i.name_segment_vocab===0&&t.push(v("name_segment_vocab_zero","info","name_segment_vocab: 0 (identifier-segments not active)",0)),i.project_metadata===0&&t.push(v("project_metadata_zero","info","project_metadata: 0 (CodeBase.initialize not run)",0));}finally{w.close();}}catch(y){t.push(v("integrity_stats","warn",`db integrity check failed: ${errorMeta(y).message}`,Date.now()-u));}}let x=L();if(!n.llm.initialized)t.push(v("llm","info","Llm namespace not initialized (calls `easbot codebase init` first)",Date.now()-x));else {let u=[];n.llm.capabilities.embedding||u.push("embedding"),n.llm.capabilities.graphLlm||u.push("graphLlm"),t.push(v("llm",u.length===0?"ok":"info",u.length===0?"embedding + graphLlm configured":`missing capabilities: ${u.join(", ")}`,Date.now()-x,{capabilities:n.llm.capabilities}));}return {healthy:!t.some(u=>u.severity==="error"),checks:t,issues:t.map(u=>({severity:u.severity,message:u.message,name:u.name,code:u.code})),durationMs:Date.now()-e,status:n,backendAvailable:a,dbStats:i??void 0}}function v(o,e,n,t,i){return {code:o.toUpperCase().replace(/[^A-Z0-9]+/g,"_"),severity:e,name:o,message:n,details:i,durationMs:t}}function Pe(o){let e={};for(let n of o)if(n==="--no-embed")e.noEmbed=true;else if(n==="--embed")e.noEmbed=false;else if(n==="--json")e.json=true;else if(n==="--verbose"||n==="-v")e.verbose=true;else if(n==="--quiet"||n==="-q")e.quiet=true;else if(n==="--help"||n==="-h")e.help=true;else if(n.startsWith("--batch=")){let t=n.slice(8),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e.batch=i);}return e}async function H(o){let e=await f.getRootDir();a(e);b$2(e);await D();let {CodeBase:i}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s}=await import('@easbot/types'),a$1=o.batch??l.batchSize??50,p=new i({workspaceDir:e,database:{path:c$1(e),walMode:true},embedding:o.noEmbed===false?r:void 0,indexer:{...l,batchSize:a$1},parser:s,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),m=-1,g=0,d=!o.quiet,x;try{await p.initialize(),registerActiveProgressLine(process.stderr);let u=await p.indexDirectory(e,d?y=>{let w=Math.max(y.total,1),b=Math.min(100,Math.floor(y.processed/w*100)),S=Date.now();if(b!==m||S-g>3e4){let C=String(b).padStart(3," ");clearActiveProgressLine(),process.stderr.write(` \u{1F4A1} [${C}%] ${y.stage}: ${y.processed}/${y.total} files`),m=b,g=S;}}:void 0);x={rootDir:e,success:u.success,filesProcessed:u.filesProcessed,nodesCreated:u.nodesCreated,edgesCreated:u.edgesCreated,errorCount:u.errors.length,errors:u.errors,durationMs:u.duration,embedded:!o.noEmbed,batchSize:a$1};}finally{clearActiveProgressLine(),unregisterActiveProgressLine(process.stderr),await p.close();}return x}function Fe(o){let e=[];if(e.push("Codebase index"),e.push(` rootDir: ${o.rootDir}`),e.push(` success: ${o.success?"\u2713":"\u2717"}`),e.push(` files processed: ${o.filesProcessed}`),e.push(` nodes created: ${o.nodesCreated}`),e.push(` edges created: ${o.edgesCreated}`),e.push(` embedded: ${o.embedded?"yes":"no (--no-embed)"}`),e.push(` batch size: ${o.batchSize}`),e.push(` duration: ${o.durationMs}ms`),o.errorCount>0){e.push(` errors (${o.errorCount}):`);for(let n of o.errors.slice(0,10))e.push(` - ${n.filePath}: ${n.error}`);o.errors.length>10&&e.push(` ... and ${o.errors.length-10} more`);}return e.join(`
|
|
2
|
-
`)}function Me(o){let e={};for(let n of o)n==="--json"?e.json=true:n==="--quiet"||n==="-q"?e.quiet=true:n==="--help"||n==="-h"?e.help=true:n==="--no-embed"?e.noEmbed=true:n==="--embed"&&(e.noEmbed=false);return e}async function Ae(o){let e=await f.getRootDir(),n=c$1(e),{CodeBase:t}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:i,DEFAULT_INDEXER_CONFIG:r,DEFAULT_PARSER_CONFIG:l}=await import('@easbot/types'),s=new t({workspaceDir:e,database:{path:n,walMode:true},embedding:o.noEmbed===false?i:void 0,indexer:r,parser:l,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),a,p={_lastPct:-1,_lastProgressAt:0};try{await s.initialize(),registerActiveProgressLine(process.stderr);let c=await s.sync(o.quiet?void 0:g=>{let d=Math.max(g.total,1),x=Math.min(100,Math.floor(g.processed/d*100)),u=Date.now(),y=x!==p._lastPct,w=u-p._lastProgressAt>3e4;if(y||w){let b=String(x).padStart(3," ");clearActiveProgressLine(),process.stderr.write(` \u{1F4A1} [${b}%] ${g.stage}: ${g.processed}/${g.total} files`),p._lastPct=x,p._lastProgressAt=u;}}),m=s.getDatabase().getIndexState();a={rootDir:e,success:c.success,filesAdded:c.filesAdded,filesUpdated:c.filesUpdated,filesDeleted:c.filesDeleted,filesSkipped:c.filesSkipped,nodesCreated:c.nodesCreated,edgesCreated:c.edgesCreated,errorCount:c.errors.length,errors:c.errors,durationMs:c.duration,indexState:m};}finally{clearActiveProgressLine(),unregisterActiveProgressLine(process.stderr),await s.close();}return a}function qe(o){let e=[];if(e.push("Codebase sync"),e.push(` rootDir: ${o.rootDir}`),e.push(` success: ${o.success?"\u2713":"\u2717"}`),e.push(` indexState: ${o.indexState}`),e.push(""),e.push(" Files"),e.push(` \u2139 added: ${o.filesAdded}`),e.push(` \u2139 updated: ${o.filesUpdated}`),e.push(` \u2139 deleted: ${o.filesDeleted}`),e.push(` \u2139 skipped: ${o.filesSkipped} (no-change: hash matches; parser-rejected: 0 nodes)`),e.push(""),e.push(" Graph"),e.push(` \u2139 nodes created: ${o.nodesCreated}`),e.push(` \u2139 edges created: ${o.edgesCreated}`),e.push(` duration: ${o.durationMs}ms`),o.errorCount>0){e.push(` errors (${o.errorCount}):`);for(let n of o.errors.slice(0,10))e.push(` - ${n.filePath}: ${n.error}`);o.errors.length>10&&e.push(` ... and ${o.errors.length-10} more`);}return e.join(`
|
|
3
|
-
`)}function Je(o){let e={};for(let n of o)n==="--keep-config"?e.keepConfig=true:n==="--no-reindex"?e.noReindex=true:n==="--no-embed"?e.noEmbed=true:n==="--force"||n==="-f"?e.force=true:n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}async function ze(o){let e=await f.getRootDir();a(e);let t=c$1(e),i=b$2(e),r=false,l=false;for(let p of [t,`${t}-wal`,`${t}-shm`])if(existsSync(p))try{rmSync(p,{force:!0}),p===t&&(r=!0);}catch{}if(!o.keepConfig&&existsSync(i))try{rmSync(i,{force:!0}),l=!0;}catch{}await D({force:true});let s=false,a$1;if(!o.noReindex){let p=await H({noEmbed:o.noEmbed,quiet:true});s=true,a$1={filesProcessed:p.filesProcessed,nodesCreated:p.nodesCreated,edgesCreated:p.edgesCreated,durationMs:p.durationMs,embedded:p.embedded};}return {rootDir:e,removedDb:r,removedConfig:l,recreated:true,reindexed:s,configPath:i,indexSummary:a$1}}function We(o){let e=[];return e.push("Codebase recreate"),e.push(` rootDir: ${o.rootDir}`),e.push(` removed db: ${o.removedDb?"\u2713":"\u2717 (not found)"}`),e.push(` removed config:${o.removedConfig?"\u2713":"(preserved via --keep-config or absent)"}`),e.push(` \u2713 reinitialized at ${o.configPath}`),o.reindexed&&o.indexSummary?e.push(` \u2713 reindexed in ${o.indexSummary.durationMs}ms (files: ${o.indexSummary.filesProcessed}, nodes: ${o.indexSummary.nodesCreated}, edges: ${o.indexSummary.edgesCreated}, embed: ${o.indexSummary.embedded?"on":"off"})`):e.push(" \u2139 reindex skipped (--no-reindex). Next: run `easbot codebase index` to rebuild the index."),e.join(`
|
|
4
|
-
`)}function Ge(o){let e={};for(let n of o)n==="--keep-embeddings"?e.keepEmbeddings=true:n==="--force"||n==="-f"?e.force=true:n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}async function Ke(o){let e=await f.getRootDir();a(e);let t=c$1(e),i=b$2(e);if(!existsSync(t))return await D(),{rootDir:e,cleared:false,nodesRemoved:0,edgesRemoved:0,filesRemoved:0,embeddingsPreserved:false,configPreserved:existsSync(i),nextIndexState:"uninitialized"};let{CodeBase:r}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:l,DEFAULT_INDEXER_CONFIG:s,DEFAULT_PARSER_CONFIG:a$1}=await import('@easbot/types'),p=new r({workspaceDir:e,database:{path:t,walMode:true},embedding:o.keepEmbeddings?l:void 0,indexer:s,parser:a$1,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),c;try{await p.initialize();let m={nodes:p.getDatabase().getNodeCount(),edges:p.getDatabase().getEdgeCount(),files:p.getDatabase().getFileCount()};await p.clear({keepEmbeddings:!!o.keepEmbeddings}),p.getDatabase().setIndexState("uninitialized"),c={rootDir:e,cleared:!0,nodesRemoved:m.nodes,edgesRemoved:m.edges,filesRemoved:m.files,embeddingsPreserved:!!o.keepEmbeddings,configPreserved:existsSync(i),nextIndexState:"uninitialized"};}finally{await p.close();}return c}function Ve(o){let e=[];return e.push("Codebase clear"),e.push(` rootDir: ${o.rootDir}`),o.cleared?(e.push(" \u2713 cleared data"),e.push(` nodes removed: ${o.nodesRemoved}`),e.push(` edges removed: ${o.edgesRemoved}`),e.push(` file hashes removed: ${o.filesRemoved}`),e.push(` embeddings preserved: ${o.embeddingsPreserved?"yes (--keep-embeddings)":"no"}`),e.push(` config preserved: ${o.configPreserved?"\u2713":"\u2717"}`)):(e.push(" \u2717 db not found at .easbot/db/codebase.db \u2014 nothing to clear"),e.push(` config preserved: ${o.configPreserved?"\u2713":"\u2717"}`)),e.push(""),e.push("\u{1F4A1} Next: run `easbot codebase index` to rebuild."),e.join(`
|
|
5
|
-
`)}var He=new Set(["backend","schema_version","extraction_version"]);function qo(o){return new Set(["schema_version","extraction_version"]).has(o)?"number":"string"}function Ye(o){let e={},n=[];for(let t of o)t==="--json"?e.json=true:t==="--help"||t==="-h"?e.help=true:t.startsWith("-")||n.push(t);return n.length>0&&(e.subcommand=n[0],e.subcommand==="set"?(n.length>1&&(e.key=n[1]),n.length>2&&(e.value=n[2])):n.length>1&&(e.key=n[1])),e}var Uo=new Set(["backend","schema_version","extraction_version"]);async function Qe(o){let e=await f.getConfigPath(),n=await f.exists(),t={rootDir:await f.getRootDir(),configPath:n?e:void 0,exists:n,values:null};if(!n)return t;let i=await f.getCodebaseJson();return i?(o.key?(t.key=o.key,t.value=i[o.key]):t.values={...i},t):{...t,exists:false}}async function Xe(o){if(!o.key)throw new b$1.ConfigError({message:"config set requires <key>"});if(o.value===void 0)throw new b$1.ConfigError({message:"config set requires <value> after <key>",field:o.key});if(!He.has(o.key))throw new b$1.ConfigError({message:`Unsupported config key: "${o.key}". Allowed: ${Array.from(He).join(", ")}`,field:o.key});let e=await f.getConfigPath();if(!await f.exists())throw new b$1.ConfigError({message:`codebase not initialized at ${await f.getRootDir()} \u2014 run \`easbot codebase init\` first`});let n=o.value;if(qo(o.key)==="number"){let l=Number(o.value);if(!Number.isFinite(l))throw new b$1.ConfigError({message:`config key "${o.key}" expects a number, got "${o.value}"`,field:o.key});n=l;}let i=await f.getCodebaseJson()??{},r=i[o.key];return i[o.key]=n,await f.writeCodebaseJson(i),{rootDir:await f.getRootDir(),configPath:e,key:o.key,oldValue:r,newValue:n,requiresRestart:Uo.has(o.key)}}function Ze(o){if(!o.exists)return `\u2717 config not found at ${o.configPath??"/.easbot/codebase.json"} \u2014 run \`easbot codebase init\` first`;let e=[];if(e.push(`Codebase config: ${o.configPath}`),o.key!==void 0)e.push(` ${o.key}: ${JSON.stringify(o.value)}`);else if(o.values)for(let[n,t]of Object.entries(o.values))e.push(` ${n}: ${JSON.stringify(t)}`);return e.join(`
|
|
6
|
-
`)}function et(o){let e=[];return e.push(`\u2713 ${o.key}: ${JSON.stringify(o.oldValue)} \u2192 ${JSON.stringify(o.newValue)} (${o.configPath})`),o.requiresRestart&&(e.push(""),e.push(" \u26A0\uFE0F this setting affects db connection / sync behavior \u2014 restart CodeBase or run `easbot codebase recreate` for the change to take effect.")),e.join(`
|
|
7
|
-
`)}function nt(o){let e={};for(let n of o)n==="--schema"?e.schema=true:n==="--force"||n==="-f"?e.force=true:n==="--backup"||n==="-b"?e.backup=true:n==="--dry-run"||n==="-n"?e.dryRun=true:n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}async function st(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(!existsSync(n)||!existsSync(t))throw new NameErrors.OperationFailedError({message:`codebase not initialized at ${e} \u2014 run \`easbot codebase init\` first`,operation:"codebase-not-initialized",target:e});let{DatabaseManager:i}=await import('./database-manager-7D7NDXJK.mjs'),r=new i(t);try{let l=r.db,s=r.isIndexStale(),a=r.getMeta("indexed_with_extraction_version"),p=a?parseInt(a,10):null,c=r.getIndexState(),m=r.getMeta("schema_version"),g=m?parseInt(m,10):0,d={rootDir:e,dbPath:t,wasStale:s,previousVersion:p??null,currentVersion:j,applied:!1,schemaMigrated:!1,previousSchemaVersion:g,currentSchemaVersion:g,dryRun:!!o.dryRun,schemaSteps:g$1.map(b=>({id:b.id,description:b.description,status:"pending"})),migrationErrors:[],indexState:c},x;if(o.backup!==!1&&!o.dryRun)try{let b=new Date().toISOString().replace(/[:.]/g,"-");x=join(n,`codebase.db.bak.${b}`),copyFileSync(t,x);for(let S of ["-wal","-shm"]){let h=t+S;existsSync(h)&©FileSync(h,x+S);}d.backupPath=x;}catch(b){let S=errorMeta(b).message;d.recommendation=`Backup failed: ${S}. Continuing without backup.`;}let y=o.schema!==!1;try{let b=h(l,f$3,{dryRun:o.dryRun});d.currentSchemaVersion=o.dryRun?b.targetVersion:Math.max(b.currentVersion,b.targetVersion),d.migrationErrors=b.errors.map(h=>({migrationId:h.migrationId,error:h.error}));let S=new Set(b.applied);for(let h of d.schemaSteps)S.has(h.id)&&(h.status=o.dryRun?"pending":"applied");for(let h of d.migrationErrors){let C=d.schemaSteps.find(N=>N.id===h.migrationId);C&&(C.status="failed");}if(d.schemaMigrated=b.applied.length>0&&!o.dryRun,!o.dryRun){let h=i$1(l);d.currentSchemaVersion=h,h>0&&r.setMeta("schema_version",String(h));}}catch(b){let S=errorMeta(b).message;d.migrationErrors.push({migrationId:0,error:S});}let w=s||o.force;return w&&!o.dryRun&&(r.setMeta("indexed_with_extraction_version",String(j)),(c==="stale"||c==="failed")&&(r.setIndexState("complete"),d.indexState="complete"),d.applied=!0),o.dryRun?d.migrationErrors.length>0?d.recommendation="dry-run finished. Run without --dry-run to apply.":d.schemaMigrated?d.recommendation="dry-run: schema migration would apply. Run without --dry-run to apply.":d.recommendation="dry-run: nothing to apply.":!w&&!d.schemaMigrated&&d.migrationErrors.length===0?d.recommendation=`Already current (schema_version=${d.currentSchemaVersion}, extraction_version=${j}). No upgrade needed.`:d.migrationErrors.length>0?d.recommendation=`Schema migration completed with ${d.migrationErrors.length} error(s). `+(d.backupPath?`Restore from backup: ${d.backupPath}`:"Re-run `recreate` to drop & rebuild."):d.schemaMigrated&&!w?d.recommendation=`Schema migrated (v${d.previousSchemaVersion} \u2192 v${d.currentSchemaVersion}). To apply extraction changes, run \`recreate\` to rebuild data or \`index --force\`.`:d.schemaMigrated&&w?d.recommendation="Schema + extraction metadata both updated. To rebuild data with new extractor, run `recreate` or `index --force`.":d.recommendation="Extraction metadata updated. No schema changes needed.",d}finally{r.close();}}function it(o){let e=[];if(e.push(`Codebase upgrade${o.dryRun?" (dry-run)":""}`),e.push(` db: ${o.dbPath}`),o.backupPath&&e.push(` backup: ${o.backupPath}`),e.push(` previous version: ${o.previousVersion??"(none)"}`),e.push(` current version: ${o.currentVersion}`),e.push(` previous schema_version: ${o.previousSchemaVersion}`),e.push(` current schema_version: ${o.currentSchemaVersion}`),e.push(` was stale: ${o.wasStale?"yes":"no"}`),e.push(` applied: ${o.applied?"\u2713":"(noop \u2014 already current)"}`),(o.schemaSteps??[]).length>0){e.push(""),e.push(" schema steps:");for(let n of o.schemaSteps){let t=n.status==="applied"?"\u2713":n.status==="pending"?"\xB7":n.status==="failed"?"\u2717":"-";e.push(` [${t}] v${n.id}: ${n.description}`);}}if((o.migrationErrors??[]).length>0){e.push(""),e.push(` migration errors: ${o.migrationErrors.length}`);for(let n of o.migrationErrors)e.push(` - v${n.migrationId}: ${n.error}`);}return e.push(` index_state: ${o.indexState}`),o.recommendation&&(e.push(""),e.push(` \u{1F4A1} ${o.recommendation}`)),e.join(`
|
|
8
|
-
`)}function rt(o){let e={};for(let n of o)if(n==="--all")e.all=true;else if(n==="--dry-run"||n==="-n")e.dryRun=true;else if(n==="--pending-list"||n==="-p")e.pendingList=true;else if(n.startsWith("--batch=")){let t=parseInt(n.slice(8),10);Number.isFinite(t)&&t>0&&(e.batchSize=t);}else n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}var zo=200;function Wo(o,e=zo){return o?o.length<=e?o:o.slice(0,e)+"\u2026":""}async function ct(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(!existsSync(n))throw new NameErrors.OperationFailedError({message:`codebase not initialized at ${e} \u2014 run \`easbot codebase init\` first`,operation:"codebase-not-initialized",target:e});if(!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first to build`,operation:"db-not-found",target:t});let i=Date.now(),r=process.env.EASBOT_EMBEDDING_MODEL;if(!o.dryRun&&!r)throw new NameErrors.MissingFieldError({field:"EASBOT_EMBEDDING_MODEL",message:'embed requires an embedding model. Set EASBOT_EMBEDDING_MODEL env var (e.g. "openai/text-embedding-3-small") or pass --dry-run to skip embedding generation and just inspect pending nodes. Call `embed` from within an `easbot` REPL session for actual generation.'});let{CodeBase:l}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:s,DEFAULT_INDEXER_CONFIG:a$1,DEFAULT_PARSER_CONFIG:p}=await import('@easbot/types'),c={...s,modelId:r??"(dry-run)"},m=new l({workspaceDir:e,database:{path:t,walMode:true},embedding:c,indexer:a$1,parser:p,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await m.initialize();let g=m.getDatabase(),d=g.getNodeCount(),x=g.queryAll("SELECT node_id FROM node_embeddings"),u=new Set(x.map(S=>S.node_id)),y;if(o.all)y=g.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else if(u.size===0)y=g.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else {let S=Array.from(u),h=S.map(()=>"?").join(",");y=g.queryAll(`SELECT id, name, ast_type, language, file_path, text FROM nodes WHERE id NOT IN (${h})`,S);}let w=y.map(S=>({id:S.id,name:S.name,ast_type:S.ast_type,file_path:S.file_path,language:S.language,text_preview:Wo(S.text)})),b={rootDir:e,dbPath:t,totalNodes:d,alreadyEmbedded:u.size,newlyEmbedded:0,failed:0,all:!!o.all,dryRun:!!o.dryRun,pendingList:o.pendingList?w:[],duration:Date.now()-i,embeddingModelConfigured:!!r};return o.dryRun?b.recommendation=w.length>0?`dry-run: ${w.length} node(s) pending embedding. Use \`easbot codebase embed\` (without --dry-run) inside an \`easbot\` REPL for actual generation, or \`--pending-list\` to emit this list as JSON.`:"dry-run: all nodes already embedded.":w.length===0?b.recommendation="All nodes already have embeddings. Use --all to force regenerate.":b.recommendation=`${w.length} node(s) pending. Run \`easbot codebase embed --pending-list --json [dir]\` to emit the list, then call \`embed\` from within an \`easbot\` REPL session for actual generation (CLI cannot invoke AI SDK adapters in standalone mode).`,b}finally{await m.close();}}function lt(o){let e=[],n=o.dryRun?" (dry-run)":"";if(e.push(`Codebase embed${n}`),e.push(` db: ${o.dbPath}`),e.push(` mode: ${o.all?"all (force regenerate)":"incremental (only missing)"}`),e.push(` embedding model: ${o.embeddingModelConfigured?"configured":"(none)"}`),e.push(` total nodes: ${o.totalNodes}`),e.push(` already embedded: ${o.alreadyEmbedded}`),e.push(` newly embedded: ${o.newlyEmbedded}`),o.failed>0&&e.push(` failed: ${o.failed}`),e.push(` pending: ${o.pendingList.length}`),e.push(` duration: ${o.duration}ms`),o.dryRun&&o.pendingList.length>0){e.push(""),e.push(" \u{1F4A1} first 5 pending nodes:");for(let t of o.pendingList.slice(0,5))e.push(` - ${t.id} (${t.ast_type})`);}return o.recommendation&&(e.push(""),e.push(` \u{1F4A1} ${o.recommendation}`)),e.join(`
|
|
9
|
-
`)}var dt=Log.create({service:"codebase-watch"});function pt(o){let e={};for(let n of o)if(n.startsWith("--debounce=")){let t=parseInt(n.slice(11),10);Number.isFinite(t)&&t>0&&(e.debounce=t);}else if(n.startsWith("--interval=")){let t=parseInt(n.slice(11),10);Number.isFinite(t)&&t>0&&(e.interval=t);}else if(n.startsWith("--backend=")){let t=n.slice(10);(t==="fs-events"||t==="inotify"||t==="windows"||t==="brute-force"||t==="watchman"||t==="auto")&&(e.backend=t);}else n.startsWith("--ignore=")?(e.ignore||(e.ignore=[]),e.ignore.push(n.slice(9))):n==="--on-load-failure=throw"?e.onLoadFailure="throw":n==="--on-load-failure=warn"?e.onLoadFailure="warn":n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}async function ut(o){let e=await f.getRootDir(),n=a(e);existsSync(n)||await D();let t=new a$1({workspaceDir:e,backend:o.backend??"auto",ignorePatterns:o.ignore,onLoadFailure:o.onLoadFailure??"warn"}),i=[];t.on((r,l)=>{let s={event:r,relPath:l,at:Date.now()};i.push(s),dt.debug("watch event",{event:r,relPath:l});let a=`[${new Date(s.at).toISOString()}]`,p=r==="add"?"\x1B[32m+ ADD \x1B[0m":r==="change"?"\x1B[33m~ CHANGE\x1B[0m":"\x1B[31m- UNLINK\x1B[0m";process.stdout.write(`${a} ${p} ${l}
|
|
10
|
-
`);}),await t.start();try{await d(n,process.pid);}catch(r){dt.warn("failed to write watcher pid",{error:errorMeta(r)});}return {watcher:t,events:i,startTime:Date.now()}}function mt(o){return ["Codebase watcher started"," backend: native @parcel/watcher (real-time FS events)"," debounce: 200ms (event coalescing)",` pid: ${process.pid}`,` initial events: ${o.length}`].join(`
|
|
11
|
-
`)}function gt(o){let e={};for(let n of o)n==="--force"||n==="-f"?e.force=true:n==="--json"?e.json=true:(n==="--help"||n==="-h")&&(e.help=true);return e}async function ft(o){let e$1=await f.getRootDir(),n=a(e$1);existsSync(n)||await D();let t=join(n,".watcher.pid"),i=c(n);if(i===null)return {rootDir:e$1,pidFile:t,pid:null,stopped:false,error:"No watcher running (no .easbot/.watcher.pid found)"};try{return process.kill(i,"SIGTERM"),await e(n),{rootDir:e$1,pidFile:t,pid:i,stopped:!0}}catch(r){await e(n);let l=errorMeta(r).message;return {rootDir:e$1,pidFile:t,pid:i,stopped:false,error:l}}}function bt(o){let e=[];return e.push("Codebase stop"),e.push(` pid file: ${o.pidFile}`),e.push(` pid: ${o.pid??"(none)"}`),e.push(` stopped: ${o.stopped?"\u2713":"\u2717"}`),o.error?(e.push(` error: ${o.error}`),e.push(""),e.push(" \u{1F4A1} If a stale watcher was running, its process may have already exited.")):(e.push(""),e.push(" \u{1F4A1} Use `easbot codebase watch` to start a new watcher session.")),e.join(`
|
|
12
|
-
`)}function yt(o){let e={includeEdges:true,enableEmbedding:true},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t==="--no-edges")e.includeEdges=false;else if(t==="--no-vector"||t==="--no-embed")e.enableEmbedding=false;else if(t.startsWith("-l=")||t.startsWith("--language="))e.language=t.includes("=")?t.split("=")[1]:void 0;else if(!(t==="-l"||t==="--language"))if(t.startsWith("--ast="))e.astType=t.slice(6);else if(t.startsWith("-n=")||t.startsWith("--max=")){let i=parseInt(t.split("=")[1]??"",10);Number.isFinite(i)&&i>0&&(e.maxResults=i);}else t.startsWith("-")||n.push(t);return n.length>0&&(e.query=n.join(" ")),e}async function xt(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});let{CodeBase:i}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s,DEFAULT_SEARCH_CONFIG:a$1}=await import('@easbot/types'),p=new i({workspaceDir:e,database:{path:t,walMode:true},embedding:o.enableEmbedding?r:void 0,indexer:l,parser:s,search:a$1,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),c=Date.now();try{await p.initialize();let g=await p.getQuery().search(o.query??"",{maxResults:o.maxResults??10,language:o.language,astType:o.astType,includeEdges:o.includeEdges,enableEmbedding:o.enableEmbedding});return {rootDir:e,query:o.query??"",totalResults:g.length,results:g.map(d=>({id:d.id,name:d.name,astType:d.ast_type,language:d.language,filePath:d.file_path,startLine:d.start_line??0,endLine:d.end_line??0,snippet:(d.text??"").slice(0,200),edgeCount:(d.edges??[]).length})),durationMs:Date.now()-c}}finally{await p.close();}}function St(o){let e=[];e.push(`Codebase query: ${JSON.stringify(o.query)}`),e.push(` results: ${o.totalResults} (in ${o.durationMs}ms)`);for(let n of o.results)e.push(` ${n.name} (${n.astType}) \u2014 ${n.language} ${n.filePath}:${n.startLine}-${n.endLine} [${n.edgeCount} edges]`),e.push(` ${n.snippet.replace(/\s+/g," ").slice(0,100)}`);return e.join(`
|
|
13
|
-
`)}function Et(o){let e={includeEdges:false},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t==="--edges")e.includeEdges=true;else if(t.startsWith("--file="))e.file=t.slice(7);else if(t.startsWith("--kind="))e.kind=t.slice(7);else if(t.startsWith("--max=")){let i=parseInt(t.slice(6),10);Number.isFinite(i)&&i>0&&(e.edgesLimit=i);}else t.startsWith("-")||n.push(t);return n.length>0&&(e.name=n[0],e.nodeId=n[0]),e}async function Rt(o){if(!o.name&&!o.nodeId)throw new NameErrors.MissingFieldError({field:"name-or-nodeId",message:"node command requires a <name> or <node-id> argument"});let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});let i={workspaceDir:e,rootDir:e},r;try{r=await b(i,{name:o.name,nodeId:o.nodeId,file:o.file,kind:o.kind,includeEdges:o.includeEdges??!1,includeContent:!0,maxEdgesPerNode:o.edgesLimit??10});}catch(c){if(c instanceof ServiceError&&c.data?.code==="NOT_FOUND")return {rootDir:e,found:false,incomingEdges:[],outgoingEdges:[]};throw c}if(!r.node)return {rootDir:e,found:false,incomingEdges:[],outgoingEdges:[]};let l=[],s=[],a$1=r.node.name.split("@")[0]??r.node.name,p=a$1.includes(".")?a$1.split(".").pop()??a$1:a$1;for(let c of r.edges){let m;if(c.target===r.node.id)m="in";else if(c.source===r.node.id)m="out";else if(c.target.includes(":*:")){let d=(c.target.split(":").pop()??"").split("@")[0]??"";m=a$1.includes(".")&&d===a$1||d===p?"in":"out";}else m="out";let g={id:c.id,relation:c.relation,source:c.source,target:c.target,direction:m};(m==="in"?l:s).push(g);}return {rootDir:e,found:true,node:{id:r.node.id,name:r.node.name,astType:r.node.ast_type,language:r.node.language,filePath:r.node.file_path,startLine:r.node.start_line??0,endLine:r.node.end_line??0,text:r.node.text??""},incomingEdges:l,outgoingEdges:s}}function _t(o){if(!o.found||!o.node)return `\u2717 node not found (rootDir: ${o.rootDir})`;let e=[];if(e.push(`Codebase node: ${o.node.id}`),e.push(` name: ${o.node.name}`),e.push(` type: ${o.node.astType}`),e.push(` language: ${o.node.language}`),e.push(` location: ${o.node.filePath}:${o.node.startLine}-${o.node.endLine}`),e.push(` edges: ${o.incomingEdges.length} incoming / ${o.outgoingEdges.length} outgoing`),o.incomingEdges.length>0&&typeof o.incomingEdges[0]=="object"&&"relation"in o.incomingEdges[0]){e.push(""),e.push(" incoming edges:");for(let n of o.incomingEdges.slice(0,20))e.push(` [${n.relation}] ${n.source} \u2192 ${n.target}`);e.push(" outgoing edges:");for(let n of o.outgoingEdges.slice(0,20))e.push(` [${n.relation}] ${n.source} \u2192 ${n.target}`);}return e.join(`
|
|
14
|
-
`)}async function Y(o={}){let{CodeBase:e}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:n,DEFAULT_INDEXER_CONFIG:t,DEFAULT_PARSER_CONFIG:i,DEFAULT_SEARCH_CONFIG:r,DEFAULT_SYNC_CONFIG:l}=await import('@easbot/types'),s=await f.getRootDir(),a$1=c$1(s),p=a(s);if(!existsSync(p))if(o.autoInit)await D();else throw new NameErrors.OperationFailedError({message:`codebase not initialized at ${s} \u2014 run \`easbot codebase init <dir>\` first`,operation:"codebase-not-initialized",target:s});if(!existsSync(a$1))throw new NameErrors.OperationFailedError({message:`db not found at ${a$1} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:a$1});let c=new e({workspaceDir:s,database:{path:a$1,walMode:true},embedding:n,indexer:t,parser:i,search:r,sync:{...l,onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0},...o.configOverrides});await c.initialize();let m=false;return {codebase:c,rootDir:s,close:async()=>{if(!m){m=true;try{await c.close();}catch{}}}}}function Dt(o){let e={direction:"both"},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t.startsWith("--depth=")){let i=parseInt(t.slice(8),10);Number.isFinite(i)&&i>0&&(e.depth=i);}else if(t.startsWith("--max=")){let i=parseInt(t.slice(6),10);Number.isFinite(i)&&i>0&&(e.maxNodes=i);}else if(t.startsWith("--direction=")){let i=t.slice(12);(i==="incoming"||i==="outgoing"||i==="both")&&(e.direction=i);}else if(t.startsWith("--relation=")){let i=t.slice(11).split(",").map(r=>r.trim()).filter(Boolean);e.relationTypes=i;}else t.startsWith("-")||n.push(t);return n.length>0&&(e.nodeId=n[0]),e}async function vt(o){if(!o.nodeId)throw new NameErrors.MissingFieldError({field:"nodeId",message:"context command requires a <node-id> argument"});let e=o.depth??2,n=o.maxNodes??100,t=o.direction??"both",{codebase:i,rootDir:r,close:l}=await Y();try{let s=i.getDatabase(),a=i.getQuery();if(!s.getNodeById(o.nodeId))return {rootDir:r,rootNodeId:o.nodeId,depth:e,totalNodes:0,totalEdges:0,nodes:[],edges:[],truncated:!1};let c=new Map,m=[{nodeId:o.nodeId,depth:0}];c.set(o.nodeId,0);let g=[],d=!1;for(;m.length>0;){let b=m.shift();if(b.depth>=e)continue;if(c.size>=n){d=!0;break}let S=a.queryNeighbors(b.nodeId,{direction:t,relationTypes:o.relationTypes,limit:n-c.size+1});for(let h of S.edges){g.push({source:h.source,target:h.target,relation:h.relation});let C=h.source===b.nodeId?h.target:h.source;if(!c.has(C)&&(c.set(C,b.depth+1),m.push({nodeId:C,depth:b.depth+1}),c.size>=n)){d=!0;break}}if(d)break}let x=Array.from(c.keys()),u=x.length>0?s.queryNodes({ids:x}):[],y=new Map(u.map(b=>[b.id,b])),w=[];for(let[b,S]of c.entries()){let h=y.get(b);h&&w.push({id:h.id,name:h.name,astType:h.ast_type,language:h.language,filePath:h.file_path,depth:S});}return {rootDir:r,rootNodeId:o.nodeId,depth:e,totalNodes:w.length,totalEdges:g.length,nodes:w,edges:g,truncated:d}}finally{await l();}}function It(o){let e=[];e.push(`Codebase context: ${o.rootNodeId} (depth=${o.depth})`),e.push(` nodes: ${o.totalNodes}${o.truncated?" [TRUNCATED]":""}`),e.push(` edges: ${o.totalEdges}`);for(let n of o.nodes.slice(0,50))e.push(` [d=${n.depth}] ${n.name} (${n.astType}) \u2014 ${n.language} ${n.filePath}`);return o.nodes.length>50&&e.push(` ... and ${o.nodes.length-50} more`),e.join(`
|
|
15
|
-
`)}function Ot(o){let e={},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t.startsWith("-d=")||t.startsWith("--depth=")){let i=parseInt(t.split("=")[1]??"",10);Number.isFinite(i)&&i>0&&(e.depth=i);}else if(t.startsWith("--relation=")){let i=t.slice(11).split(",").map(r=>r.trim()).filter(Boolean);e.relationTypes=i;}else t.startsWith("--file=")?e.file=t.slice(7):t.startsWith("--kind=")?e.kind=t.slice(7):t.startsWith("-")||n.push(t);return n.length>0&&(e.nodeId=n[0]),e}async function jt(o){if(!o.nodeId)throw new NameErrors.MissingFieldError({field:"nodeId",message:"impact command requires a <node-id> argument"});let e=o.depth??3,n=o.relationTypes??["CALLS","REFERENCES","USES"],{rootDir:t,close:i}=await Y(),r={workspaceDir:t,rootDir:t};try{let l=await d$1(r,{name:o.nodeId,nodeId:o.nodeId,file:o.file,kind:o.kind,depth:e,relationTypes:n,maxResults:200});return {rootDir:t,rootNodeId:l.root?.id??o.nodeId,totalImpacted:l.totalImpacted,depth:e,buckets:l.buckets.map(s=>({depth:s.depth,count:s.count,sample:s.sample.map(a=>({id:a.id,name:a.name,filePath:a.filePath}))}))}}finally{await i();}}function Tt(o){let e=[];e.push(`Codebase impact: ${o.rootNodeId} (depth=${o.depth})`),e.push(` total impacted: ${o.totalImpacted}`);for(let n of o.buckets){e.push(` d=${n.depth}: ${n.count} nodes`);for(let t of n.sample.slice(0,5))e.push(` - ${t.name} (${t.filePath})`);}return e.join(`
|
|
16
|
-
`)}var nn="ts|tsx|js|jsx|mjs|cjs|py|rs|go|java|kt|scala|swift|rb|php|pl|sh|c|cpp|cc|cxx|h|hpp|lua|zig|cs|dart|ex|exs|clj|cljs|vue|svelte",sn=[new RegExp(`(?:^|/)(?:main|index|app|server)\\.(?:${nn})$`)];function Pt(o){let e={excludeEntry:true};for(let n of o)if(n==="--help"||n==="-h")e.help=true;else if(n==="--json")e.json=true;else if(n==="--no-exclude-entry")e.excludeEntry=false;else if(n.startsWith("--type="))e.astTypes=n.slice(7).split(",").map(t=>t.trim()).filter(Boolean);else if(n.startsWith("--limit=")){let t=parseInt(n.slice(8),10);Number.isFinite(t)&&t>0&&(e.limit=t);}return e}async function Ft(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});let i=o.astTypes??["function","method","class"],r=o.limit??100,l=o.excludeEntry!==false,{CodeBase:s}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:p,DEFAULT_PARSER_CONFIG:c,DEFAULT_SEARCH_CONFIG:m}=await import('@easbot/types'),g=new s({workspaceDir:e,database:{path:t,walMode:true},embedding:a$1,indexer:p,parser:c,search:m,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await g.initialize();let d=g.getDatabase(),x=g.getQuery(),u=[],y=0,w=["CALLS","IMPORTS","TYPE_REFERENCES"],b=d.queryAll("SELECT DISTINCT target FROM edges WHERE relation IN ('CALLS','IMPORTS','TYPE_REFERENCES')"),S=new Set(b.map(h=>h.target));for(let h of i){let C=d.queryNodes({astType:h,limit:1e5});for(let N of C){if(l&&sn.some(P=>P.test(N.file_path))){y++;continue}if(!S.has(N.id)&&(u.push({id:N.id,name:N.name,astType:N.ast_type,filePath:N.file_path,startLine:N.start_line??0}),u.length>=r))break}if(u.length>=r)break}return {rootDir:e,totalCandidates:u.length,excludedEntry:y,candidates:u.slice(0,r)}}finally{await g.close();}}function Lt(o){let e=[];e.push("Codebase dead-code"),e.push(` total candidates: ${o.totalCandidates}`),o.excludedEntry>0&&e.push(` excluded (entry files): ${o.excludedEntry}`);for(let n of o.candidates.slice(0,50))e.push(` - ${n.name} (${n.astType}) \u2014 ${n.filePath}:${n.startLine}`);return o.candidates.length>50&&e.push(` ... and ${o.candidates.length-50} more`),e.join(`
|
|
17
|
-
`)}function At(o){let e={relation:"IMPORTS",scope:"file"};for(let n of o)if(n==="--help"||n==="-h")e.help=true;else if(n==="--json")e.json=true;else if(n.startsWith("--relation="))e.relation=n.slice(11);else if(n.startsWith("--scope=")){let t=n.slice(8);(t==="file"||t==="module")&&(e.scope=t);}return e}function rn(o){let e=0,n=new Map,t=new Map,i=new Set,r=[],l=[];function s(a){n.set(a,e),t.set(a,e),e++,r.push(a),i.add(a);let p=o.get(a)??[];for(let c of p)n.has(c)?i.has(c)&&t.set(a,Math.min(t.get(a),n.get(c))):(s(c),t.set(a,Math.min(t.get(a),t.get(c))));if(t.get(a)===n.get(a)){let c=[],m;do m=r.pop(),i.delete(m),c.push(m);while(m!==a);c.length>1&&l.push(c);}}for(let a of o.keys())n.has(a)||s(a);return l}async function qt(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});let i=o.relation??"IMPORTS",{CodeBase:r}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:l,DEFAULT_INDEXER_CONFIG:s,DEFAULT_PARSER_CONFIG:a$1,DEFAULT_SEARCH_CONFIG:p}=await import('@easbot/types'),c=new r({workspaceDir:e,database:{path:t,walMode:true},embedding:l,indexer:s,parser:a$1,search:p,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await c.initialize();let m=c.getDatabase(),g=m.queryNodes({limit:1e5}),d=new Map;for(let C of g){let N=d.get(C.file_path)??[];N.push(C.id),d.set(C.file_path,N);}let x=g.map(C=>C.id),u=new Map;for(let C of g)u.set(C.id,C.file_path);let y;if(x.length===0)y=[];else {let C=x.map(()=>"?").join(",");y=m.queryAll(`SELECT * FROM edges WHERE relation = ? AND source IN (${C})`,[i,...x]);}let w=new Map;for(let C of y){let N=u.get(C.source),P=u.get(C.target);if(!N||!P||N===P)continue;let T=w.get(N);T||(T=new Set,w.set(N,T)),T.add(P);}let b=new Map;for(let[C,N]of w.entries())b.set(C,Array.from(N));let h=rn(b).map(C=>{let N=[];for(let P=0;P<C.length;P++){let T=C[P],I=w.get(T);if(I)for(let F of I)C.includes(F)&&N.push({source:T,target:F});}return {cycle:C,edges:N}});return {rootDir:e,relation:i,totalCycles:h.length,cycles:h.slice(0,50)}}finally{await c.close();}}function Ut(o){let e=[];e.push(`Codebase circular (relation=${o.relation})`),e.push(` total cycles: ${o.totalCycles}`);for(let n=0;n<o.cycles.length;n++){let t=o.cycles[n];e.push(` cycle #${n+1} (${t.cycle.length} files):`),e.push(` ${t.cycle.join(" \u2192 ")} \u2192 ${t.cycle[0]}`);}return e.join(`
|
|
18
|
-
`)}function zt(o){let e={},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t.startsWith("-d=")||t.startsWith("--depth=")){let i=parseInt(t.split("=")[1]??"",10);Number.isFinite(i)&&i>0&&(e.depth=i);}else if(t.startsWith("--relation=")){let i=t.slice(11).split(",").map(r=>r.trim()).filter(Boolean);e.relationTypes=i;}else t.startsWith("-")||n.push(t);return n.length>0&&(e.fromId=n[0]),n.length>1&&(e.toId=n[1]),e}async function Wt(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});if(!o.fromId||!o.toId)throw new NameErrors.MissingFieldError({field:"from-to",message:"path command requires <from> and <to> node IDs"});let i=o.depth??6,r=o.relationTypes??["CALLS","IMPORTS"],{CodeBase:l}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:s,DEFAULT_INDEXER_CONFIG:a$1,DEFAULT_PARSER_CONFIG:p,DEFAULT_SEARCH_CONFIG:c}=await import('@easbot/types'),m=new l({workspaceDir:e,database:{path:t,walMode:true},embedding:s,indexer:a$1,parser:p,search:c,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await m.initialize();let g=m.getQuery();if(o.fromId===o.toId)return {rootDir:e,found:!0,depth:0,steps:[],pathNodes:[o.fromId]};let d=new Set([o.fromId]),x=new Map,u=[o.fromId],y=!1;e:for(let h=0;h<=i;h++){let C=[];for(let N of u){let P=g.queryNeighbors(N,{direction:"both",relationTypes:r,limit:1e3});for(let T of P.edges){let I=T.source===N?T.target:T.source;if(!d.has(I)){if(d.add(I),x.set(I,{via:N,relation:T.relation}),I===o.toId){y=!0;break e}C.push(I);}}}u.length=0,u.push(...C);}if(!y)return {rootDir:e,found:!1,depth:0,steps:[],pathNodes:[]};let w=[o.toId],b=[],S=o.toId;for(;S!==o.fromId;){let h=x.get(S);if(!h)break;b.unshift({from:h.via,to:S,relation:h.relation}),w.unshift(h.via),S=h.via;}return {rootDir:e,found:!0,depth:b.length,steps:b,pathNodes:w}}finally{await m.close();}}function Gt(o){let e=[];if(!o.found)return e.push("Codebase path: NOT FOUND within depth limit"),e.join(`
|
|
19
|
-
`);e.push(`Codebase path: depth=${o.depth}`);for(let n=0;n<o.steps.length;n++){let t=o.steps[n];e.push(` ${n+1}. [${t.relation}] ${t.from} \u2192 ${t.to}`);}return e.join(`
|
|
20
|
-
`)}function Ht(o){let e={};for(let n of o)(n==="--help"||n==="-h")&&(e.help=true);return e}async function Yt(o){let e=await f.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await D(),!existsSync(t))throw new NameErrors.OperationFailedError({message:`db not found at ${t} \u2014 run \`easbot codebase index\` first`,operation:"db-not-found",target:t});let{CodeBase:i}=await import('./code-base-FSOSU46G.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s,DEFAULT_SEARCH_CONFIG:a$1}=await import('@easbot/types'),{CodebaseStdioServer:p}=await import('./stdio-server-NV5YAXJD.mjs'),c="0.0.0";try{let u=dirname(fileURLToPath(import.meta.url));for(let y=0;y<8;y++){try{let b=JSON.parse(readFileSync(join(u,"package.json"),"utf-8"));if(b?.name==="@easbot/codebase"&&typeof b.version=="string"){c=b.version;break}}catch{}let w=dirname(u);if(w===u)break;u=w;}}catch{}let m=new i({workspaceDir:e,database:{path:t,walMode:true},embedding:r,indexer:l,parser:s,search:a$1,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});await m.initialize();let g={id:"easbot-codebase-mcp",name:"EASBot Codebase MCP",version:c,transportType:ServerTransportType.STDIO},d=await p.start(m,g);return {rootDir:e,tools:d.tools}}var fn=Log.create({service:"codebase-cmd-callers"});function Qt(o){let e={maxResults:10},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t.startsWith("--file="))e.file=t.slice(7);else if(t.startsWith("--kind="))e.kind=t.slice(7);else if(t.startsWith("--max=")){let i=parseInt(t.slice(6),10);Number.isFinite(i)&&i>0&&(e.maxResults=i);}else t.startsWith("-")||n.push(t);return n.length>0&&(e.symbol=n[0]),e}async function Xt(o){if(!o.symbol&&!o.nodeId)throw new NameErrors.MissingFieldError({field:"symbol-or-nodeId",message:"callers command requires a <symbol> or --nodeId argument"});let e=await f.getRootDir(),n=Date.now(),i=await e$1({workspaceDir:e,rootDir:e},{name:o.symbol,nodeId:o.nodeId,file:o.file,kind:o.kind,maxResults:o.maxResults});return fn.debug("callers command done",{symbol:o.symbol,count:i.callers.length,rootDir:e}),{rootDir:e,serviceResult:i,durationMs:Date.now()-n}}function Zt(o){let{serviceResult:e,rootDir:n}=o,t=[],i=e.root?.name??"?",r=e.truncated?"+":"";if(t.push(`Callers of \`${i}\` (${e.callers.length}${r}) [${n}]`),e.callers.length===0)t.push(" (no incoming edges)");else for(let l of e.callers)t.push(` - [${l.relation}] \`${l.name}\` ${l.filePath}:${l.startLine}`);return e.callers.length>0&&(t.push(""),t.push("\u{1F4A1} Use `easbot codebase node <name>` to read full source of any caller.")),t.join(`
|
|
21
|
-
`)}var yn=Log.create({service:"codebase-cmd-callees"});function eo(o){let e={maxResults:10},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t.startsWith("--file="))e.file=t.slice(7);else if(t.startsWith("--kind="))e.kind=t.slice(7);else if(t.startsWith("--max=")){let i=parseInt(t.slice(6),10);Number.isFinite(i)&&i>0&&(e.maxResults=i);}else t.startsWith("-")||n.push(t);return n.length>0&&(e.symbol=n[0]),e}async function to(o){if(!o.symbol&&!o.nodeId)throw new NameErrors.MissingFieldError({field:"symbol-or-nodeId",message:"callees command requires a <symbol> or --nodeId argument"});let e=await f.getRootDir(),n=Date.now(),i=await f$2({workspaceDir:e,rootDir:e},{name:o.symbol,nodeId:o.nodeId,file:o.file,kind:o.kind,maxResults:o.maxResults});return yn.debug("callees command done",{symbol:o.symbol,count:i.callees.length,rootDir:e}),{rootDir:e,serviceResult:i,durationMs:Date.now()-n}}function oo(o){let{serviceResult:e,rootDir:n}=o,t=[],i=e.root?.name??"?",r=e.truncated?"+":"";if(t.push(`Callees of \`${i}\` (${e.callees.length}${r}) [${n}]`),e.callees.length===0)t.push(" (no outgoing edges)");else for(let l of e.callees)t.push(` - [${l.relation}] \`${l.name}\` ${l.filePath}:${l.startLine}`);return e.callees.length>0&&(t.push(""),t.push("\u{1F4A1} Use `easbot codebase node <name>` to read full source of any callee.")),t.join(`
|
|
22
|
-
`)}var wn=Log.create({service:"codebase-cmd-explore"});function no(o){let e={maxFiles:5,maxSymbols:3,depth:1,includeContent:true},n=[];for(let t of o)if(t==="--help"||t==="-h")e.help=true;else if(t==="--json")e.json=true;else if(t==="--no-content")e.includeContent=false;else if(t.startsWith("--file="))e.file=t.slice(7);else if(t.startsWith("--kind="))e.kind=t.slice(7);else if(t.startsWith("--max-files=")){let i=parseInt(t.slice(12),10);Number.isFinite(i)&&i>0&&(e.maxFiles=i);}else if(t.startsWith("--max-symbols=")){let i=parseInt(t.slice(14),10);Number.isFinite(i)&&i>0&&(e.maxSymbols=i);}else if(t.startsWith("--depth=")){let i=parseInt(t.slice(8),10);Number.isFinite(i)&&i>0&&(e.depth=i);}else t.startsWith("--intent=")?e.intent=t.slice(9):t.startsWith("-")||n.push(t);return n.length>0&&(e.query=n.join(" ")),e}async function so(o){if(!o.query)throw new NameErrors.MissingFieldError({field:"query",message:"explore command requires a <query> argument"});let e=await f.getRootDir(),n=Date.now(),i=await g({workspaceDir:e,rootDir:e},{query:o.query,file:o.file,kind:o.kind,maxFiles:o.maxFiles,maxSymbols:o.maxSymbols,depth:o.depth,includeContent:o.includeContent,intent:o.intent});return wn.debug("explore command done",{query:o.query,totalHits:i.totalHits,entryPoints:i.entryPoints.length,rootDir:e}),{rootDir:e,serviceResult:i,durationMs:Date.now()-n}}async function io(o){let e={pendingFiles:[],toolName:"codebase_explore",writeToDisk:false};return await F(o.serviceResult,e)}var ao={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var En=ao.languages,Rn=En.filter(o=>o.supported).map(o=>o.value),q={defaultLocale:"zh-CN",locales:Rn},K={},Q=(o,e)=>{let n=K[o]||{translation:{}};return K[o]={translation:{...n.translation,...e.translation}},K[o]},X=(o=q.defaultLocale)=>(K[o]||Q(o,{translation:{}}),{locale:o,resources:K[o]||{translation:{}}});var _n={translation:{"cli.banner.title":"easbot-codebase \u2014 \u4EE3\u7801\u77E5\u8BC6\u56FE\u8C31","cli.banner.usage":"\u7528\u6CD5: easbot-codebase <command> [options]","cli.banner.section.lifecycle":"\u547D\u4EE4\uFF08\u751F\u547D\u5468\u671F\uFF09:","cli.banner.section.graph":"\u547D\u4EE4\uFF08\u56FE\u67E5\u8BE2\uFF09:","cli.banner.section.external":"\u5916\u90E8\u63A5\u53E3:","cli.banner.hint.run_help":"\u8FD0\u884C `easbot codebase <command> --help` \u67E5\u770B\u8BE6\u60C5\u3002","cli.banner.local.title":"\u72EC\u7ACB CLI:","cli.banner.local.body":"\u672C\u5305\u540C\u65F6\u4F5C\u4E3A\u72EC\u7ACB CLI `easbot-codebase` \u53D1\u5E03\uFF0C\u53EF\u72EC\u7ACB\u4F7F\u7528\u3002","cli.banner.local.agent":"Agent CLI \u7528\u6237: `easbot codebase <command> ...`","cli.banner.local.standalone":"\u72EC\u7ACB\u7528\u6237: `easbot-codebase <command> ...`","cli.cmd.init.summary":"init [dir] \u5728\u76EE\u6807\u76EE\u5F55\u521D\u59CB\u5316 .easbot/codebase.json","cli.cmd.index.summary":"index [dir] \u6784\u5EFA\u5B8C\u6574\u7D22\u5F15","cli.cmd.sync.summary":"sync \u8FD0\u884C\u589E\u91CF\u540C\u6B65","cli.cmd.recreate.summary":"recreate \u4E22\u5F03\u6570\u636E\u5E93 + \u91CD\u65B0\u521D\u59CB\u5316 + \u91CD\u5EFA\u7D22\u5F15\uFF08\u4E00\u6761\u9F99\uFF09","cli.cmd.clear.summary":"clear \u6E05\u7A7A\u6240\u6709\u8282\u70B9/\u8FB9\uFF08\u4FDD\u7559 config.json\uFF09","cli.cmd.status.summary":"status \u663E\u793A\u7D22\u5F15\u72B6\u6001 / \u6570\u636E\u5E93 / \u914D\u7F6E","cli.cmd.doctor.summary":"doctor \u8FD0\u884C\u5065\u5EB7\u68C0\u67E5\uFF08\u540E\u7AEF\u53EF\u7528\u6027\u7B49\uFF09","cli.cmd.config.summary":"config \u8BFB\u53D6/\u8BBE\u7F6E .easbot/codebase.json \u5B57\u6BB5","cli.cmd.upgrade.summary":"upgrade \u5F53 extraction_version \u8FC7\u65F6\u65F6\u66F4\u65B0\u5143\u6570\u636E","cli.cmd.embed.summary":"embed \u751F\u6210\u8282\u70B9\u5D4C\u5165\u5411\u91CF","cli.cmd.watch.summary":"watch \u76D1\u542C\u5DE5\u4F5C\u533A\u6587\u4EF6\u53D8\u66F4\uFF08\u81EA\u52A8\u540C\u6B65\uFF09","cli.cmd.stop.summary":"stop \u505C\u6B62\u6B63\u5728\u8FD0\u884C\u7684\u6587\u4EF6\u76D1\u542C\u5668","cli.cmd.query.summary":"query <q...> \u6DF7\u5408\u641C\u7D22\uFF08FTS + \u5411\u91CF + \u57FA\u7840\uFF09","cli.cmd.node.summary":"node <name|id> \u663E\u793A\u5355\u4E2A\u8282\u70B9\u7684\u8BE6\u60C5","cli.cmd.context.summary":"context <id> \u6784\u5EFA\u8282\u70B9\u5468\u56F4\u7684\u5B50\u56FE\u4E0A\u4E0B\u6587","cli.cmd.impact.summary":"impact <id> \u5F71\u54CD\u534A\u5F84\uFF08BFS \u5165\u8FB9\uFF09","cli.cmd.callers.summary":"callers <sym> \u8C01\u8C03\u7528\u4E86 <symbol>","cli.cmd.callees.summary":"callees <sym> <symbol> \u8C03\u7528\u4E86\u8C01","cli.cmd.explore.summary":"explore <q> \u4E3B\u5DE5\u5177 \u2014 \u4E00\u6B21\u8C03\u7528\u8FD4\u56DE\u6E90\u7801 + \u8C03\u7528\u94FE","cli.cmd.dead_code.summary":"dead-code \u67E5\u627E\u672A\u4F7F\u7528\u7684\u7B26\u53F7","cli.cmd.circular.summary":"circular \u68C0\u6D4B\u5FAA\u73AF\u4F9D\u8D56","cli.cmd.path.summary":"path <from> <to> \u67E5\u627E\u4E24\u4E2A\u8282\u70B9\u4E4B\u95F4\u7684\u6700\u77ED\u8DEF\u5F84","cli.cmd.mcp.summary":"mcp [dir] \u542F\u52A8 stdio MCP \u670D\u52A1\u5668\uFF08\u66B4\u9732 9 \u4E2A codebase \u5DE5\u5177\uFF09","cli.cmd.init.description":"\u5728\u76EE\u6807\u76EE\u5F55\u521D\u59CB\u5316 .easbot/codebase.json","cli.cmd.index.description":"\u6784\u5EFA\u5B8C\u6574\u7D22\u5F15\uFF08\u7F3A\u5931 db \u65F6\u81EA\u52A8\u521B\u5EFA\uFF09","cli.cmd.sync.description":"\u8FD0\u884C\u589E\u91CF\u540C\u6B65\uFF08\u4EC5\u53D8\u66F4\u8FC7\u7684\u6587\u4EF6\uFF09","cli.cmd.recreate.description":"\u4E22\u5F03\u6574\u4E2A\u6570\u636E\u5E93 + \u91CD\u65B0\u521D\u59CB\u5316 + \u91CD\u5EFA\u7D22\u5F15\uFF08\u4E00\u6761\u9F99\uFF09","cli.cmd.clear.description":"\u6E05\u7A7A\u6240\u6709\u8282\u70B9/\u8FB9\uFF08\u4FDD\u7559 config.json\uFF09","cli.cmd.status.description":"\u663E\u793A\u7D22\u5F15\u72B6\u6001 / \u6570\u636E\u5E93 / \u914D\u7F6E","cli.cmd.doctor.description":"\u8FD0\u884C\u5065\u5EB7\u68C0\u67E5\uFF08\u540E\u7AEF / FTS / parser\uFF09","cli.cmd.config.description":"\u8BFB\u53D6/\u8BBE\u7F6E .easbot/codebase.json \u5B57\u6BB5","cli.cmd.upgrade.description":"extraction_version \u8FC7\u65F6\u65F6\u66F4\u65B0\u5143\u6570\u636E","cli.cmd.embed.description":"\u751F\u6210 / \u68C0\u67E5\u8282\u70B9\u5D4C\u5165\u5411\u91CF\uFF08dry-run / pending-list\uFF09","cli.cmd.watch.description":"\u76D1\u542C\u5DE5\u4F5C\u533A\u6587\u4EF6\u53D8\u66F4\uFF08\u81EA\u52A8\u540C\u6B65\uFF09","cli.cmd.stop.description":"\u505C\u6B62\u6B63\u5728\u8FD0\u884C\u7684\u6587\u4EF6\u76D1\u542C\u5668","cli.cmd.query.description":"\u6DF7\u5408\u641C\u7D22\uFF08FTS + \u5411\u91CF + \u57FA\u7840\uFF09","cli.cmd.node.description":"\u663E\u793A\u5355\u4E2A\u8282\u70B9\u7684\u8BE6\u60C5","cli.cmd.context.description":"\u6784\u5EFA\u8282\u70B9\u5468\u56F4\u7684\u5B50\u56FE\u4E0A\u4E0B\u6587","cli.cmd.impact.description":"\u5F71\u54CD\u534A\u5F84\uFF08BFS \u5165\u8FB9\uFF09","cli.cmd.callers.description":"\u8C01\u8C03\u7528\u4E86 <symbol>\uFF08\u5165\u8FB9\uFF09","cli.cmd.callees.description":"<symbol> \u8C03\u7528\u4E86\u8C01\uFF08\u51FA\u8FB9\uFF09","cli.cmd.explore.description":"\u4E3B\u5DE5\u5177 \u2014 \u4E00\u6B21\u8C03\u7528\u8FD4\u56DE\u6E90\u7801 + \u8C03\u7528\u94FE","cli.cmd.dead_code.description":"\u67E5\u627E\u672A\u4F7F\u7528\u7684\u7B26\u53F7","cli.cmd.circular.description":"\u68C0\u6D4B\u5FAA\u73AF\u4F9D\u8D56\uFF08Tarjan SCC\uFF09","cli.cmd.path.description":"\u67E5\u627E\u4E24\u4E2A\u8282\u70B9\u4E4B\u95F4\u7684\u6700\u77ED\u8DEF\u5F84","cli.cmd.mcp.description":"\u542F\u52A8 stdio MCP \u670D\u52A1\u5668\uFF08\u66B4\u9732 9 \u4E2A codebase \u5DE5\u5177\uFF09","cli.shared.show_help":"\u663E\u793A\u6B64\u5E2E\u52A9","cli.init.usage":"\u7528\u6CD5: easbot codebase init [dir] [--force]","cli.init.description":"\u5728\u76EE\u6807\u76EE\u5F55\u521D\u59CB\u5316 .easbot/codebase.json\u3002","cli.init.creates":"\u521B\u5EFA .easbot/codebase.json\uFF0C\u9ED8\u8BA4\u540E\u7AEF\u4E3A better-sqlite3\u3002","cli.init.opt.force":"--force, -f \u8986\u76D6\u5DF2\u5B58\u5728\u7684 config.json","cli.init.exists":"codebase \u914D\u7F6E\u5DF2\u5B58\u5728\u4E8E {{path}}\uFF08\u4F7F\u7528 --force \u8986\u76D6\uFF09","cli.init.created":"\u2713 codebase \u5DF2\u5728 {{path}} \u521D\u59CB\u5316","cli.status.usage":"\u7528\u6CD5: easbot codebase status [--json] [dir]","cli.doctor.usage":"\u7528\u6CD5: easbot codebase doctor [dir]","cli.index.usage":"\u7528\u6CD5: easbot codebase index [dir] [--embed] [--no-embed] [--batch=N] [--json]","cli.index.description":"\u4E3A\u76EE\u6807\u76EE\u5F55\u6784\u5EFA\u5B8C\u6574\u7D22\u5F15\u3002","cli.index.auto_init":"\u5982\u679C .easbot/codebase.json \u4E0D\u5B58\u5728\u4F1A\u81EA\u52A8\u521D\u59CB\u5316\u3002","cli.index.opt.embed":"--embed \u751F\u6210\u8282\u70B9\u5D4C\u5165\u5411\u91CF\uFF08\u9ED8\u8BA4\u8DF3\u8FC7\uFF09","cli.index.opt.no_embed":"--no-embed \u540C\u9ED8\u8BA4\uFF08\u8DF3\u8FC7\u5D4C\u5165\uFF09","cli.index.opt.batch":"--batch=N \u7D22\u5F15\u6279\u5927\u5C0F\uFF08\u9ED8\u8BA4 50\uFF09","cli.index.opt.json":"--json \u4EE5 JSON \u8F93\u51FA\uFF08\u65E0 ANSI \u989C\u8272\uFF09","cli.sync.usage":"\u7528\u6CD5: easbot codebase sync [--embed] [--no-embed] [--quiet] [--json] [dir]","cli.sync.description":"\u8FD0\u884C\u589E\u91CF\u540C\u6B65\uFF08\u4EC5\u589E/\u6539/\u5220\u53D8\u66F4\u8FC7\u7684\u6587\u4EF6\uFF09\u3002","cli.sync.auto_version":"\u6210\u529F\u65F6\u81EA\u52A8\u66F4\u65B0 meta['indexed_with_version']\u3002","cli.sync.opt.embed":"--embed \u542F\u7528\u8282\u70B9\u5D4C\u5165\u5411\u91CF\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF0C\u4EC5 FTS\uFF09","cli.sync.opt.no_embed":"--no-embed \u663E\u5F0F\u7981\u7528\u5D4C\u5165\u5411\u91CF\uFF08\u9ED8\u8BA4\uFF09","cli.sync.opt.quiet":"--quiet, -q \u4EC5\u6253\u5370\u6458\u8981","cli.sync.opt.json":"--json \u4EE5 JSON \u8F93\u51FA\uFF08\u65E0 ANSI \u989C\u8272\uFF09","cli.recreate.usage":"\u7528\u6CD5: easbot codebase recreate [--keep-config] [--no-reindex] [--no-embed] [--force] [--json] [dir]","cli.recreate.description":"\u4E22\u5F03\u6574\u4E2A\u6570\u636E\u5E93\uFF08codebase.db + -wal + -shm\uFF09\uFF0C\u91CD\u65B0\u521D\u59CB\u5316\uFF0C\u5E76\u81EA\u52A8\u91CD\u5EFA\u7D22\u5F15\u3002","cli.recreate.equivalent":"\u7B49\u4EF7\u4E8E codegraph `recreate()`\uFF0C\u7528\u4E8E\u5B89\u5168\u7684\u7D22\u5F15\u6062\u590D\u3002","cli.recreate.opt.keep_config":"--keep-config \u4FDD\u7559 .easbot/codebase.json\uFF08\u4EC5\u5220\u9664 db\uFF09","cli.recreate.opt.no_reindex":"--no-reindex \u8DF3\u8FC7\u81EA\u52A8\u91CD\u5EFA\u7D22\u5F15\u6B65\u9AA4\uFF08\u4E4B\u540E\u9700\u624B\u52A8\u8DD1 `easbot codebase index`\uFF09","cli.recreate.opt.no_embed":"--no-embed \u8F6C\u53D1\u7ED9 runIndex\uFF1A\u8DF3\u8FC7 embedding \u751F\u6210\uFF08\u66F4\u5FEB\uFF09","cli.recreate.opt.force":"--force, -f \u8DF3\u8FC7\u5B89\u5168\u786E\u8BA4\uFF08\u7528\u4E8E\u811A\u672C\uFF09","cli.recreate.opt.json":"--json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA","cli.recreate.warn":"\u26A0\uFE0F \u8FD9\u4F1A\u5220\u9664\u6574\u4E2A\u7D22\u5F15\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B `recreate` \u4F1A\u5728\u540C\u4E00\u6B21\u8C03\u7528\u4E2D\u91CD\u5EFA\u7D22\u5F15\u3002","cli.clear.usage":"\u7528\u6CD5: easbot codebase clear [--keep-embeddings] [--force] [dir]","cli.clear.description":"\u6E05\u7A7A\u6240\u6709\u8282\u70B9/\u8FB9/file_hashes\uFF1B\u4FDD\u7559 config.json \u4E0E meta\u3002","cli.clear.reset_state":'index_state \u91CD\u7F6E\u4E3A "uninitialized"\uFF0C`status` \u4F1A\u5EFA\u8BAE\u8FD0\u884C `index`\u3002',"cli.clear.opt.keep_embeddings":"--keep-embeddings \u4FDD\u7559 node_embeddings / embedding_cache","cli.clear.opt.force":"--force, -f \u8DF3\u8FC7\u5B89\u5168\u786E\u8BA4\uFF08\u7528\u4E8E\u811A\u672C\uFF09","cli.clear.opt.json":"--json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA","cli.clear.hint":"\u{1F4A1} \u5982\u679C\u60F3\u5220\u9664\u6574\u4E2A db \u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 `recreate`\u3002","cli.config.usage":"\u7528\u6CD5: easbot codebase config <get|set> [key] [value] [--json] [dir]","cli.config.description":"\u8BFB\u53D6\u6216\u5199\u5165 .easbot/codebase.json \u5B57\u6BB5\u3002","cli.config.subcommands":"\u5B50\u547D\u4EE4:","cli.config.get":"get [key] \u663E\u793A\u5168\u90E8\u5B57\u6BB5\uFF08\u6216\u67D0\u4E2A\u5B57\u6BB5\uFF09","cli.config.set":"set <key> <value> \u66F4\u65B0\u67D0\u4E2A\u5B57\u6BB5\uFF08\u5FC5\u987B\u5728\u767D\u540D\u5355\u4E2D\uFF09","cli.config.allowed_keys":"\u5141\u8BB8\u7684\u952E: backend, schema_version, extraction_version, index_state","cli.config.opt.json":"--json \u4EE5 JSON \u8F93\u51FA\uFF08\u65E0 ANSI \u989C\u8272\uFF09","cli.config.no_subcommand":"config \u9700\u8981\u5B50\u547D\u4EE4: get | set","cli.config.unknown_subcommand":"\u672A\u77E5\u7684 config \u5B50\u547D\u4EE4: {{subcommand}}","cli.upgrade.usage":"\u7528\u6CD5: easbot codebase upgrade [--schema] [--force] [dir]","cli.upgrade.description":"\u5F53 indexed_with_extraction_version \u8FC7\u65F6\u65F6\u66F4\u65B0\u5143\u6570\u636E\u3002","cli.upgrade.does_not_delete":"\u4E0D\u4F1A\u5220\u9664\u6570\u636E \u2014 \u4F7F\u7528 `recreate` \u5220\u9664\u6574\u4E2A db\u3002","cli.upgrade.opt.schema":"--schema \u540C\u65F6\u91CD\u8DD1 ensureSchema\uFF08\u5E42\u7B49\u7684 CREATE TABLE IF NOT EXISTS\uFF09","cli.upgrade.opt.force":"--force, -f \u5373\u4F7F\u672A\u8FC7\u671F\u4E5F\u66F4\u65B0\u7248\u672C","cli.embed.usage":"\u7528\u6CD5: easbot codebase embed [--all] [--dry-run|-n] [--pending-list|-p] [--batch=N] [--json] [dir]","cli.embed.description":"\u4E3A node_embeddings \u4E2D\u7F3A\u5931\u7684\u8282\u70B9\u751F\u6210\u5D4C\u5165\u5411\u91CF\u3002","cli.embed.statistical_only":"CLI \u4EC5\u505A\u7EDF\u8BA1 \u2014 \u771F\u6B63\u7684\u5D4C\u5165\u751F\u6210\u9700\u8981","cli.embed.repl_required":"\u5728\u6CE8\u5165 EmbeddingModel \u7684 `easbot` REPL \u4F1A\u8BDD\u4E2D\u5B8C\u6210\u3002","cli.embed.opt.all":"--all \u5F3A\u5236\u4E3A\u6240\u6709\u8282\u70B9\u91CD\u65B0\u751F\u6210","cli.embed.opt.dry_run":"--dry-run, -n \u4EC5\u6253\u5370\u7EDF\u8BA1\uFF08CLI \u9ED8\u8BA4\u884C\u4E3A\uFF09","cli.embed.opt.pending":"--pending-list, -p \u5217\u51FA\u5F85\u5D4C\u5165\u7684\u8282\u70B9 id","cli.embed.opt.batch":"--batch=N \u5D4C\u5165\u6279\u5927\u5C0F\uFF08\u9ED8\u8BA4 10\uFF09","cli.embed.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.embed.env.heading":"\u73AF\u5883\u53D8\u91CF:","cli.embed.env.model":"EASBOT_EMBEDDING_MODEL \u5982 openai/text-embedding-3-small","cli.query.usage":"\u7528\u6CD5: easbot codebase query <q...> [--language=<lang>] [--ast=<type>] [--max=N] [--no-edges] [--no-vector|--no-embed] [--json]","cli.query.description":"\u5BF9\u5DF2\u7D22\u5F15\u4EE3\u7801\u8282\u70B9\u505A\u6DF7\u5408\u641C\u7D22\uFF08FTS + \u5411\u91CF + \u57FA\u7840\uFF09\u3002","cli.query.aliases":"\u522B\u540D: search","cli.query.opt.language":"--language=<lang> \u6309\u8BED\u8A00\u8FC7\u6EE4\uFF08ts / js / py / go / ...\uFF09","cli.query.opt.ast":"--ast=<type> \u6309 AST \u7C7B\u578B\u8FC7\u6EE4\uFF08class_declaration / function_declaration / ...\uFF09","cli.query.opt.max":"--max=<N> \u6700\u5927\u7ED3\u679C\u6570\uFF08\u9ED8\u8BA4 20\uFF09","cli.query.opt.no_edges":"--no-edges \u7ED3\u679C\u4E2D\u4E0D\u5305\u542B\u8FB9\uFF08\u9ED8\u8BA4: \u5305\u542B\uFF09","cli.query.opt.no_vector":"--no-vector / --no-embed \u7981\u7528\u5411\u91CF\u641C\u7D22\uFF08\u4EC5 FTS + \u57FA\u7840\uFF0C\u9ED8\u8BA4: \u542F\u7528\u5411\u91CF\uFF09","cli.query.opt.json":"--json JSON \u8F93\u51FA","cli.node.usage":"\u7528\u6CD5: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json]","cli.node.description":"\u663E\u793A\u5355\u4E2A\u8282\u70B9\u7684\u8BE6\u60C5\u3002","cli.node.accepts_name":"\u63A5\u53D7\u7B26\u53F7\u540D <name>\uFF08\u5BF9 LLM \u53CB\u597D\uFF0C\u4E0E tool/MCP \u5BF9\u9F50\uFF09","cli.node.accepts_id":"\u6216\u6765\u81EA `query` / \u6570\u636E\u5E93\u7684\u539F\u59CB <node-id>\u3002","cli.node.opt.file":"--file=<path> \u540C\u540D\u7B26\u53F7\u5B58\u5728\u65F6\u7528\u4E8E\u6D88\u6B67","cli.node.opt.kind":"--kind=<kind> \u6309 AST \u7C7B\u578B\u8FC7\u6EE4/\u6D88\u6B67","cli.node.opt.edges":"--edges \u5305\u542B\u5165\u8FB9/\u51FA\u8FB9\u6C47\u603B","cli.node.opt.max":"--max=<N> \u8FB9\u6570\u91CF\u4E0A\u9650\uFF08\u9ED8\u8BA4 50\uFF09","cli.node.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.context.usage":"\u7528\u6CD5: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json]","cli.context.description":"\u6784\u5EFA\u8282\u70B9\u5468\u56F4\u7684\u5B50\u56FE\u4E0A\u4E0B\u6587\uFF08BFS \u90BB\u63A5 N \u5C42\uFF09\u3002","cli.context.opt.depth":"--depth=<N> BFS \u6DF1\u5EA6\uFF08\u9ED8\u8BA4 2\uFF09","cli.context.opt.max":"--max=<N> \u6700\u5927\u8282\u70B9\u6570\uFF08\u9ED8\u8BA4 100\uFF09","cli.context.opt.direction":"--direction=<dir> incoming | outgoing | both\uFF08\u9ED8\u8BA4 both\uFF09","cli.context.opt.relation":"--relation=<r1,r2,...> \u6309\u5173\u7CFB\u7C7B\u578B\u8FC7\u6EE4\uFF08CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / USES / REFERENCES\uFF09","cli.context.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.impact.usage":"\u7528\u6CD5: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]","cli.impact.description":"\u5F71\u54CD\u534A\u5F84: BFS \u5165\u5411 CALLS / REFERENCES / USES / IMPORTS / TYPE_REFERENCES\uFF0C\u6309\u6DF1\u5EA6\u5206\u6876\u3002","cli.impact.opt.depth":"--depth=<N> BFS \u6DF1\u5EA6\uFF08\u9ED8\u8BA4 3\uFF09","cli.impact.opt.relation":"--relation=<r1,r2,...> \u6309\u5173\u7CFB\u7C7B\u578B\u8FC7\u6EE4","cli.impact.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.callers.usage":"\u7528\u6CD5: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]","cli.callers.description":"\u8C01\u8C03\u7528\u4E86 <symbol>\uFF08\u5165\u5411 CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS\uFF09\u3002","cli.callers.accepts":"\u63A5\u53D7\u7B26\u53F7\u540D <symbol>\uFF08\u5BF9 LLM \u53CB\u597D\uFF09\u6216 --node-id \u6307\u5B9A\u539F\u59CB\u8282\u70B9 id\u3002","cli.callers.opt.node_id":"--node-id=<id> \u6765\u81EA `query` / \u6570\u636E\u5E93\u7684\u539F\u59CB\u8282\u70B9 id","cli.callers.opt.file":"--file=<path> \u6587\u4EF6\u8DEF\u5F84\u6216 basename \u7528\u4E8E\u540C\u540D\u7B26\u53F7\u6D88\u6B67","cli.callers.opt.kind":"--kind=<kind> \u6309\u8282\u70B9\u7C7B\u578B\u8FC7\u6EE4\uFF08class_declaration / function_declaration / ...\uFF09","cli.callers.opt.max":"--max=<N> \u6700\u5927\u8C03\u7528\u8005\u6570\uFF08\u9ED8\u8BA4 20\uFF09","cli.callers.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.callees.usage":"\u7528\u6CD5: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]","cli.callees.description":"<symbol> \u8C03\u7528\u4E86\u8C01\uFF08\u51FA\u5411\u8FB9\uFF09\u3002","cli.callees.accepts":"\u63A5\u53D7\u7B26\u53F7\u540D <symbol>\uFF08\u5BF9 LLM \u53CB\u597D\uFF09\u6216 --node-id \u6307\u5B9A\u539F\u59CB\u8282\u70B9 id\u3002","cli.callees.opt.node_id":"--node-id=<id> \u6765\u81EA `query` / \u6570\u636E\u5E93\u7684\u539F\u59CB\u8282\u70B9 id","cli.callees.opt.file":"--file=<path> \u6587\u4EF6\u8DEF\u5F84\u6216 basename \u7528\u4E8E\u6D88\u6B67","cli.callees.opt.kind":"--kind=<kind> \u6309\u8282\u70B9\u7C7B\u578B\u8FC7\u6EE4","cli.callees.opt.max":"--max=<N> \u6700\u5927\u88AB\u8C03\u7528\u6570\uFF08\u9ED8\u8BA4 20\uFF09","cli.callees.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.explore.usage":"\u7528\u6CD5: easbot codebase explore <query> [--file=<path>] [--kind=<kind>] [--max-files=N] [--max-symbols=N] [--depth=N] [--no-content] [--intent=<ctx>] [--json]","cli.explore.description":"\u4E3B\u5DE5\u5177 \u2014 \u5355\u6B21\u8C03\u7528\u8FD4\u56DE\u6E90\u7801 + \u8C03\u7528\u94FE\u3002","cli.explore.query_help":"<query> \u53EF\u4EE5\u662F\u7B26\u53F7\u540D\u6216\u81EA\u7136\u8BED\u8A00\u3002","cli.explore.opt.file":"--file=<path> \u6587\u4EF6\u8DEF\u5F84\u6216 basename \u7528\u4E8E\u6D88\u6B67","cli.explore.opt.kind":"--kind=<kind> \u6309\u8282\u70B9\u7C7B\u578B\u8FC7\u6EE4","cli.explore.opt.max_files":"--max-files=<N> \u6700\u5927\u5165\u53E3\u6587\u4EF6\u6570\uFF08\u9ED8\u8BA4 5\uFF09","cli.explore.opt.max_symbols":"--max-symbols=<N> \u6BCF\u6587\u4EF6\u6700\u5927\u7B26\u53F7\u6570\uFF08\u9ED8\u8BA4 3\uFF09","cli.explore.opt.depth":"--depth=<N> \u8C03\u7528\u94FE\u7684\u90BB\u63A5\u6DF1\u5EA6\uFF08\u9ED8\u8BA4 1\uFF09","cli.explore.opt.no_content":"--no-content \u4E0D\u5305\u542B\u6E90\u7801\uFF08\u4EC5\u4F4D\u7F6E\uFF0C\u9ED8\u8BA4: \u5305\u542B\uFF09","cli.explore.opt.intent":"--intent=<ctx> \u7528\u4E8E\u6392\u5E8F\u7684 LLM \u4E0A\u4E0B\u6587\u4E32","cli.explore.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.dead_code.usage":"\u7528\u6CD5: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json]","cli.dead_code.description":"\u67E5\u627E\u65E0\u5165\u8FB9\u7684\u8282\u70B9\uFF08\u542F\u53D1\u5F0F\u6B7B\u4EE3\u7801\uFF09\u3002","cli.dead_code.opt.type":"--type=<t1,t2,...> \u4EC5\u8003\u8651\u8FD9\u4E9B AST \u7C7B\u578B","cli.dead_code.opt.no_exclude_entry":"--no-exclude-entry \u5305\u542B\u5165\u53E3\u6587\u4EF6\uFF08\u9ED8\u8BA4: \u6392\u9664\uFF09","cli.dead_code.opt.limit":"--limit=<N> \u6700\u5927\u7ED3\u679C\u6570\uFF08\u9ED8\u8BA4 100\uFF09","cli.dead_code.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.circular.usage":"\u7528\u6CD5: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json]","cli.circular.description":"\u901A\u8FC7 Tarjan SCC \u68C0\u6D4B\u5FAA\u73AF\u4F9D\u8D56\u3002","cli.circular.opt.relation":"--relation=<r> \u8DDF\u968F\u7684\u5173\u7CFB\u7C7B\u578B\uFF08\u9ED8\u8BA4 IMPORTS\uFF09","cli.circular.opt.scope":"--scope=<scope> file | module\uFF08\u9ED8\u8BA4 file\uFF09","cli.circular.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.path.usage":"\u7528\u6CD5: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]","cli.path.description":"\u67E5\u627E\u4E24\u4E2A\u8282\u70B9\u4E4B\u95F4\u7684\u6700\u77ED\u8DEF\u5F84\uFF08\u6CBF CALLS / IMPORTS / TYPE_REFERENCES / USES / REFERENCES \u505A BFS\uFF09\u3002","cli.path.opt.depth":"--depth=<N> BFS \u6DF1\u5EA6\u4E0A\u9650\uFF08\u9ED8\u8BA4 6\uFF09","cli.path.opt.relation":"--relation=<r1,r2,...> \u6309\u5173\u7CFB\u7C7B\u578B\u8FC7\u6EE4","cli.path.opt.json":"--json \u4EE5 JSON \u8F93\u51FA","cli.mcp.usage":"\u7528\u6CD5: easbot codebase mcp [dir]","cli.mcp.description":"\u542F\u52A8 stdio MCP \u670D\u52A1\u5668\uFF0C\u66B4\u9732 9 \u4E2A codebase \u5DE5\u5177:","cli.mcp.tools.1":" query / node / context / impact","cli.mcp.tools.2":" callers / callees / explore","cli.mcp.tools.3":" status / doctor","cli.mcp.transport":"\u901A\u8FC7 stdio JSON-RPC \u4ECE MCP \u5BA2\u6237\u7AEF\u8FDE\u63A5\u3002","cli.watch.usage":"\u7528\u6CD5: easbot codebase watch [--debounce=N] [--interval=N] [dir]","cli.watch.description":"\u76D1\u542C\u5DE5\u4F5C\u533A\u76EE\u5F55\u7684\u6587\u4EF6\u53D8\u66F4\u5E76\u8BB0\u5F55\u4E8B\u4EF6\u3002","cli.watch.pid_file":"\u5728 .easbot/.watcher.pid \u5199\u5165 pid \u6587\u4EF6\uFF0C\u4F9B\u540E\u7EED `stop` \u4F7F\u7528\u3002","cli.watch.opt.debounce":"--debounce=N \u5355\u8DEF\u5F84\u9632\u6296\uFF08\u6BEB\u79D2\uFF0C\u9ED8\u8BA4 200\uFF09","cli.watch.opt.interval":"--interval=N \u8F6E\u8BE2\u95F4\u9694\uFF08\u6BEB\u79D2\uFF0C\u9ED8\u8BA4 500\uFF09","cli.watch.note":"\u6CE8\u610F: \u8BE5\u547D\u4EE4\u4F1A\u963B\u585E\u3002\u6309 Ctrl+C \u9000\u51FA\u3002","cli.stop.usage":"\u7528\u6CD5: easbot codebase stop [dir]","cli.stop.description":"\u505C\u6B62\u7531 .easbot/.watcher.pid \u6807\u8BC6\u7684\u8FD0\u884C\u4E2D\u76D1\u542C\u5668\u3002","cli.stop.opt.force":"--force, -f \u5FFD\u7565\u9519\u8BEF\u5E76\u5F3A\u5236\u6E05\u7406 pid \u6587\u4EF6","cli.shared.options_heading":"\u9009\u9879:","cli.shared.subcommands_heading":"\u5B50\u547D\u4EE4:","cli.shared.environment_heading":"\u73AF\u5883\u53D8\u91CF:","cli.unknown_command":"\u672A\u77E5\u547D\u4EE4: {{command}}","cli.help_hint":"\u8FD0\u884C `easbot codebase --help` \u67E5\u770B\u53EF\u7528\u547D\u4EE4\u3002","cli.signal_cleanup":"[codebase] \u6536\u5230 {{signal}}\uFF0C\u6B63\u5728\u6E05\u7406...","cli.command_failed":"codebase {{command}} \u6267\u884C\u5931\u8D25: {{message}}"}},ro=_n;var kn={translation:{"cli.banner.title":"easbot-codebase \u2014 code knowledge graph ecosystem","cli.banner.usage":"Usage: easbot-codebase <command> [options]","cli.banner.section.lifecycle":"Commands (lifecycle):","cli.banner.section.graph":"Commands (graph query):","cli.banner.section.external":"External:","cli.banner.hint.run_help":"Run `easbot codebase <command> --help` for details.","cli.banner.local.title":"Local CLI:","cli.banner.local.body":"This package is also published as `easbot-codebase` for standalone use.","cli.banner.local.agent":"Agent CLI users: `easbot codebase <command> ...`","cli.banner.local.standalone":"Standalone users: `easbot-codebase <command> ...`","cli.cmd.init.summary":"init [dir] Initialize .easbot/codebase.json in the target directory","cli.cmd.index.summary":"index [dir] Build the full index","cli.cmd.sync.summary":"sync Run incremental sync","cli.cmd.recreate.summary":"recreate Drop db, re-init, rebuild index in one step","cli.cmd.clear.summary":"clear Clear all nodes/edges (keep config.json)","cli.cmd.status.summary":"status Show index state / db / config","cli.cmd.doctor.summary":"doctor Run health checks (backend availability, etc.)","cli.cmd.config.summary":"config Get/set .easbot/codebase.json fields","cli.cmd.upgrade.summary":"upgrade Update extraction_version metadata when stale","cli.cmd.embed.summary":"embed Generate node embeddings","cli.cmd.watch.summary":"watch Watch workspace for file changes (auto-sync)","cli.cmd.stop.summary":"stop Stop a running file watcher","cli.cmd.query.summary":"query <q...> Hybrid search (FTS + vector + basic)","cli.cmd.node.summary":"node <name|id> Show details for a single node","cli.cmd.context.summary":"context <id> Build sub-graph context around a node","cli.cmd.impact.summary":"impact <id> Blast radius (BFS incoming edges)","cli.cmd.callers.summary":"callers <sym> Flat list of who calls <symbol>","cli.cmd.callees.summary":"callees <sym> Flat list of what <symbol> calls","cli.cmd.explore.summary":"explore <q> PRIMARY tool \u2014 source code + caller/callee trail in one call","cli.cmd.dead_code.summary":"dead-code Find unused symbols","cli.cmd.circular.summary":"circular Detect circular dependencies","cli.cmd.path.summary":"path <from> <to> Find shortest path between two nodes","cli.cmd.mcp.summary":"mcp [dir] Start stdio MCP server (exposes 9 codebase tools)","cli.cmd.init.description":"Initialize .easbot/codebase.json in the target directory","cli.cmd.index.description":"Build the full index (creates db if missing)","cli.cmd.sync.description":"Run incremental sync (only changed files)","cli.cmd.recreate.description":"Discard the entire db and re-init","cli.cmd.clear.description":"Clear all nodes/edges (keep config.json)","cli.cmd.status.description":"Show index state / db / config","cli.cmd.doctor.description":"Run health checks (backend, FTS, parser)","cli.cmd.config.description":"Get/set .easbot/codebase.json fields","cli.cmd.upgrade.description":"Update extraction_version metadata when stale","cli.cmd.embed.description":"Generate / inspect node embeddings (dry-run / pending-list)","cli.cmd.watch.description":"Watch workspace for file changes (auto-sync)","cli.cmd.stop.description":"Stop a running file watcher","cli.cmd.query.description":"Hybrid search (FTS + vector + basic)","cli.cmd.node.description":"Show details for a single node","cli.cmd.context.description":"Build sub-graph context around a node","cli.cmd.impact.description":"Blast radius (BFS incoming edges)","cli.cmd.callers.description":"Flat list of who calls <symbol> (incoming edges)","cli.cmd.callees.description":"Flat list of what <symbol> calls (outgoing edges)","cli.cmd.explore.description":"PRIMARY tool \u2014 source code + caller/callee trail in one call","cli.cmd.dead_code.description":"Find unused symbols","cli.cmd.circular.description":"Detect circular dependencies (Tarjan SCC)","cli.cmd.path.description":"Find shortest path between two nodes","cli.cmd.mcp.description":"Start stdio MCP server (exposes 9 codebase tools)","cli.shared.show_help":"Show this help","cli.init.usage":"Usage: easbot codebase init [dir] [--force]","cli.init.description":"Initialize .easbot/codebase.json in the target directory.","cli.init.creates":"Creates .easbot/codebase.json with default backend = better-sqlite3.","cli.init.opt.force":"--force, -f Overwrite existing config.json","cli.init.exists":"codebase config already exists at {{path}} (use --force to overwrite)","cli.init.created":"\u2713 codebase initialized at {{path}}","cli.status.usage":"Usage: easbot codebase status [--json] [dir]","cli.doctor.usage":"Usage: easbot codebase doctor [dir]","cli.index.usage":"Usage: easbot codebase index [dir] [--embed] [--no-embed] [--batch=N] [--json]","cli.index.description":"Build the full index for the target directory.","cli.index.auto_init":"Auto-initializes .easbot/codebase.json if it does not exist.","cli.index.opt.embed":"--embed Generate node embeddings (default: skip)","cli.index.opt.no_embed":"--no-embed Same as default (skip embedding)","cli.index.opt.batch":"--batch=N Batch size for indexing (default 50)","cli.index.opt.json":"--json Output as JSON (no ANSI)","cli.sync.usage":"Usage: easbot codebase sync [--embed] [--no-embed] [--quiet] [--json] [dir]","cli.sync.description":"Run incremental sync (only adds/updates/deletes changed files).","cli.sync.auto_version":"Auto-updates meta['indexed_with_version'] on success.","cli.sync.opt.embed":"--embed Enable node embeddings (default off, FTS-only)","cli.sync.opt.no_embed":"--no-embed Explicitly disable embeddings (default)","cli.sync.opt.quiet":"--quiet, -q Only print summary","cli.sync.opt.json":"--json Output as JSON (no ANSI)","cli.recreate.usage":"Usage: easbot codebase recreate [--keep-config] [--no-reindex] [--no-embed] [--force] [--json] [dir]","cli.recreate.description":"Discard the entire db (codebase.db + -wal + -shm), re-init, and rebuild the index in one step.","cli.recreate.equivalent":"Equivalent to codegraph `recreate()` for safe index recovery.","cli.recreate.opt.keep_config":"--keep-config Keep .easbot/codebase.json (only drop db)","cli.recreate.opt.no_reindex":"--no-reindex Skip the auto rebuild-index step (manual `easbot codebase index` required after)","cli.recreate.opt.no_embed":"--no-embed Forward to runIndex: skip embedding generation (faster)","cli.recreate.opt.force":"--force, -f Skip safety prompts (for scripts)","cli.recreate.opt.json":"--json Output as JSON","cli.recreate.warn":"\u26A0\uFE0F This deletes the entire index. By default `recreate` also rebuilds the index in the same call.","cli.clear.usage":"Usage: easbot codebase clear [--keep-embeddings] [--force] [dir]","cli.clear.description":"Clear all nodes/edges/file_hashes; keep config.json and meta.","cli.clear.reset_state":'index_state is reset to "uninitialized" so `status` recommends `index`.',"cli.clear.opt.keep_embeddings":"--keep-embeddings Preserve node_embeddings / embedding_cache","cli.clear.opt.force":"--force, -f Skip safety prompts (for scripts)","cli.clear.opt.json":"--json Output as JSON","cli.clear.hint":"\u{1F4A1} Use `recreate` if you want to drop the entire db file.","cli.config.usage":"Usage: easbot codebase config <get|set> [key] [value] [--json] [dir]","cli.config.description":"Read or write .easbot/codebase.json fields.","cli.config.subcommands":"Subcommands:","cli.config.get":"get [key] Show all fields (or a specific key)","cli.config.set":"set <key> <value> Update a field (must be in allowlist)","cli.config.allowed_keys":"Allowed keys: backend, schema_version, extraction_version, index_state","cli.config.opt.json":"--json Output as JSON (no ANSI)","cli.config.no_subcommand":"config requires a subcommand: get | set","cli.config.unknown_subcommand":"Unknown config subcommand: {{subcommand}}","cli.upgrade.usage":"Usage: easbot codebase upgrade [--schema] [--force] [dir]","cli.upgrade.description":"Update indexed_with_extraction_version metadata when stale.","cli.upgrade.does_not_delete":"Does NOT delete data \u2014 use `recreate` to drop the db entirely.","cli.upgrade.opt.schema":"--schema Also re-run ensureSchema (idempotent CREATE TABLE IF NOT EXISTS)","cli.upgrade.opt.force":"--force, -f Update version even when not stale","cli.embed.usage":"Usage: easbot codebase embed [--all] [--dry-run|-n] [--pending-list|-p] [--batch=N] [--json] [dir]","cli.embed.description":"Generate node embeddings for nodes missing from node_embeddings.","cli.embed.statistical_only":"CLI is statistical-only \u2014 actual embedding generation requires","cli.embed.repl_required":"an `easbot` REPL session with an injected EmbeddingModel.","cli.embed.opt.all":"--all Force regenerate for all nodes","cli.embed.opt.dry_run":"--dry-run, -n Print statistics only (default behavior in CLI)","cli.embed.opt.pending":"--pending-list, -p List node ids that are pending embedding","cli.embed.opt.batch":"--batch=N Embedding batch size (default 10)","cli.embed.opt.json":"--json Output as JSON","cli.embed.env.heading":"Environment:","cli.embed.env.model":"EASBOT_EMBEDDING_MODEL e.g. openai/text-embedding-3-small","cli.query.usage":"Usage: easbot codebase query <q...> [--language=<lang>] [--ast=<type>] [--max=N] [--no-edges] [--no-vector|--no-embed] [--json]","cli.query.description":"Hybrid search (FTS + vector + basic) over indexed code nodes.","cli.query.aliases":"Aliases: search","cli.query.opt.language":"--language=<lang> Filter by language (ts / js / py / go / ...)","cli.query.opt.ast":"--ast=<type> Filter by AST type (class_declaration / function_declaration / ...)","cli.query.opt.max":"--max=<N> Max results (default 20)","cli.query.opt.no_edges":"--no-edges Do not include edges in results (default: include)","cli.query.opt.no_vector":"--no-vector / --no-embed Disable vector search (FTS + basic only, default: vector on)","cli.query.opt.json":"--json JSON output","cli.node.usage":"Usage: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json]","cli.node.description":"Show details for a single node.","cli.node.accepts_name":"Accepts a symbol <name> (LLM workflow friendly, tool/MCP-aligned)","cli.node.accepts_id":"or a raw <node-id> from `query` / database.","cli.node.opt.file":"--file=<path> Disambiguate when same-named symbols exist","cli.node.opt.kind":"--kind=<kind> Filter / disambiguate by AST kind","cli.node.opt.edges":"--edges Include incoming / outgoing edge summaries","cli.node.opt.max":"--max=<N> Edge limit (default 50)","cli.node.opt.json":"--json Output as JSON","cli.context.usage":"Usage: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json]","cli.context.description":"Build a sub-graph context around a node (BFS to N-level neighbors).","cli.context.opt.depth":"--depth=<N> BFS depth (default 2)","cli.context.opt.max":"--max=<N> Max nodes (default 100)","cli.context.opt.direction":"--direction=<dir> incoming | outgoing | both (default both)","cli.context.opt.relation":"--relation=<r1,r2,...> Filter by relation types (CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / USES / REFERENCES)","cli.context.opt.json":"--json Output as JSON","cli.impact.usage":"Usage: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]","cli.impact.description":"Blast radius: BFS incoming CALLS / REFERENCES / USES / IMPORTS / TYPE_REFERENCES, bucketed by depth.","cli.impact.opt.depth":"--depth=<N> BFS depth (default 3)","cli.impact.opt.relation":"--relation=<r1,r2,...> Filter by relation types","cli.impact.opt.json":"--json Output as JSON","cli.callers.usage":"Usage: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]","cli.callers.description":"Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).","cli.callers.accepts":"Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.","cli.callers.opt.node_id":"--node-id=<id> Raw node id from `query` / database","cli.callers.opt.file":"--file=<path> File path or basename to disambiguate when same-named symbols exist","cli.callers.opt.kind":"--kind=<kind> Filter by node kind (class_declaration / function_declaration / ...)","cli.callers.opt.max":"--max=<N> Max callers (default 20)","cli.callers.opt.json":"--json Output as JSON","cli.callees.usage":"Usage: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]","cli.callees.description":"Flat list of what <symbol> calls (outgoing edges).","cli.callees.accepts":"Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.","cli.callees.opt.node_id":"--node-id=<id> Raw node id from `query` / database","cli.callees.opt.file":"--file=<path> File path or basename to disambiguate","cli.callees.opt.kind":"--kind=<kind> Filter by node kind","cli.callees.opt.max":"--max=<N> Max callees (default 20)","cli.callees.opt.json":"--json Output as JSON","cli.explore.usage":"Usage: easbot codebase explore <query> [--file=<path>] [--kind=<kind>] [--max-files=N] [--max-symbols=N] [--depth=N] [--no-content] [--intent=<ctx>] [--json]","cli.explore.description":"PRIMARY tool \u2014 single call to get source code + caller/callee trail.","cli.explore.query_help":"<query> can be a symbol name or natural language.","cli.explore.opt.file":"--file=<path> File path or basename to disambiguate","cli.explore.opt.kind":"--kind=<kind> Filter by node kind","cli.explore.opt.max_files":"--max-files=<N> Max entry-point files (default 5)","cli.explore.opt.max_symbols":"--max-symbols=<N> Max symbols per file (default 3)","cli.explore.opt.depth":"--depth=<N> Neighbor depth for caller/callee trail (default 1)","cli.explore.opt.no_content":"--no-content Do not include source code (locations only, default: include)","cli.explore.opt.intent":"--intent=<ctx> LLM context string for ranking","cli.explore.opt.json":"--json Output as JSON","cli.dead_code.usage":"Usage: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json]","cli.dead_code.description":"Find nodes with no incoming edges (heuristic dead code).","cli.dead_code.opt.type":"--type=<t1,t2,...> Only consider these AST types","cli.dead_code.opt.no_exclude_entry":"--no-exclude-entry Include entry-point files (default: exclude)","cli.dead_code.opt.limit":"--limit=<N> Max results (default 100)","cli.dead_code.opt.json":"--json Output as JSON","cli.circular.usage":"Usage: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json]","cli.circular.description":"Detect circular dependencies via Tarjan SCC.","cli.circular.opt.relation":"--relation=<r> Relation type to follow (default IMPORTS)","cli.circular.opt.scope":"--scope=<scope> file | module (default file)","cli.circular.opt.json":"--json Output as JSON","cli.path.usage":"Usage: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]","cli.path.description":"Find shortest path between two nodes (BFS along CALLS / IMPORTS / TYPE_REFERENCES / USES / REFERENCES).","cli.path.opt.depth":"--depth=<N> BFS depth limit (default 6)","cli.path.opt.relation":"--relation=<r1,r2,...> Filter by relation types","cli.path.opt.json":"--json Output as JSON","cli.mcp.usage":"Usage: easbot codebase mcp [dir]","cli.mcp.description":"Start a stdio MCP server exposing 9 codebase tools:","cli.mcp.tools.1":" query / node / context / impact","cli.mcp.tools.2":" callers / callees / explore","cli.mcp.tools.3":" status / doctor","cli.mcp.transport":"Connect from MCP clients via stdio JSON-RPC.","cli.watch.usage":"Usage: easbot codebase watch [--debounce=N] [--interval=N] [dir]","cli.watch.description":"Watch the workspace directory for file changes and log events.","cli.watch.pid_file":"Writes a pid file at .easbot/.watcher.pid for subsequent `stop`.","cli.watch.opt.debounce":"--debounce=N Per-path debounce in ms (default 200)","cli.watch.opt.interval":"--interval=N Polling interval in ms (default 500)","cli.watch.note":"NOTE: This command blocks. Press Ctrl+C to exit.","cli.stop.usage":"Usage: easbot codebase stop [dir]","cli.stop.description":"Stop a running watcher identified by .easbot/.watcher.pid.","cli.stop.opt.force":"--force, -f Ignore errors and clear the pid file anyway","cli.shared.options_heading":"Options:","cli.shared.subcommands_heading":"Subcommands:","cli.shared.environment_heading":"Environment:","cli.unknown_command":"Unknown command: {{command}}","cli.help_hint":"Run `easbot codebase --help` for available commands.","cli.signal_cleanup":"[codebase] received {{signal}}, cleaning up...","cli.command_failed":"codebase {{command}} failed: {{message}}"}},co=kn;var Nn=()=>{X("zh-CN"),X("en-US"),Q("zh-CN",ro),Q("en-US",co);};Nn();var re=new Map;var ce=new Map;var Dn=o=>{if(ce.has(o))return ce.get(o);let e=/{{\s*(\w+)\s*}}/g,n=[],t;for(;(t=e.exec(o))!==null;){let l=t[1];l&&!n.includes(l)&&n.push(l);}let i=new RegExp("{{\\s*("+n.join("|")+")\\s*}}","g"),r={keys:n,regex:i};return ce.set(o,r),r},lo=(o,e)=>{if(!o||typeof o!="string")return "";if(!e||Object.keys(e).length===0)return o;let{regex:n,keys:t}=Dn(o);return t.length===0||!t.some(r=>r in e)?o:o.replace(n,(r,l)=>{let s=e[l];return s==null?"":String(s)})},vn=o=>{if(o&&q.locales.includes(o))return o;let e=process.env.EASBOT_LANG?.trim()||process.env.LANG?.trim();if(e){let n=e.replace(/_/g,"-");if(q.locales.includes(n))return n;let t=n.split("-")[0];if(t==="zh")return "zh-CN";if(t==="en")return "en-US"}return q.defaultLocale},po=o=>{if(!re.has(o)){let{resources:e}=X(o);re.set(o,e);}return re.get(o)},In=(o,e={})=>{let n=vn(e.locale),i=po(n)?.translation[o];if(i&&typeof i=="string"){let r=lo(i,e.vars);return r!=null?String(r):String(o)}if(n!==q.defaultLocale){let l=po(q.defaultLocale)?.translation[o];if(l&&typeof l=="string"){let s=lo(l,e.vars);return s!=null?String(s):String(o)}}return String(e.fallback??o)},le=In;var de=Log.create({service:"codebase-cli"});async function Ln(o){try{let{bootstrapLlm:e}=await import('@easbot/llm'),{Llm:n}=await import('./llm-U57HNTZO.mjs');await e({target:n,cwd:o,subConfigPath:".easbot/codebase.json",embedding:!1,graph:!1});}catch(e){let{errorMeta:n}=await import('@easbot/utils');de.warn("bootstrapLlm failed; Llm-related features will be disabled",{error:n(e)});}}function pe(o){return resolveLocaleLang(o?.locale)}function go(o){let e=(t,i,r)=>le(t,{locale:o,vars:r,fallback:i}),n=(t,i,r)=>{let l=An.filter(s=>s.group===t).map(s=>` ${qn(s.name)}${e(s.i18nKey,s.description)}`).join(`
|
|
23
|
-
`);return `${e(i,r)}
|
|
24
|
-
${l}`};return `
|
|
25
|
-
\x1B[1m${e("cli.banner.title","easbot-codebase \u2014 Code Knowledge Graph for EASBot")}\x1B[0m
|
|
26
|
-
|
|
27
|
-
${e("cli.banner.usage","Usage: easbot-codebase <command> [options]")}
|
|
28
|
-
|
|
29
|
-
${n("lifecycle","cli.banner.section.lifecycle","Commands (lifecycle):")}
|
|
30
|
-
|
|
31
|
-
${n("graph","cli.banner.section.graph","Commands (graph query):")}
|
|
32
|
-
|
|
33
|
-
${n("external","cli.banner.section.external","External:")}
|
|
34
|
-
|
|
35
|
-
Run \x1B[1measbot codebase <command> --help\x1B[0m for details.
|
|
36
|
-
|
|
37
|
-
\x1B[1m${e("cli.banner.local.title","Local CLI:")}\x1B[0m
|
|
38
|
-
${e("cli.banner.local.body","This package is also published as `easbot-codebase` for standalone use.")}
|
|
39
|
-
${e("cli.banner.local.agent","Agent CLI users: `easbot codebase <command> ...`")}
|
|
40
|
-
${e("cli.banner.local.standalone","Standalone users: `easbot-codebase <command> ...`")}
|
|
41
|
-
|
|
42
|
-
\x1B[2m$\x1B[0m easbot-codebase init ${e("cli.cmd.init.description","Initialize .easbot/codebase.json in the target directory")}
|
|
43
|
-
\x1B[2m$\x1B[0m easbot-codebase index ${e("cli.cmd.index.description","Build the full index (creates db if missing)")}
|
|
44
|
-
\x1B[2m$\x1B[0m easbot-codebase status ${e("cli.cmd.status.description","Show index state / db / config")}
|
|
45
|
-
\x1B[2m$\x1B[0m easbot-codebase query <q...> ${e("cli.cmd.query.description","Hybrid search (FTS + vector + basic)")}
|
|
46
|
-
\x1B[2m$\x1B[0m easbot-codebase --help ${e("cli.shared.show_help","Show this help")}
|
|
47
|
-
`}function Mn(o){let e=pe(o);console.log(go(e));}function Br(o){let e=pe(o);console.log(go(e));}var An=[{i18nKey:"cli.cmd.init.description",name:"init [dir]",description:"Initialize .easbot/codebase.json in the target directory",group:"lifecycle"},{i18nKey:"cli.cmd.index.description",name:"index",description:"Build the full index (creates db if missing)",group:"lifecycle"},{i18nKey:"cli.cmd.sync.description",name:"sync",description:"Run incremental sync (only changed files)",group:"lifecycle"},{i18nKey:"cli.cmd.recreate.description",name:"recreate",description:"Drop db, re-init, and rebuild the index in one step",group:"lifecycle"},{i18nKey:"cli.cmd.clear.description",name:"clear",description:"Clear all nodes/edges (keep config.json)",group:"lifecycle"},{i18nKey:"cli.cmd.status.description",name:"status",description:"Show index state / db / config",group:"lifecycle"},{i18nKey:"cli.cmd.doctor.description",name:"doctor",description:"Run health checks (backend, FTS, parser)",group:"lifecycle"},{i18nKey:"cli.cmd.config.description",name:"config",description:"Get/set .easbot/codebase.json fields",group:"lifecycle"},{i18nKey:"cli.cmd.upgrade.description",name:"upgrade",description:"Update extraction_version metadata when stale",group:"lifecycle"},{i18nKey:"cli.cmd.embed.description",name:"embed-status",description:"Inspect node embeddings (statistical only \u2014 counts/pending-list). Use MCP `embed` tool to actually generate embeddings.",group:"lifecycle"},{i18nKey:"cli.cmd.watch.description",name:"watch",description:"Watch workspace for file changes (auto-sync)",group:"lifecycle"},{i18nKey:"cli.cmd.stop.description",name:"stop",description:"Stop a running file watcher",group:"lifecycle"},{i18nKey:"cli.cmd.query.description",name:"query <q...>",description:"Hybrid search (FTS + vector + basic)",group:"graph"},{i18nKey:"cli.cmd.node.description",name:"node <name|id>",description:"Show details for a single node",group:"graph"},{i18nKey:"cli.cmd.context.description",name:"context <id>",description:"Build sub-graph context around a node",group:"graph"},{i18nKey:"cli.cmd.impact.description",name:"impact <id>",description:"Blast radius (BFS incoming edges)",group:"graph"},{i18nKey:"cli.cmd.callers.description",name:"callers <symbol>",description:"Flat list of who calls <symbol> (incoming edges)",group:"graph"},{i18nKey:"cli.cmd.callees.description",name:"callees <symbol>",description:"Flat list of what <symbol> calls (outgoing edges)",group:"graph"},{i18nKey:"cli.cmd.explore.description",name:"explore <query>",description:"PRIMARY tool \u2014 source code + caller/callee trail in one call",group:"graph"},{i18nKey:"cli.cmd.dead_code.description",name:"dead-code",description:"Find unused symbols",group:"graph"},{i18nKey:"cli.cmd.circular.description",name:"circular",description:"Detect circular dependencies (Tarjan SCC)",group:"graph"},{i18nKey:"cli.cmd.path.description",name:"path <from> <to>",description:"Find shortest path between two nodes",group:"graph"},{i18nKey:"cli.cmd.mcp.description",name:"mcp",description:"Start stdio MCP server (exposes 9 codebase tools)",group:"external"}];function qn(o){return o.length>=18?o:o+" ".repeat(18-o.length)}var mo=false;function Un(){if(mo)return;mo=true;let o=false,e=n=>{o||(o=true,console.error(`
|
|
48
|
-
[codebase] received ${n}, cleaning up...`),setTimeout(()=>process.exit(130),5e3));};process.on("SIGINT",e),process.on("SIGTERM",e);}async function Jr(o,e){Un();let n=pe(e),t=(s,a,p)=>le(s,{locale:n,vars:p,fallback:a});if(await Ln(e?.cwd??process.cwd()),o.length===0)return Mn(e),{code:0,handled:false};let i=o[0],r=o.slice(1),l=r.includes("--json");try{switch(i){case "init":{let s=Oe(r);if(s.help)return console.log(t("cli.init.usage","Usage: easbot codebase init [dir] [--force] [--json]")),console.log(""),console.log(t("cli.init.description","Initialize .easbot/codebase.json in the target directory.")),console.log(t("cli.init.creates","Creates .easbot/codebase.json with default backend = better-sqlite3.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.init.opt.force","--force, -f Overwrite existing config.json")}`),console.log(` ${t("cli.init.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:i};let a=await D({...s,skipAutoSync:!1});if(s.json){let{business:c,meta:m}=a.skipped?{business:{configPath:a.configPath,backend:a.backend,schemaVersion:a.schemaVersion,created:a.created,skipped:a.skipped},meta:{action:"exists"}}:{business:{configPath:a.configPath,backend:a.backend,schemaVersion:a.schemaVersion,created:a.created,skipped:a.skipped,initialSync:a.initialSync},meta:{action:"created"}};return emitJsonOk(c,m),{code:0,handled:!0,command:i}}let p={dbPath:a.dbPath};return typeof a.migrationsApplied=="number"&&(p.migrationsApplied=a.migrationsApplied),typeof a.tablesCreated=="number"&&(p.tablesCreated=a.tablesCreated),typeof a.durationMs=="number"&&(p.durationMs=`${a.durationMs}ms`),printHuman([formatKnowledgeInit({packageName:"codebase",configPath:a.configPath,backend:a.backend,schemaVersion:a.schemaVersion,skipped:a.skipped===!0,extras:p})],{title:"init codebase workspace",boxed:!0,skipOutro:a.skipped===!0}),{code:0,handled:!0,command:i}}case "status":{let s=Bn(r),a=await V(s);return s.json?emitJsonOk(a,{healthy:a.healthy}):printHuman([formatKnowledgeStatus(zn(a))],{title:t("cli.cmd.status.description","Show index state / db / config"),boxed:!0}),{code:0,handled:!0,command:i}}case "doctor":{let s=Jn(r);if(s.help)return console.log(t("cli.doctor.usage","Usage: easbot codebase doctor [--json]")),console.log(""),console.log(t("cli.doctor.description","Run health checks (backend, FTS, parser, db integrity).")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.doctor.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:i};let a=await Te(s);return s.json?emitJsonOk(a,{healthy:a.healthy,checkCount:a.checks.length,issueCount:a.issues.length,errorCount:a.checks.filter(p=>p.severity==="error").length,warnCount:a.checks.filter(p=>p.severity==="warn").length}):printHuman([formatKnowledgeDoctor(Wn(a))],{title:t("cli.cmd.doctor.description","Run health checks (backend, FTS, parser)"),boxed:!0}),{code:a.healthy?0:1,handled:!0,command:i}}case "index":{let s=Pe(r);if(s.help)return console.log(t("cli.index.usage","Usage: easbot codebase index [--embed] [--no-embed] [--batch=N] [--json]")),console.log(""),console.log(t("cli.index.description","Build the full index for the target directory.")),console.log(t("cli.index.auto_init","Auto-initializes .easbot/codebase.json if it does not exist.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.index.opt.embed","--embed Generate node embeddings (default: skip)")}`),console.log(` ${t("cli.index.opt.no_embed","--no-embed Same as default (skip embedding)")}`),console.log(` ${t("cli.index.opt.batch","--batch=N Batch size for indexing (default 50)")}`),console.log(` ${t("cli.index.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:i};let a=await H(s);return s.json?emitJsonOk(a,{success:a.success,noEmbed:s.noEmbed!==!1,batch:s.batch??null,verbose:s.verbose===!0,quiet:s.quiet===!0}):printHuman([Fe(a)],{title:t("cli.cmd.index.description","Build the full index (creates db if missing)")}),{code:a.success?0:1,handled:!0,command:i}}case "sync":{let s=Me(r);if(s.help)return console.log(t("cli.sync.usage","Usage: easbot codebase sync [--embed] [--no-embed] [--quiet] [--json]")),console.log(""),console.log(t("cli.sync.description","Run incremental sync (only adds/updates/deletes changed files).")),console.log(t("cli.sync.auto_version","Auto-updates meta['indexed_with_version'] on success.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.sync.opt.embed","--embed Enable node embeddings (default off, FTS-only)")}`),console.log(` ${t("cli.sync.opt.no_embed","--no-embed Explicitly disable embeddings (default)")}`),console.log(` ${t("cli.sync.opt.quiet","--quiet, -q Only print summary")}`),console.log(` ${t("cli.sync.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:i};let a=await Ae(s);return s.json?emitJsonOk(a,{success:a.success,quiet:s.quiet===!0}):printHuman([qe(a)],{title:t("cli.cmd.sync.description","Run incremental sync (only changed files)")}),{code:a.success?0:1,handled:!0,command:i}}case "recreate":{let s=Je(r);if(s.help)return console.log(t("cli.recreate.usage","Usage: easbot codebase recreate [--keep-config] [--no-reindex] [--no-embed] [--force] [--json]")),console.log(""),console.log(t("cli.recreate.description","Discard the entire db (codebase.db + -wal + -shm), re-init, and rebuild the index in one step.")),console.log(t("cli.recreate.equivalent","Equivalent to codegraph `recreate()` for safe index recovery.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.recreate.opt.keep_config","--keep-config Keep .easbot/codebase.json (only drop db)")}`),console.log(` ${t("cli.recreate.opt.no_reindex","--no-reindex Skip the auto rebuild-index step (manual `easbot codebase index` required after)")}`),console.log(` ${t("cli.recreate.opt.no_embed","--no-embed Forward to runIndex: skip embedding generation (faster)")}`),console.log(` ${t("cli.recreate.opt.force","--force, -f Skip safety prompts (for scripts)")}`),console.log(` ${t("cli.recreate.opt.json","--json Output as JSON")}`),console.log(""),console.log(t("cli.recreate.warn","\u26A0\uFE0F This deletes the entire index. By default `recreate` also rebuilds the index in the same call.")),{code:0,handled:!0,command:i};let a=await ze(s);return s.json?emitJsonOk(a,{keepConfig:s.keepConfig===!0,force:s.force===!0}):printHuman([We(a)],{title:t("cli.cmd.recreate.description","Discard the entire db and re-init"),boxed:!0}),{code:0,handled:!0,command:i}}case "clear":{let s=Ge(r);if(s.help)return console.log(t("cli.clear.usage","Usage: easbot codebase clear [--keep-embeddings] [--force] [--json]")),console.log(""),console.log(t("cli.clear.description","Clear all nodes/edges/file_hashes; keep config.json and meta.")),console.log(t("cli.clear.reset_state",'index_state is reset to "uninitialized" so `status` recommends `index`.')),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.clear.opt.keep_embeddings","--keep-embeddings Preserve node_embeddings / embedding_cache")}`),console.log(` ${t("cli.clear.opt.force","--force, -f Skip safety prompts (for scripts)")}`),console.log(` ${t("cli.clear.opt.json","--json Output as JSON")}`),console.log(""),console.log(t("cli.clear.hint","\u{1F4A1} Use `recreate` if you want to drop the entire db file.")),{code:0,handled:!0,command:i};let a=await Ke(s);return s.json?emitJsonOk(a,{keepEmbeddings:s.keepEmbeddings===!0,force:s.force===!0}):printHuman([Ve(a)],{title:t("cli.cmd.clear.description","Clear all nodes/edges (keep config.json)"),boxed:!0}),{code:0,handled:!0,command:i}}case "config":{let s=Ye(r);if(s.help)return console.log(t("cli.config.usage","Usage: easbot codebase config <get|set> [key] [value] [--json]")),console.log(""),console.log(t("cli.config.description","Read or write .easbot/codebase.json fields.")),console.log(""),console.log(t("cli.config.subcommands","Subcommands:")),console.log(` ${t("cli.config.get","get [key] Show all fields (or a specific key)")}`),console.log(` ${t("cli.config.set","set <key> <value> Update a field (must be in allowlist)")}`),console.log(""),console.log(t("cli.config.allowed_keys","Allowed keys: backend, schema_version, extraction_version, index_state")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.config.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:i};if(!s.subcommand)return console.error(t("cli.config.no_subcommand","config requires a subcommand: get | set")),{code:1,handled:!0,command:i};if(s.subcommand==="get"){let a=await Qe(s);return s.json?emitJsonOk(a,{subcommand:"get",key:s.key??null}):printHuman([Ze(a)],{title:t("cli.config.get","get [key] Show all fields (or a specific key)")}),{code:0,handled:!0,command:i}}if(s.subcommand==="set"){let a=await Xe(s);return s.json?emitJsonOk(a,{subcommand:"set",key:s.key??null}):printHuman([et(a)],{title:t("cli.config.set","set <key> <value> Update a field (must be in allowlist)")}),{code:0,handled:!0,command:i}}return console.error(t("cli.config.unknown_subcommand",`Unknown config subcommand: ${s.subcommand}`,{subcommand:s.subcommand})),{code:1,handled:!0,command:i}}case "upgrade":{let s=nt(r);if(s.help)return console.log(t("cli.upgrade.usage","Usage: easbot codebase upgrade [--schema] [--force]")),console.log(""),console.log(t("cli.upgrade.description","Update indexed_with_extraction_version metadata when stale.")),console.log(t("cli.upgrade.does_not_delete","Does NOT delete data \u2014 use `recreate` to drop the db entirely.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.upgrade.opt.schema","--schema Also re-run ensureSchema (idempotent CREATE TABLE IF NOT EXISTS)")}`),console.log(` ${t("cli.upgrade.opt.force","--force, -f Update version even when not stale")}`),{code:0,handled:!0,command:i};let a=await st(s);return s.json?emitJsonOk(a,{schema:s.schema===!0,force:s.force===!0}):printHuman([it(a)],{title:t("cli.cmd.upgrade.description","Update extraction_version metadata when stale")}),{code:0,handled:!0,command:i}}case "embed":case "embed-status":{let s=rt(r);if(s.help)return console.log(t("cli.embed.usage","Usage: easbot codebase embed-status [--all] [--dry-run|-n] [--pending-list|-p] [--json]")),console.log(""),console.log(t("cli.embed.description","Inspect node embeddings (statistical only) \u2014 does NOT generate embeddings.")),console.log(t("cli.embed.statistical_only","CLI is statistical-only \u2014 actual embedding generation requires")),console.log(t("cli.embed.repl_required","an `easbot` REPL session with an injected EmbeddingModel.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.embed.opt.all","--all Show all nodes (including those with embeddings)")}`),console.log(` ${t("cli.embed.opt.dry_run","--dry-run, -n Print statistics only (default behavior)")}`),console.log(` ${t("cli.embed.opt.pending","--pending-list, -p List node ids that are pending embedding")}`),console.log(` ${t("cli.embed.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};s.dryRun=!0;let a=await ct(s);return s.json?emitJsonOk(a,{all:s.all===!0,dryRun:!0,pendingList:s.pendingList===!0,batchSize:s.batchSize??null}):printHuman([lt(a)],{title:t("cli.cmd.embed.description","Inspect node embeddings (statistical only)")}),{code:0,handled:!0,command:i}}case "query":{let s=yt(r);if(s.help)return console.log(t("cli.query.usage","Usage: easbot codebase query <q...> [--language=<lang>] [--ast=<type>] [--max=N] [--no-edges] [--no-vector|--no-embed] [--json]")),console.log(""),console.log(t("cli.query.description","Hybrid search (FTS + vector + basic) over indexed code nodes.")),console.log(t("cli.query.aliases","Aliases: search")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.query.opt.language","--language=<lang> Filter by language (ts / js / py / go / ...)")}`),console.log(` ${t("cli.query.opt.ast","--ast=<type> Filter by AST type (class_declaration / function_declaration / ...)")}`),console.log(` ${t("cli.query.opt.max","--max=<N> Max results (default 20)")}`),console.log(` ${t("cli.query.opt.no_edges","--no-edges Do not include edges in results (default: include)")}`),console.log(` ${t("cli.query.opt.no_vector","--no-vector / --no-embed Disable vector search (FTS + basic only, default: vector on)")}`),console.log(` ${t("cli.query.opt.json","--json JSON output")}`),{code:0,handled:!0,command:i};let a=await xt(s);return s.json?emitJsonOk(a,{query:s.query??"",language:s.language??null,astType:s.astType??null,maxResults:s.maxResults??null}):printHuman([St(a)],{title:t("cli.cmd.query.description","Hybrid search (FTS + vector + basic)")}),{code:0,handled:!0,command:i}}case "node":{let s=Et(r);if(s.help)return console.log(t("cli.node.usage","Usage: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json]")),console.log(""),console.log(t("cli.node.description","Show details for a single node.")),console.log(t("cli.node.accepts_name","Accepts a symbol <name> (LLM workflow friendly, tool/MCP-aligned)")),console.log(t("cli.node.accepts_id","or a raw <node-id> from `query` / database.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.node.opt.file","--file=<path> Disambiguate when same-named symbols exist")}`),console.log(` ${t("cli.node.opt.kind","--kind=<kind> Filter / disambiguate by AST kind")}`),console.log(` ${t("cli.node.opt.edges","--edges Include incoming / outgoing edge summaries")}`),console.log(` ${t("cli.node.opt.max","--max=<N> Edge limit (default 50)")}`),console.log(` ${t("cli.node.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await Rt(s);return s.json?emitJsonOk(a,{name:s.name??"",nodeId:s.nodeId??null,file:s.file??null,kind:s.kind??null,includeEdges:s.includeEdges===!0,edgesLimit:s.edgesLimit??null,found:a.found}):printHuman([_t(a)],{title:t("cli.cmd.node.description","Show details for a single node")}),{code:a.found?0:1,handled:!0,command:i}}case "context":{let s=Dt(r);if(s.help)return console.log(t("cli.context.usage","Usage: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json]")),console.log(""),console.log(t("cli.context.description","Build a sub-graph context around a node (BFS to N-level neighbors).")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.context.opt.depth","--depth=<N> BFS depth (default 2)")}`),console.log(` ${t("cli.context.opt.max","--max=<N> Max nodes (default 100)")}`),console.log(` ${t("cli.context.opt.direction","--direction=<dir> incoming | outgoing | both (default both)")}`),console.log(` ${t("cli.context.opt.relation","--relation=<r1,r2,...> Filter by relation types (CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / USES / REFERENCES)")}`),console.log(` ${t("cli.context.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await vt(s);return s.json?emitJsonOk(a,{nodeId:s.nodeId??"",depth:s.depth??null,direction:s.direction??"both"}):printHuman([It(a)],{title:t("cli.cmd.context.description","Build sub-graph context around a node")}),{code:0,handled:!0,command:i}}case "impact":{let s=Ot(r);if(s.help)return console.log(t("cli.impact.usage","Usage: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]")),console.log(""),console.log(t("cli.impact.description","Blast radius: BFS incoming CALLS / REFERENCES / USES / IMPORTS / TYPE_REFERENCES, bucketed by depth.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.impact.opt.depth","--depth=<N> BFS depth (default 3)")}`),console.log(` ${t("cli.impact.opt.relation","--relation=<r1,r2,...> Filter by relation types")}`),console.log(` ${t("cli.impact.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await jt(s);return s.json?emitJsonOk(a,{nodeId:s.nodeId??"",depth:s.depth??null}):printHuman([Tt(a)],{title:t("cli.cmd.impact.description","Blast radius (BFS incoming edges)")}),{code:0,handled:!0,command:i}}case "callers":{let s=Qt(r);if(s.help)return console.log(t("cli.callers.usage","Usage: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]")),console.log(""),console.log(t("cli.callers.description","Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).")),console.log(t("cli.callers.accepts","Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.callers.opt.node_id","--node-id=<id> Raw node id from `query` / database")}`),console.log(` ${t("cli.callers.opt.file","--file=<path> File path or basename to disambiguate when same-named symbols exist")}`),console.log(` ${t("cli.callers.opt.kind","--kind=<kind> Filter by node kind (class_declaration / function_declaration / ...)")}`),console.log(` ${t("cli.callers.opt.max","--max=<N> Max callers (default 20)")}`),console.log(` ${t("cli.callers.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await Xt(s);return s.json?emitJsonOk(a,{symbol:s.symbol??"",nodeId:s.nodeId??null,file:s.file??null,kind:s.kind??null,maxResults:s.maxResults??null}):printHuman([Zt(a)],{title:t("cli.cmd.callers.description","Flat list of who calls <symbol> (incoming edges)")}),{code:0,handled:!0,command:i}}case "callees":{let s=eo(r);if(s.help)return console.log(t("cli.callees.usage","Usage: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json]")),console.log(""),console.log(t("cli.callees.description","Flat list of what <symbol> calls (outgoing edges).")),console.log(t("cli.callees.accepts","Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.callees.opt.node_id","--node-id=<id> Raw node id from `query` / database")}`),console.log(` ${t("cli.callees.opt.file","--file=<path> File path or basename to disambiguate")}`),console.log(` ${t("cli.callees.opt.kind","--kind=<kind> Filter by node kind")}`),console.log(` ${t("cli.callees.opt.max","--max=<N> Max callees (default 20)")}`),console.log(` ${t("cli.callees.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await to(s);return s.json?emitJsonOk(a,{symbol:s.symbol??"",nodeId:s.nodeId??null,file:s.file??null,kind:s.kind??null,maxResults:s.maxResults??null}):printHuman([oo(a)],{title:t("cli.cmd.callees.description","Flat list of what <symbol> calls (outgoing edges)")}),{code:0,handled:!0,command:i}}case "explore":{let s=no(r);if(s.help)return console.log(t("cli.explore.usage","Usage: easbot codebase explore <query> [--file=<path>] [--kind=<kind>] [--max-files=N] [--max-symbols=N] [--depth=N] [--no-content] [--intent=<ctx>] [--json]")),console.log(""),console.log(t("cli.explore.description","PRIMARY tool \u2014 single call to get source code + caller/callee trail.")),console.log(t("cli.explore.query_help","<query> can be a symbol name or natural language.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.explore.opt.file","--file=<path> File path or basename to disambiguate")}`),console.log(` ${t("cli.explore.opt.kind","--kind=<kind> Filter by node kind")}`),console.log(` ${t("cli.explore.opt.max_files","--max-files=<N> Max entry-point files (default 5)")}`),console.log(` ${t("cli.explore.opt.max_symbols","--max-symbols=<N> Max symbols per file (default 3)")}`),console.log(` ${t("cli.explore.opt.depth","--depth=<N> Neighbor depth for caller/callee trail (default 1)")}`),console.log(` ${t("cli.explore.opt.no_content","--no-content Do not include source code (locations only, default: include)")}`),console.log(` ${t("cli.explore.opt.intent","--intent=<ctx> LLM context string for ranking")}`),console.log(` ${t("cli.explore.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await so(s);return s.json?emitJsonOk(a,{query:s.query??"",file:s.file??null,kind:s.kind??null,maxFiles:s.maxFiles??null,maxSymbols:s.maxSymbols??null,depth:s.depth??null,includeContent:s.includeContent!==!1,intent:s.intent??null}):printHuman([await io(a)],{title:t("cli.cmd.explore.description","PRIMARY tool \u2014 source code + caller/callee trail in one call")}),{code:0,handled:!0,command:i}}case "dead-code":{let s=Pt(r);if(s.help)return console.log(t("cli.dead_code.usage","Usage: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json]")),console.log(""),console.log(t("cli.dead_code.description","Find nodes with no incoming edges (heuristic dead code).")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.dead_code.opt.type","--type=<t1,t2,...> Only consider these AST types")}`),console.log(` ${t("cli.dead_code.opt.no_exclude_entry","--no-exclude-entry Include entry-point files (default: exclude)")}`),console.log(` ${t("cli.dead_code.opt.limit","--limit=<N> Max results (default 100)")}`),console.log(` ${t("cli.dead_code.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await Ft(s);return s.json?emitJsonOk(a,{astTypes:s.astTypes??null,limit:s.limit??null,excludeEntry:s.excludeEntry!==!1}):printHuman([Lt(a)],{title:t("cli.cmd.dead_code.description","Find unused symbols")}),{code:0,handled:!0,command:i}}case "circular":{let s=At(r);if(s.help)return console.log(t("cli.circular.usage","Usage: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json]")),console.log(""),console.log(t("cli.circular.description","Detect circular dependencies via Tarjan SCC.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.circular.opt.relation","--relation=<r> Relation type to follow (default IMPORTS)")}`),console.log(` ${t("cli.circular.opt.scope","--scope=<scope> file | module (default file)")}`),console.log(` ${t("cli.circular.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await qt(s);return s.json?emitJsonOk(a,{relation:s.relation??null,scope:s.scope??null}):printHuman([Ut(a)],{title:t("cli.cmd.circular.description","Detect circular dependencies (Tarjan SCC)")}),{code:0,handled:!0,command:i}}case "path":{let s=zt(r);if(s.help)return console.log(t("cli.path.usage","Usage: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json]")),console.log(""),console.log(t("cli.path.description","Find shortest path between two nodes (BFS along CALLS / IMPORTS / TYPE_REFERENCES / USES / REFERENCES).")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.path.opt.depth","--depth=<N> BFS depth limit (default 6)")}`),console.log(` ${t("cli.path.opt.relation","--relation=<r1,r2,...> Filter by relation types")}`),console.log(` ${t("cli.path.opt.json","--json Output as JSON")}`),{code:0,handled:!0,command:i};let a=await Wt(s);return s.json?emitJsonOk(a,{fromId:s.fromId??"",toId:s.toId??"",depth:s.depth??null}):printHuman([Gt(a)],{title:t("cli.cmd.path.description","Find shortest path between two nodes")}),{code:a.found?0:1,handled:!0,command:i}}case "mcp":{let s=Ht(r);return s.help?(console.log(t("cli.mcp.usage","Usage: easbot codebase mcp")),console.log(""),console.log(t("cli.mcp.description","Start a stdio MCP server exposing 9 codebase tools:")),console.log(` ${t("cli.mcp.tools.1"," query / node / context / impact")}`),console.log(` ${t("cli.mcp.tools.2"," callers / callees / explore")}`),console.log(` ${t("cli.mcp.tools.3"," status / doctor")}`),console.log(""),console.log(t("cli.mcp.transport","Connect from MCP clients via stdio JSON-RPC.")),{code:0,handled:!0,command:i}):(await Yt(s),{code:0,handled:!0,command:i})}case "watch":{let s=pt(r);if(s.help)return console.log(t("cli.watch.usage","Usage: easbot codebase watch [--debounce=N] [--interval=N]")),console.log(""),console.log(t("cli.watch.description","Watch the workspace directory for file changes and log events.")),console.log(t("cli.watch.pid_file","Writes a pid file at .easbot/.watcher.pid for subsequent `stop`.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.watch.opt.debounce","--debounce=N Per-path debounce in ms (default 200)")}`),console.log(` ${t("cli.watch.opt.interval","--interval=N Polling interval in ms (default 500)")}`),console.log(""),console.log(t("cli.watch.note","NOTE: This command blocks. Press Ctrl+C to exit.")),{code:0,handled:!0,command:i};let a=await ut(s);return console.log(mt(a.events)),await new Promise(p=>{let c=()=>{de.info("watcher received signal, stopping"),p();};process.once("SIGINT",c),process.once("SIGTERM",c);}),await a.watcher.dispose(),{code:0,handled:!0,command:i}}case "stop":{let s=gt(r);if(s.help)return console.log(t("cli.stop.usage","Usage: easbot codebase stop")),console.log(""),console.log(t("cli.stop.description","Stop a running watcher identified by .easbot/.watcher.pid.")),console.log(""),console.log(t("cli.shared.options_heading","Options:")),console.log(` ${t("cli.stop.opt.force","--force, -f Ignore errors and clear the pid file anyway")}`),{code:0,handled:!0,command:i};let a=await ft(s);return s.json?emitJsonOk(a,{force:s.force===!0}):printHuman([bt(a)],{title:t("cli.cmd.stop.description","Stop a running file watcher")}),{code:a.stopped?0:1,handled:!0,command:i}}default:return l?emitJsonError(i,t("cli.unknown_command",`Unknown command: ${i}`,{command:i})):(console.error(t("cli.unknown_command",`Unknown command: ${i}`,{command:i})),console.error(t("cli.help_hint","Run `easbot codebase --help` for available commands."))),{code:1,handled:!0,command:i}}}catch(s){let a=errorMeta(s),p=a.message;return l?emitJsonError(i,p):console.error(t("cli.command_failed",`codebase ${i} failed: ${p}`,{command:i,message:p})),de.error("codebase CLI error",{command:i,error:a}),{code:1,handled:true,command:i}}}function Bn(o){let e={};for(let n of o)n==="--json"&&(e.json=true);return e}function Jn(o){let e={};for(let n of o)n==="--help"||n==="-h"?e.help=true:n==="--json"&&(e.json=true);return e}function zn(o){return {packageName:"codebase",rootDir:o.rootDir,configPath:o.configPath,configExists:o.configExists,dbPath:o.dbPath,dbExists:o.dbExists,dbSize:o.dbSize,indexState:o.indexState,schemaVersion:o.schemaVersion,extractionVersion:o.extractionVersion,lastSyncAt:o.lastSyncAt,vectorEnabled:o.vectorEnabled,embeddingDims:o.embeddingDims,llm:o.llm,backend:o.backend,healthy:o.healthy,recommendation:o.recommendation,dbStats:o.dbStats,extras:(()=>{let e={};if(o.isStale===true&&(e.stale="yes \u2014 reindex recommended"),typeof o.ftsAvailable=="boolean"&&(e.fts_available=o.ftsAvailable?"yes":"no"),o.meta&&typeof o.meta=="object")for(let[n,t]of Object.entries(o.meta))e[`meta/${n}`]=t===void 0?"\u2205":t;return Object.keys(e).length>0?e:void 0})()}}function Wn(o){return {packageName:"codebase",healthy:o.healthy,durationMs:o.durationMs,checks:o.checks.map(e=>({code:e.code,severity:e.severity,name:e.name,message:e.message,durationMs:e.durationMs,details:e.details})),backendAvailable:o.backendAvailable,dbStats:o.dbStats}}export{Co as a,f as b,Mn as c,Br as d,An as e,Jr as f,Wn as g};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {streamText}from'ai';import {Log,errorMeta}from'@easbot/utils';var m;(I=>{let l=Log.create({service:"codebase-llm"}),i=null;function S(t){if(f())return;let e=t;i={models:e.models,options:{graph:e.options?.graph}},l.info("Llm initialized",{graphLlm:!!e.models.graphLlm,embeddingLlm:!!e.models.embeddingLlm});}I.init=S;function f(){return i!==null}I.isInitialized=f;function M(){i=null;}I._resetForTest=M;function R(){return i?{graphLlm:!!i.models.graphLlm,embedding:!!i.models.embeddingLlm}:{graphLlm:false,embedding:false}}I.capabilities=R;function v(){return i?.models.graphLlm}I.getGraphLlm=v;function N(){return i?.models.embeddingLlm}I.getEmbeddingLlm=N;async function h(t,e){if(!i?.models.graphLlm)return l.debug("Llm.generateText: graphLlm not configured, return empty string"),"";try{return (await streamText({model:i.models.graphLlm,prompt:t,maxOutputTokens:e?.maxOutputTokens??i.options.graph?.maxOutputTokens,temperature:e?.temperature??i.options.graph?.temperature})).text}catch(n){return l.error("Llm.generateText failed",{error:errorMeta(n)}),""}}I.generateText=h;async function T(t){if(!i?.models.graphLlm)return {score:-1,details:"graphLlm not configured",missingEntities:[],extraEntities:[],wrongRelations:[],missingRelations:[]};let e=L(t.gold,t.predicted),n=await h(e,{maxOutputTokens:1024,temperature:0,...t.options});return y(n)}I.evaluateExtraction=T;function L(t,e){return `You are a code knowledge graph extraction quality evaluator.
|
|
2
|
-
|
|
3
|
-
Given:
|
|
4
|
-
- **Gold (ground truth)**: a reference extraction produced by a human annotator
|
|
5
|
-
- **Predicted**: an automatic extraction produced by the codebase extractor
|
|
6
|
-
|
|
7
|
-
Both Gold and Predicted support TWO input formats \u2014 auto-detect by JSON shape:
|
|
8
|
-
|
|
9
|
-
**Format A (flat symbol list, common for search/recall eval):**
|
|
10
|
-
{ "expected": ["MemorySystem", "NoteKnowledge"], "query": "core classes" } // gold
|
|
11
|
-
{ "actual": ["MemorySystem", "./parser"] } // predicted
|
|
12
|
-
|
|
13
|
-
**Format B (structured extraction, for full MRO eval):**
|
|
14
|
-
{ "entities": [{"name": "Foo", "type": "class"}], "relations": [{"source": "Foo", "target": "Bar", "relation": "EXTENDS"}] } // gold
|
|
15
|
-
{ "entities": [{"name": "Foo", "type": "class"}], "relations": [] } // predicted
|
|
16
|
-
|
|
17
|
-
Scoring dimensions (be strict):
|
|
18
|
-
1. **Entity name match**: case-insensitive exact match preferred; consider semantic synonyms (e.g. "UserService" \u2248 "UserSvc"); reject type-mismatched candidates (file paths vs class names).
|
|
19
|
-
2. **Relation endpoints**: source/target must point to same conceptual entity as in gold.
|
|
20
|
-
3. **Relation type accuracy**: e.g. CALLS vs REFERENCES vs IMPORTS are distinct.
|
|
21
|
-
4. **Type/category match**: an entity in predicted must have the same type/category as its gold counterpart (e.g. don't count a file_path as a class).
|
|
22
|
-
|
|
23
|
-
Output JSON schema (REQUIRED):
|
|
24
|
-
{
|
|
25
|
-
"score": <number between 0 and 1>,
|
|
26
|
-
"details": "<short explanation of what matched, what was missed, what was wrong>",
|
|
27
|
-
"missing_entities": [<entity names missing from predicted>],
|
|
28
|
-
"extra_entities": [<entity names in predicted but not gold or wrong type>],
|
|
29
|
-
"wrong_relations": [<relation strings like "source->target:TYPE" that are wrong>],
|
|
30
|
-
"missing_relations": [<relation strings missing from predicted>]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
Scoring guide:
|
|
34
|
-
- 1.0: all entities + all relations match perfectly
|
|
35
|
-
- 0.7-0.9: most entities match, minor relations off
|
|
36
|
-
- 0.4-0.6: ~half match, significant misses
|
|
37
|
-
- 0.0-0.3: little to no match (e.g. predicted is file paths, gold is class names)
|
|
38
|
-
|
|
39
|
-
OUTPUT FORMAT RULES (MUST FOLLOW):
|
|
40
|
-
- Output ONLY the raw JSON object above, with NO surrounding markdown code fences (no \`\`\`json, no \`\`\`).
|
|
41
|
-
- Start your response with the character { and end with }.
|
|
42
|
-
- Do NOT add any explanatory text before or after the JSON.
|
|
43
|
-
- Do NOT wrap in any kind of code block.
|
|
44
|
-
- Output the JSON on a single line or with newlines, both are acceptable as long as it's valid JSON.
|
|
45
|
-
|
|
46
|
-
Gold:
|
|
47
|
-
${t}
|
|
48
|
-
|
|
49
|
-
Predicted:
|
|
50
|
-
${e}`}function y(t){let e={score:0,details:"",missingEntities:[],extraEntities:[],wrongRelations:[],missingRelations:[]},n=t??"",d=n.trim();if(!d)return {...e,details:"LLM returned empty text"};let s=d,g=s.match(/```(?:json|JSON)?\s*([\s\S]*?)\s*```/);g&&(s=(g[1]??"").trim());let u=s.match(/\{[\s\S]*\}/);if(u)try{let a=JSON.parse(u[0]);return c(a)}catch{}for(let a of s.split(`
|
|
51
|
-
`)){let r=a.trim();if(r.startsWith("{"))try{let o=JSON.parse(r);return c(o)}catch{}}let p=s.match(/(\d+(?:\.\d+)?%?)/g);if(p)for(let a of p){let r=a;r.endsWith("%")&&(r=String(parseFloat(r)/100));let o=parseFloat(r);if(!Number.isNaN(o)&&o>=0&&o<=1)return {...e,score:o,details:`LLM returned non-JSON output; score extracted via heuristic from: ${n.slice(0,200)}`}}return {...e,details:`Failed to parse LLM output: ${n.slice(0,200)}`}}I.parseEvaluationResult=y;function c(t){return {score:typeof t.score=="number"?Math.max(0,Math.min(1,t.score)):0,details:typeof t.details=="string"?t.details:"",missingEntities:Array.isArray(t.missing_entities)?t.missing_entities.filter(n=>typeof n=="string"):[],extraEntities:Array.isArray(t.extra_entities)?t.extra_entities.filter(n=>typeof n=="string"):[],wrongRelations:Array.isArray(t.wrong_relations)?t.wrong_relations.filter(n=>typeof n=="string"):[],missingRelations:Array.isArray(t.missing_relations)?t.missing_relations.filter(n=>typeof n=="string"):[]}}})(m||(m={}));var A=m;export{m as a,A as b};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {b,c,x}from'./chunk-J7AIRI5N.mjs';import {e}from'./chunk-4XKCGYFF.mjs';import {Log,Filesystem,ServiceError,ServiceErrorBus,TruncateContent,errorMeta}from'@easbot/utils';import {DEFAULT_SEARCH_CONFIG,DEFAULT_PARSER_CONFIG,DEFAULT_INDEXER_CONFIG,DEFAULT_EMBEDDING_CONFIG}from'@easbot/types';import {existsSync,statSync}from'fs';var Z=Log.create({service:"codebase-service"}),N=Filesystem.toUnixPath;function Ne(e,t){let r={exact:1,qualified:.85,substring:.5}[e];return t?Math.min(1,r+.2):r}function Pe(e,t){if(!t)return false;if(e===t)return true;let r=e.split(/[/\\]/).pop()??"",o=t.split(/[/\\]/).pop()??"";return !!(r&&o&&r===o||t.includes("/")&&e.endsWith("/"+t))}async function $(e,t,r){if(r.nodeId){let i=e.getNode(r.nodeId);if(!i)throw new ServiceError({code:"NOT_FOUND",message:`Node not found: nodeId=${r.nodeId}`,details:{name:r.nodeId}});return {node:i,candidates:[]}}if(!r.name)throw new ServiceError({code:"NOT_FOUND",message:"Either name or nodeId is required",details:{...r}});let l=e.getDatabase().findNodesByName({name:r.name,file:r.file,kind:r.kind,limit:50});if(l.length===0)throw new ServiceError({code:"NOT_FOUND",message:`Node not found: ${r.name}`,details:{name:r.name,candidates:[]}});let a=!!r.file,c=r.file?N(r.file):null,s=l.map(i=>{let m=c?Pe(N(i.node.file_path),c):false;return {node:i.node,score:Ne(i.matchKind,m),matchKind:i.matchKind,inFile:m}});if(s.sort((i,m)=>m.score-i.score),s.length===1)return {node:s[0].node,candidates:s.map(i=>({node:i.node,score:i.score}))};let d=s[0].score,n=s.filter(i=>i.score===d);if(n.length===1)return {node:n[0].node,candidates:s.slice(0,10).map(i=>({node:i.node,score:i.score}))};if(a&&n.length>1){let i=n.filter(m=>m.inFile);if(i.length===1)return {node:i[0].node,candidates:s.slice(0,10).map(m=>({node:m.node,score:m.score}))}}throw new ServiceError({code:"AMBIGUOUS",message:`Ambiguous name "${r.name}" \u2014 ${s.length} candidates`,details:{name:r.name,candidates:s.slice(0,10).map(i=>({node:i.node,score:i.score}))}})}async function P(e){let t=c(e.rootDir),r=new x({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 r.initialize(),r}function z(e,t,r,o){let l=r.map(()=>"?").join(","),a=t.name.split("@")[0]??t.name,c=a.includes(".")?a.split(".").pop()??a:a,s=new Set([`${t.language}:*:*:${a}`]);c!==a&&s.add(`${t.language}:*:*:${c}`);let d=[];c!==a&&d.push(`${t.language}:*:*:%${c}`);let n=Array.from(s),i=n.map(()=>"?").join(","),u=d.length>0?"OR LOWER(target) LIKE LOWER(?)":"";n.length>1&&Z.warn("queryIncomingEdgesWithWildcard: multi-variant wildcards (bare+namespaced)",{rootName:t.name,wildcards:n,hint:"\u540C\u540D\u540C namespace \u4E0D\u540C file \u7684\u65B9\u6CD5\u53EF\u80FD\u90FD\u88AB\u547D\u4E2D\uFF0CLLM \u63A8\u7406\u8BF7\u7528 file \u8FC7\u6EE4\u8F85\u4F50"});let g=`
|
|
2
|
-
SELECT id, source, target, relation, created_at FROM edges
|
|
3
|
-
WHERE relation IN (${l})
|
|
4
|
-
AND source != target
|
|
5
|
-
AND (
|
|
6
|
-
target = ?
|
|
7
|
-
OR target IN (${i})
|
|
8
|
-
${u}
|
|
9
|
-
)
|
|
10
|
-
GROUP BY id
|
|
11
|
-
LIMIT ?
|
|
12
|
-
`;return e.queryAll(g,[...r,t.id,...n,...d,o])}function Re(e){return e==="class_declaration"||e==="class_definition"||e==="interface_declaration"||e==="struct_declaration"||e==="struct_specifier"||e==="record_declaration"}function Se(e,t,r,o,l){let c=e.queryAll("SELECT id FROM nodes WHERE file_path = ? AND start_line >= ? AND end_line <= ? AND ast_type IN ('method_definition', 'method_declaration') LIMIT 1000",[t.file_path,t.start_line,t.end_line]).map(n=>n.id),s=new Set,d=[];for(let n of r)n.id&&!s.has(n.id)&&(s.add(n.id),d.push(n));if(c.length>0){let n=o.map(()=>"?").join(","),i=c.map(()=>"?").join(","),m=`
|
|
13
|
-
SELECT id, source, target, relation, created_at FROM edges
|
|
14
|
-
WHERE relation IN (${n})
|
|
15
|
-
AND source != target
|
|
16
|
-
AND source IN (${i})
|
|
17
|
-
GROUP BY id
|
|
18
|
-
LIMIT ?
|
|
19
|
-
`,u=e.queryAll(m,[...o,...c,l]);for(let g of u)g.id&&!s.has(g.id)&&(s.add(g.id),d.push(g));}return d.slice(0,l)}function ee(e,t,r,o){let a=`
|
|
20
|
-
SELECT id, source, target, relation, created_at FROM edges
|
|
21
|
-
WHERE relation IN (${r.map(()=>"?").join(",")})
|
|
22
|
-
AND source != target
|
|
23
|
-
AND source = ?
|
|
24
|
-
LIMIT ?
|
|
25
|
-
`;return e.queryAll(a,[...r,t.id,o])}function te(e,t,r,o){let l=o==="in"?e.source:e.target;t.id;let c=r.getNodeById(l);if(!c&&l.includes(":*:")){let s=l.split(":").pop()??l,d=s.split("@")[0]??s;if(d&&d!==l){let n=r.findNodesByName({name:d}),i=t.file_path??"",m=i.split(/[/\\]/).pop()??"",u=i.split(/[/\\]/).filter(Boolean),g=n.find(p=>p.node.file_path?p.node.file_path===i:false)??n.find(p=>!p.node.file_path||!m?false:p.node.file_path.split(/[/\\]/).pop()===m)??n.find(p=>{if(!p.node.file_path)return false;let f=p.node.file_path.split(/[/\\]/).filter(Boolean);return u.length<2||f.length<2?false:u[0]===f[0]&&u[1]===f[1]})??null;g&&(c=g.node);}}if(!c){let s=l.split(":").pop()??l;return {id:l,name:s,astType:"unresolved",filePath:"(unresolved)",startLine:0,relation:e.relation}}return {id:c.id,name:c.name,astType:c.ast_type,filePath:N(c.file_path),startLine:c.start_line??0,relation:e.relation}}async function ne(e,t){let r=Date.now(),c=await(await P(e)).getQuery().search(t.query??"",{maxResults:t.maxResults??10,language:t.language,filePath:t.file,astType:t.astType,includeEdges:true,enableFts:t.enableFts!==false,enableEmbedding:t.enableEmbedding!==false});if(t.kind){let n=t.kind.toLowerCase();c=c.filter(i=>i.ast_type.includes(n)||i.name.toLowerCase().includes(n));}if(t.file){let n=N(t.file);c=c.filter(i=>N(i.file_path).endsWith(n)||N(i.file_path).includes(n));}let s=t.maxEdgesPerNode??10,d=c.map(n=>({nodeId:n.id,name:n.name,kind:n.ast_type??"unknown",filePath:N(n.file_path),startLine:n.start_line,endLine:n.end_line,edges:(n.edges??[]).slice(0,s),source:"basic",score:0,snippet:(n.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:d.length,hits:d,durationMs:Date.now()-r,truncated:false}}async function Ce(e,t){let r=await P(e),o=r.getQuery(),l=r.getDatabase(),{node:a}=await $(o,e,t),c=[];if(t.includeEdges){let s=t.maxEdgesPerNode??10,d=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"],n=z(l,a,d,s+1),i=ee(l,a,d,s+1),m=new Set,u=[];for(let g of [...n,...i])g.id&&!m.has(g.id)&&(m.add(g.id),u.push(g));c=u.slice(0,s);}return {node:a,edges:c}}var Ie=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function Le(e,t){let r=await P(e),o=r.getQuery(),l=r.getDatabase(),{node:a}=await $(o,e,t);if(!a)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let c=t.depth??2,s=t.maxNodes??100,d=t.direction??"both";t.maxEdgesPerNode??10;let i=new Map,m=[{nodeId:a.id,depth:0}];i.set(a.id,0);let u=[],g=false;for(;m.length>0;){let h=m.shift();if(h.depth>=c)continue;if(i.size>=s){g=true;break}let A=o.queryNeighbors(h.nodeId,{direction:d,relationTypes:t.relationTypes??Ie,limit:s-i.size+1});for(let y of A.edges){u.push(y);let L=y.source===h.nodeId?y.target:y.source;if(!i.has(L)&&(i.set(L,h.depth+1),m.push({nodeId:L,depth:h.depth+1}),i.size>=s)){g=true;break}}if(g)break}let p=new Set,f=[];for(let h of u)!h.id||p.has(h.id)||(p.add(h.id),f.push(h));let b=Array.from(i.keys()),E=b.length>0?l.queryNodes({ids:b}):[],I=new Map(E.map(h=>[h.id,h])),x=[];for(let[h,A]of i.entries()){let y=I.get(h);y&&x.push({node:y,depth:A});}return {root:a,nodes:x,edges:f,truncated:g,totalNodes:x.length,totalEdges:u.length}}var Te=["CALLS","IMPORTS","TYPE_REFERENCES"];async function $e(e,t){let r=await P(e),o=r.getQuery(),l=r.getDatabase(),{node:a}=await $(o,e,t);if(!a)return {root:null,totalImpacted:0,buckets:[]};let c=t.depth??2,s=t.maxResults??10,d=t.relationTypes??Te,n=t.maxEdgesPerNode??10,i=new Set([a.id]),m=[],u=[a.id];for(let g=1;g<=c&&!(u.length===0||i.size-1>=s);g++){let p=z(l,a,d,n+1),f=[],b=new Set;for(let E of p)if(!i.has(E.source)&&!b.has(E.source)&&(b.add(E.source),i.add(E.source),f.push(E.source),i.size-1>=s))break;if(f.length>0){let E=f.slice(0,10),I=l.queryNodes({ids:E}),x=new Map(I.map(y=>[y.id,y])),h=new Map;for(let y of p)h.has(y.source)||h.set(y.source,y.relation);let A=E.map(y=>{let L=x.get(y);return {id:y,name:L?.name??"(unknown)",filePath:L?N(L.file_path):"(unknown)",relation:h.get(y)??"CALLS"}});m.push({depth:g,count:f.length,sample:A});}u=f;}return m.length===0&&Z.warn("impact: no incoming edges found",{root:a.name,depth:c,relationTypes:d}),{root:a,totalImpacted:i.size-1,buckets:m}}var re=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function _e(e,t){return oe(e,t)}async function we(e,t){return se(e,t)}async function oe(e,t){let r=await P(e),o=r.getQuery(),l=r.getDatabase(),{node:a}=await $(o,e,t);if(!a)return {root:null,callers:[],truncated:false};let c=t.maxResults??10,s=t.maxEdgesPerNode??c,d=t.relationTypes??re,n=z(l,a,d,s+1),i=[];for(let u of n){let g=te(u,a,l,"in");g&&i.push(g);}let m=i.length>c;return {root:a,callers:m?i.slice(0,c):i,truncated:m}}async function se(e,t){let r=await P(e),o=r.getQuery(),l=r.getDatabase(),{node:a}=await $(o,e,t);if(!a)return {root:null,callees:[],truncated:false};let c=t.maxResults??10,s=t.maxEdgesPerNode??c,d=t.relationTypes??re,n=ee(l,a,d,s+1),i=Re(a.ast_type)?Se(l,a,n,d,s+1):n,m=[];for(let g of i){let p=te(g,a,l,"out");p&&m.push(p);}let u=m.length>c;return {root:a,callees:u?m.slice(0,c):m,truncated:u}}async function Fe(e,t){if(!t.query)throw new ServiceError({code:"NOT_FOUND",message:"explore requires a non-empty query",details:{query:t.query}});let o=await P(e),l=o.getQuery(),a=o.getDatabase(),s=(await ne(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true})).hits;if(t.file||t.kind)try{let u=await $(l,e,{name:t.query,file:t.file,kind:t.kind});if(u?.node){let g={nodeId:u.node.id,name:u.node.name,kind:u.node.ast_type,filePath:N(u.node.file_path),startLine:u.node.start_line,endLine:u.node.end_line,edges:[],source:"basic",score:0,snippet:(u.node.text??"").slice(0,200).replace(/\s+/g," ").trim()},p=s.filter(f=>f.nodeId!==g.nodeId);s=[g,...p];}}catch{}let d=new Map;for(let u of s){let g=N(u.filePath),p=d.get(g);p?p.push(u):d.set(g,[u]);}let n=t.maxSymbols??3,i=t.maxEdgesPerNode??10,m=[];for(let[u,g]of d){let p=g.slice(0,n),f=[];for(let b of p){let E=await oe(e,{name:b.name,file:u,kind:t.kind,maxResults:i,maxEdgesPerNode:i}),I=await se(e,{name:b.name,file:u,kind:t.kind,maxResults:i,maxEdgesPerNode:i});f.push({node:(()=>{let x={id:b.nodeId,name:b.name,ast_type:b.kind,language:"ts",file_path:b.filePath,start_line:b.startLine??0,end_line:b.endLine??0};try{let h=a.getNodeById(b.nodeId);return {...x,text:h?.text??""}}catch{return {...x,text:""}}})(),callers:E.callers,callees:I.callees});}m.push({file:u,symbols:f});}return {query:t.query,entryPoints:m,totalHits:s.length}}async function Ae(e,t){let o=await(await P(e)).getStatus();o.package="codebase",o.workspaceDir=e.workspaceDir;let l=b(e.workspaceDir),a=existsSync(l),c=existsSync(o.dbPath),s;if(c)try{s=statSync(o.dbPath).size;}catch{}o.configPath=l,o.configExists=a,o.dbExists=c,o.dbSize=s,o.vectorEnabled=o.meta?.vector_enabled==="true"||o.meta?.vector_enabled==="1";let d=o.meta?.embeddingDims;d&&Number.isFinite(Number.parseInt(d,10))&&(o.embeddingDims=Number.parseInt(d,10));let n={initialized:false,capabilities:{embedding:false,graphLlm:false}};try{let{Llm:i}=await import('./llm-U57HNTZO.mjs');if(i.isInitialized()){n.initialized=!0;let m=i.capabilities();n.capabilities={embedding:m.embedding===!0,graphLlm:m.graphLlm===!0},n.embeddingModel=n.capabilities.embedding?"configured":void 0,n.graphModel=n.capabilities.graphLlm?"configured":void 0;}}catch{}o.llm=n;try{let{DatabaseManager:i}=await import('./database-manager-7D7NDXJK.mjs'),m=new i(o.dbPath);try{let{stats:u}=m.checkIntegrity();o.dbStats=u,o.ftsAvailable=m.isFtsAvailable();}finally{m.close();}}catch{}return o}async function De(e,t){return await(await P(e)).healthCheck()}var ve=Log.create({service:"codebase-service-init"}),ie=false;async function Me(){ie||(ie=true,ve.info("codebase service init"),await ServiceErrorBus.init(),await e());}var ae=Filesystem.toUnixPath;function qe(e){let t=e.text??"";if(!t)return false;let r=t.slice(0,80);return /\bexport\s/.test(r)||/\bpublic\s/.test(r)?true:(false)}function Be(e){let t=e.text??"";if(!t)return [];let r=t.slice(0,80),o=[];return /\basync\s/.test(r)&&o.push("async"),/\bstatic\s/.test(r)&&o.push("static"),/\babstract\s/.test(r)&&o.push("abstract"),/\breadonly\s/.test(r)&&o.push("readonly"),/\bconst\s/.test(r)&&o.push("const"),/\blet\s/.test(r)&&o.push("let"),o}function R(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:ae(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:qe(e),modifiers:Be(e)}}function _(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:ae(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(r=>_({...r}))}))}function j(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var Ke=Log.create({service:"codebase-format-truncate"}),W="**`",je="**",de=24e3,ce=25e3;async function O(e,t={}){let r=t.softLimit??de,o=t.hardCeiling??ce,l=t.toolName??"codebase",a=t.writeToDisk!==false;if(e.length<=r)return {content:e,truncated:false};let c=e.slice(0,o),s=c.lastIndexOf(`
|
|
26
|
-
${W}`),d=c.lastIndexOf(`
|
|
27
|
-
`),n;s>o*.5?n=s:d>0?n=d:n=-1;let i=n>0?c.slice(0,n):c,u=i+"\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(!a)return {content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-i.length}/${e.length} characters truncated ...`};try{let g=await TruncateContent.truncate(e,{maxChars:i.length,direction:"head",label:`${l}-output`});return g.truncated?{content:u,truncated:!0,outputPath:g.outputPath,hint:TruncateContent.formatHint(g),info:`... ${g.removedLength}/${g.originalLength} characters truncated ...`}:{content:u,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-i.length}/${e.length} characters truncated ...`}}catch(g){return Ke.warn("TruncateContent.truncate failed, returning without disk hint",{error:errorMeta(g)}),{content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-i.length}/${e.length} characters truncated ...`}}}function k(e,t={}){let r=t.softLimit??de,o=t.hardCeiling??ce;if(e.length<=r)return {content:e,truncated:false};let l=e.slice(0,o),a=l.lastIndexOf(`
|
|
28
|
-
${W}`),c=l.lastIndexOf(`
|
|
29
|
-
`),s;a>o*.5?s=a:c>0?s=c:s=-1;let d=s>0?l.slice(0,s):l;return {content:d+`
|
|
30
|
-
|
|
31
|
-
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}function We(e,t=Date.now()){let r=Math.max(0,Math.floor((t-e)/1e3));return r>60?">60s ago":`${r}s ago`}function v(e,t){if(!e||e.length===0)return null;let r=e.filter(l=>t.has(l.path));return r.length===0?null:`\u26A0\uFE0F Index may be stale for: ${r.map(l=>`${l.path} (edited ${We(l.lastEventAt)})`).join(", ")}
|
|
32
|
-
|
|
33
|
-
`}function D(e,t,r={}){return (ue[e]??ue.default).replace(/<(\w+)>/g,(l,a)=>a==="tool"?t:r[a]??`<${a}>`)}var ue={search:`---
|
|
34
|
-
|
|
35
|
-
> **Complete source for N files is included above \u2014 do NOT re-read them.**
|
|
36
|
-
> If your question also needs files/symbols listed under "Not shown above" (or any area this call didn't cover), make ANOTHER \`<tool>\` targeting those names \u2014 it returns the same source with line numbers and is cheaper and more complete than reading.`,impact:"---\n\n> **Risk: <riskLevel>**. Before editing `<root>`, review d=1 first \u2014 those WILL BREAK.\n> Use `<tool>` to read full source of any direct caller.",context:"---\n\n> **Use `impact` for blast-radius analysis. Use `explore` to read source.**",default:`---
|
|
37
|
-
|
|
38
|
-
> **Output truncated to budget; the content above is the source of truth.**
|
|
39
|
-
> For more detail, call \`<tool>\` with refined parameters.`};async function M(e,t){let{pendingFiles:r,toolName:o,sync:l=false}=t;if(e.length===0)return w(o,"No matches found.","Try broader search terms, or use `explore` to read source.");let a=Qe(e),c=new Set(a.keys()),s=[];s.push(v(r,c)??"");let d="[[codebase-search-summary]]";s.push(d+`
|
|
40
|
-
`);let n=e.length;s.push(`**Files with matches:** ${a.size}
|
|
41
|
-
`);for(let[g,p]of a){let f=p.map(x=>x.node.name),b=f.slice(0,5).join(", "),E=f.length>5?`, +${f.length-5} more`:"";s.push(`**\`${g}\`** \u2014 ${b}${E}
|
|
42
|
-
`);let I=p[0]?.node.language??"";s.push("```"+I);for(let x of p)s.push(`L${x.node.startLine} ${x.snippet}`);s.push("```\n");}s.push(D("search",o,{}));let i=s.join(`
|
|
43
|
-
`),m=`Found ${n} symbol${n===1?"":"s"} across ${a.size} file${a.size===1?"":"s"}.`,u=i.replace(d,m);return F(u,t,l)}async function H(e,t,r){let{pendingFiles:o,toolName:l,sync:a=false}=r;if(t.length===0||t.every(n=>n.count===0))return w(l,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let c=t.reduce((n,i)=>n+i.count,0),s=Ge(c),d=[];d.push(v(o,new Set([e.filePath]))??""),d.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${c})
|
|
44
|
-
`);for(let n of t){d.push(`- **d=${n.depth}** (${n.count} nodes) \u2014 ${n.riskLabel}`);for(let i of n.samples.slice(0,5))d.push(` - \`${i.name}\` ${i.file}:${i.line} [${i.relation}]`);n.samples.length>5&&d.push(` - ... and ${n.samples.length-5} more`);}return d.push(D("impact",l,{root:e.name,riskLevel:s})),F(d.join(`
|
|
45
|
-
`),r,a)}function Ge(e){return e>=100?"CRITICAL":e>=50?"HIGH":e>=10?"MEDIUM":"LOW"}function G(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function Q(e,t){let{root:r,incoming:o,outgoing:l,neighbors:a}=e,{pendingFiles:c,toolName:s,sync:d=false}=t;if(o.length===0&&l.length===0&&a.length===0)return w(s,`No relations found for \`${r.name}\`.`,"This is a leaf node.");let n=[];n.push(v(c,new Set([r.filePath]))??""),n.push(`**Context for \`${r.name}\`** (${r.astType}, ${r.language}, ${r.filePath}:${r.startLine})
|
|
46
|
-
`),n.push(`**Incoming** (${o.length}):`);for(let i of o.slice(0,10))n.push(`- ${i.source} \u2192 [${i.relation}] \u2192 \`${r.name}\``);o.length>10&&n.push(`- ... and ${o.length-10} more`),n.push(""),n.push(`**Outgoing** (${l.length}):`);for(let i of l.slice(0,10))n.push(`- \`${r.name}\` \u2192 [${i.relation}] \u2192 ${i.target}`);if(l.length>10&&n.push(`- ... and ${l.length-10} more`),n.push(""),a.length>0){n.push(`**Neighbors** (${a.length}):`);for(let i of a.slice(0,20))n.push(`- [d=${i.depth}] \`${i.node.name}\` (${i.node.astType}) ${i.node.filePath}:${i.node.startLine}`);a.length>20&&n.push(`- ... and ${a.length-20} more`),n.push("");}return n.push(D("context",s,{})),F(n.join(`
|
|
47
|
-
`),t,d)}async function q(e,t,r){let{pendingFiles:o,toolName:l,sync:a=false}=r;if(!e.id)return w(l,"Node not found.","Check the node ID or use `search` to find it.");let c=t.filter(n=>n.direction==="in"),s=t.filter(n=>n.direction==="out"),d=[];d.push(v(o,new Set([e.filePath]))??""),d.push(`**Node: \`${e.name}\`**
|
|
48
|
-
`),d.push(`- ID: \`${e.id}\``),d.push(`- Kind: ${e.astType}`),d.push(`- Language: ${e.language}`),d.push(`- Location: ${e.filePath}:${e.startLine}-${e.endLine}`),d.push(`- Exported: ${e.isExported}`),e.modifiers.length>0&&d.push(`- Modifiers: ${e.modifiers.join(", ")}`),d.push(""),d.push(`**Edges** (incoming: ${c.length} / outgoing: ${s.length}):`);for(let n of c.slice(0,5))d.push(`- \u2190 [${n.relation}] ${n.source}`);for(let n of s.slice(0,5))d.push(`- \u2192 [${n.relation}] ${n.target}`);return t.length>10&&d.push(`- ... and ${t.length-10} more`),d.push(D("default",l,{})),F(d.join(`
|
|
49
|
-
`),r,a)}async function B(e,t,r,o,l){let{toolName:a,sync:c=false}=l,s=r==="callers"?"Callers":"Callees",d="of",n=r==="callers"?"Use `node <name>` to read full source of any caller.":"Use `node <name>` to read full source of any callee.",i=t?.name??"?";if(e.length===0)return w(a,`**${s} ${d} \`${i}\`** (0)`,r==="callers"?"This symbol has no callers \u2014 safe to refactor.":"This symbol has no outgoing calls \u2014 leaf node.");let m=[];m.push(`**${s} ${d} \`${i}\`** (${e.length}${o?"+":""})
|
|
50
|
-
`);for(let u of e.slice(0,10)){let g=u.filePath==="(unresolved)",p=g?u.filePath:`${u.filePath}:${u.startLine}`,f=g?" _(wildcard)_":"";m.push(`- [${u.relation}] \`${u.name}\` ${p}${f}`);}return e.length>10&&m.push(`- ... and ${e.length-10} more`),m.push(`
|
|
51
|
-
---
|
|
52
|
-
> ${n}`),F(m.join(`
|
|
53
|
-
`),l,c)}async function me(e,t){let{entryPoints:r,totalHits:o,query:l}=e,{toolName:a,sync:c=false}=t;if(r.length===0)return w(a,`No matches for \`${l}\`.`,"Try broader search terms, or use `callers` / `callees` to traverse from a known symbol.");let s=[];s.push(`## Code Context
|
|
54
|
-
`),s.push(`**Query:** ${l} `),s.push(`**Total hits:** ${o} `),s.push(`**Entry points:** ${r.length}
|
|
55
|
-
`);for(let d of r){s.push(`**\`${d.file}\`** \u2014 ${d.symbols.length} symbol${d.symbols.length===1?"":"s"}
|
|
56
|
-
`);for(let n of d.symbols){let i=(n.source??"").trim()||"(source not included)",m=n.node.language;if(s.push("```"+m),s.push(`L${n.node.startLine}-L${n.node.endLine} ${n.node.name} (${n.node.astType}${n.node.modifiers.length>0?`, ${n.node.modifiers.join(" ")}`:""})`),s.push(""),s.push(i),s.push("```\n"),n.callers.length>0){s.push(`**Callers of \`${n.node.name}\` (${n.callers.length}):**`);for(let u of n.callers.slice(0,5))s.push(`- [${u.relation}] \`${u.name}\` ${u.filePath}:${u.startLine}`);n.callers.length>5&&s.push(`- ... and ${n.callers.length-5} more`),s.push("");}if(n.callees.length>0){s.push(`**Callees of \`${n.node.name}\` (${n.callees.length}):**`);for(let u of n.callees.slice(0,5))s.push(`- [${u.relation}] \`${u.name}\` ${u.filePath}:${u.startLine}`);n.callees.length>5&&s.push(`- ... and ${n.callees.length-5} more`),s.push("");}}}return s.push(`---
|
|
57
|
-
`),s.push(D("context",a,{})),F(s.join(`
|
|
58
|
-
`),t,c)}function Qe(e){let t=new Map;for(let r of e){let o=r.node.filePath,l=t.get(o);l?l.push(r):t.set(o,[r]);}return t}function w(e,t,r){return `**${e}**
|
|
59
|
-
|
|
60
|
-
${t}
|
|
61
|
-
|
|
62
|
-
> **Tip:** ${r}`}async function F(e,t,r){let o={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:r?false:t.writeToDisk};return (r?k(e,o):await O(e,o)).content}var Ve=Log.create({service:"codebase-format-render"});async function Xe(e,t){if(e.length===0)return M([],t);let r=K(e);return M(r,t)}async function Je(e,t,r){if(t.length===0)return H(R(e),[],r);let o=[{depth:1,count:t.length,riskLabel:G(1),samples:t.slice(0,10).map(l=>({name:l.source.name,file:R(l.source).filePath,line:l.source.start_line??0,relation:l.relation}))}];return H(R(e),o,r)}async function Ze(e,t,r,o,l){let a=R(e),c=t.map(n=>_(n,"in")),s=r.map(n=>_(n,"out")),d=o.map(n=>({node:R(n),depth:1}));return Q({root:a,incoming:c,outgoing:s,neighbors:d},l)}async function et(e,t){return B(e.callers,e.root,"callers",e.truncated,t)}async function tt(e,t){return B(e.callees,e.root,"callees",e.truncated,t)}async function nt(e,t){let{renderKnowledgeStatus:r}=await import('@easbot/terminal');return r({packageName:"codebase",rootDir:e.workspaceDir,configPath:e.configPath??"",configExists:typeof e.configExists=="boolean"?e.configExists:false,dbPath:e.dbPath,dbExists:typeof e.dbExists=="boolean"?e.dbExists:true,dbSize:e.dbSize,indexState:e.indexState,schemaVersion:(()=>{let o=e.meta?.schema_version;return o&&Number.isFinite(Number.parseInt(o,10))?Number.parseInt(o,10):void 0})(),extractionVersion:e.extractionVersion,lastSyncAt:e.lastSync,vectorEnabled:typeof e.vectorEnabled=="boolean"?e.vectorEnabled:false,embeddingDims:typeof e.embeddingDims=="number"?e.embeddingDims:void 0,llm:e.llm??{initialized:false,capabilities:{}},healthy:e.healthy,dbStats:e.dbStats,extras:(()=>{let o={};if(e.isStale===true&&(o.stale="yes \u2014 reindex recommended"),typeof e.ftsAvailable=="boolean"&&(o.fts_available=e.ftsAvailable?"yes":"no"),e.meta&&typeof e.meta=="object")for(let[l,a]of Object.entries(e.meta))a!=null&&(o[`meta/${l}`]=String(a));return Object.keys(o).length>0?o:void 0})()})}async function rt(e,t,r){if(!e)return q(j(),[],r);let o=R(e),l=t.map(a=>{let c=a.target===e.id?"in":"out";return _(a,c)});return q(o,l,r)}async function ot(e,t){let r={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(o=>({file:o.file,symbols:o.symbols.map(l=>({node:R(l.node),source:l.node.text??"",callers:l.callers.map(a=>({name:a.name,filePath:a.filePath,startLine:a.startLine,relation:a.relation})),callees:l.callees.map(a=>({name:a.name,filePath:a.filePath,startLine:a.startLine,relation:a.relation}))}))}))};return me(r,t)}Ve.debug("format/render.ts loaded");export{Ze as A,et as B,tt as C,nt as D,rt as E,ot as F,ne as a,Ce as b,Le as c,$e as d,_e as e,we as f,Fe as g,Ae as h,De as i,Me as j,R as k,_ as l,K as m,j as n,W as o,je as p,O as q,k as r,M as s,H as t,G as u,Q as v,q as w,B as x,Xe as y,Je as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var n=Object.defineProperty;var c=(t,e,r)=>e in t?n(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var m=(t,e,r)=>c(t,typeof e!="symbol"?e+"":e,r);var o=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,u=o();exports.a=m;exports.b=u;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {homedir}from'os';import {Filesystem}from'@easbot/utils';import {xdgData,xdgState,xdgCache,xdgConfig}from'xdg-basedir';var o=null,r=null;function h(t){o=t;}function j(){o=null;}function n(){if(o)return o;let t=Filesystem.normalize(homedir()),i=xdgData??Filesystem.join(t,".local","share");return {Path:{home:t,data:process.env.EASBOT_DATA_PATH?.trim()||Filesystem.join(i,"easbot"),config:process.env.EASBOT_CONFIG_PATH?.trim()||(xdgConfig?Filesystem.join(xdgConfig,"easbot"):Filesystem.join(t,".config","easbot")),state:process.env.EASBOT_STATE_PATH?.trim()||(xdgState??Filesystem.join(i,"easbot","state")),cache:process.env.EASBOT_CACHE_PATH?.trim()||(xdgCache?Filesystem.join(xdgCache,"easbot"):Filesystem.join(t,".cache","easbot")),log:process.env.EASBOT_LOG_PATH?.trim()||(xdgState??Filesystem.join(i,"easbot","log")),bin:process.env.EASBOT_BIN_PATH?.trim()||Filesystem.join(t,".local","bin")}}}function x(t){r=t;}function T(){r=null;}function g(){if(r)return r;let t=Filesystem.normalize(process.cwd());return {directory:t,worktree:t}}function l(){return n().Path.home||Filesystem.normalize(homedir())}function d(){let t=n().Path.data;return t||(xdgData??Filesystem.join(l(),".local","share"))}function _(){let t=n().Path.config;return t||(xdgConfig??Filesystem.join(l(),".config"))}function P(){let t=n().Path.state;return t||(xdgState??Filesystem.join(d(),"state"))}function v(){let t=n().Path.cache;return t||(xdgCache??Filesystem.join(l(),".cache"))}function G(){return Filesystem.normalize(g().directory||process.cwd())}export{h as a,j as b,n as c,x as d,T as e,g as f,l as g,d as h,_ as i,P as j,v as k,G as l};
|