@easbot/codebase 0.3.29 → 0.3.32
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-D7NVUXB2.mjs +1 -0
- package/dist/chunks/cache-LSQZJEDR.cjs +1 -0
- package/dist/chunks/{chunk-4XKCGYFF.mjs → chunk-33DIOGLJ.mjs} +22 -22
- package/dist/chunks/chunk-37KKG3UK.mjs +48 -0
- package/dist/chunks/chunk-43WAI4Z7.mjs +1 -0
- package/dist/chunks/chunk-CLUGDJA5.cjs +62 -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-H4VZF3ZQ.mjs +1 -0
- package/dist/chunks/chunk-J7Z3MIR7.cjs +1 -0
- package/dist/chunks/chunk-JEHVBEBS.cjs +1 -0
- package/dist/chunks/chunk-KFESJR3T.cjs +1 -0
- package/dist/chunks/chunk-KR6BQNY6.mjs +203 -0
- package/dist/chunks/chunk-KTSR5VPT.mjs +1 -0
- package/dist/chunks/chunk-OJK5EFPD.cjs +48 -0
- package/dist/chunks/{chunk-YJK7F6NJ.cjs → chunk-OZYQQS63.cjs} +22 -22
- package/dist/chunks/chunk-PRPBK7D6.mjs +62 -0
- package/dist/chunks/chunk-T6KJWYTV.mjs +1 -0
- package/dist/chunks/chunk-TBDAGLC4.cjs +203 -0
- package/dist/chunks/chunk-TMQVJU4I.mjs +1 -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-IQ6ZNLEJ.mjs +1 -0
- package/dist/chunks/cli-handler-WTEPKO4E.cjs +1 -0
- package/dist/chunks/code-base-5BXR4FUU.cjs +1 -0
- package/dist/chunks/code-base-M4EMTQTG.mjs +1 -0
- package/dist/chunks/database-manager-KM7BOISA.mjs +1 -0
- package/dist/chunks/database-manager-LTHK7MM6.cjs +1 -0
- package/dist/chunks/file-watcher-2MUX5MO5.cjs +1 -0
- package/dist/chunks/file-watcher-ABFT22GS.mjs +1 -0
- package/dist/chunks/{interfaces-S7TJGWWS.mjs → interfaces-43SSCG3E.mjs} +1 -1
- package/dist/chunks/interfaces-LUHDPZOT.cjs +1 -0
- package/dist/chunks/llm-S6D5ICOO.cjs +1 -0
- package/dist/chunks/llm-WS3XKT46.mjs +1 -0
- package/dist/chunks/{stdio-server-DFKFFRSM.cjs → stdio-server-KA3JQB7C.cjs} +2 -2
- package/dist/chunks/stdio-server-QP63TXGI.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 +8 -9
- 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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {g,F,f,e as e$1,d as d$1,b as b$1}from'./chunk-PRPBK7D6.mjs';import {b}from'./chunk-ETCTXAXR.mjs';import {c,e,a as a$1,d}from'./chunk-TMQVJU4I.mjs';import {a,c as c$1,b as b$5,e as e$3,d as d$3}from'./chunk-KR6BQNY6.mjs';import {b as b$3,e as e$2,c as c$3,a as a$2,d as d$2,f as f$1}from'./chunk-33DIOGLJ.mjs';import {b as b$4}from'./chunk-KTSR5VPT.mjs';import {a as a$3}from'./chunk-ESA2CL57.mjs';import {b as b$2,c as c$2}from'./chunk-T6KJWYTV.mjs';import {existsSync,readFileSync,copyFileSync,rmSync,statSync,mkdirSync}from'fs';import {Log,errorMeta,resolveLocaleLang,NameErrors,ServiceError}from'@easbot/utils';import {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 {join,dirname}from'path';import {resolveSqlTextLimit}from'@easbot/database';import {fileURLToPath}from'url';import {ServerTransportType}from'@easbot/mcp';var te=Log.create({service:"codebase.init"});function _e(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 I(o={}){let e=await b.getRootDir();try{let m=await e$3();m.source==="monorepo"?te.debug("better-sqlite3 resolved (monorepo)",{path:m.absolutePath}):te.debug("better-sqlite3 auto-installed to cache",{source:m.source,path:m.absolutePath});}catch(m){te.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 b.getConfigPath(),i=c$1(e);if(await b.exists()&&!o.force)return {configPath:t,dbPath:i,created:false,skipped:true,backend:"better-sqlite3",schemaVersion:a$2,migrationsApplied:0,tablesCreated:0,durationMs:0};if(existsSync(n)||mkdirSync(n,{recursive:true}),await b.writeCodebaseJson({version:1,schema_version:a$2,extraction_version:e$2,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$3(e);let r=false,l=0,s=0,a$1=Date.now(),d=new f$1(i);try{let m=d.getMeta("index_state"),h=d.getMeta("createdAt"),p=d.getMeta("version"),w=d.getMeta("indexed_with_version");r=m!==null&&h!==null&&p!==null&&w!==null;try{l=d.countSqliteObjects();}catch{}let u=d.getMeta("schema_version");s=u?Number.parseInt(u,10)||a$2:a$2;}finally{d.close();}let c=Date.now()-a$1;return {configPath:t,dbPath:i,created:true,skipped:false,metaInitialized:r,backend:"better-sqlite3",schemaVersion:a$2,migrationsApplied:s,tablesCreated:l,durationMs:c}}async function V(o){let e=await b.getRootDir(),t=await b.getConfigPath(),i=c$1(e),r=await b.exists(),l=existsSync(i),s;if(l)try{s=statSync(i).size;}catch{}let a={initialized:false,capabilities:{embedding:false,evaluation:false}},d={},c,m,h,p=0,w=0,u,E,x,f=false,k,g=false,y;if(r)try{let v=await b.getCodebaseJson();v&&(c=v.index_state,E=v.schema_version,m=v.extraction_version,u=v.backend);}catch{}if(l&&i)try{let{DatabaseManager:v}=await import('./database-manager-KM7BOISA.mjs'),F=new v(i);try{let P=F.getStatus();c=P.indexState??c,m=P.extractionVersion??m,h=P.isStale,p=P.nodeCount,w=P.edgeCount;for(let[Z,co]of Object.entries(P.meta))d[Z]=co;k=P.meta.lastSyncAt,E=parseInt(P.meta.schema_version??"",10)||E,u=P.meta.backend??u,f=P.meta.vector_enabled==="true"||P.meta.vector_enabled==="1",x=parseInt(P.meta.embeddingDims??"",10)||void 0;try{let{stats:Z}=F.checkIntegrity();y={...Z};}catch{}g=F.isFtsAvailable();}finally{F.close();}}catch{}let S=a$3.isInitialized();if(S){a.initialized=true;let v=a$3.capabilities();a.capabilities={embedding:v.embedding===true,evaluation:v.evaluation===true},a.embeddingModel=a.capabilities.embedding?"configured":void 0,a.evaluationModel=a.capabilities.evaluation?"configured":void 0;}if(S&&a.capabilities.embedding&&i)try{let v=await a$3.probeEmbeddingDims({timeoutMs:5e3});if(typeof v=="number"){x=v;try{let{DatabaseManager:F}=await import('./database-manager-KM7BOISA.mjs'),P=new F(i);try{syncMeta(P,[["embeddingDims",String(v)]]);}finally{P.close();}}catch{}}}catch{}let j=l&&r&&!h&&c!=="failed"&&c!=="stale",C;return r?l?c==="failed"?C="Last sync failed \u2014 run `easbot codebase index` to retry.":h?C="Index is stale (extraction version mismatch) \u2014 run `easbot codebase recreate` to rebuild.":c==="uninitialized"?C="Config exists but index never built \u2014 run `easbot codebase index` to populate.":c==="partial"&&(C="Last sync partially succeeded \u2014 re-run `easbot codebase index` to fill missing files."):C="Run `easbot codebase index` to build the index.":C="Run `easbot codebase init` to initialize the configuration.",{package:"codebase",rootDir:e,dbPath:i,dbSize:s,configPath:t,configExists:r,schemaVersion:E,extractionVersion:m,lastSyncAt:k,indexState:c,vectorEnabled:f,embeddingDims:x,llm:a,backend:u,meta:d,recommendation:C,healthy:j,dbStats:y,dbExists:l,nodeCount:p,edgeCount:w,ftsAvailable:g}}var M=()=>Date.now();async function Ne(o){let e=M(),n=await V(),t=[],i,r=M(),l;if(n.dbExists?n.configExists?l=O("database","ok",`db readable at ${n.dbPath}`,Date.now()-r):l=O("database","warn","config not found \u2014 run `easbot codebase init` first",Date.now()-r):l=O("database","info","db not initialized \u2014 run `easbot codebase index` to build",Date.now()-r),t.push(l),n.dbExists){let u=M();t.push(O("fts","ok","fts sync checked in integrity pass",Date.now()-u));}if(n.dbExists){let u=M();t.push(O("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=M();t.push(O("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(O("lock","ok","no lock contention observed",0)),t.push(O("disk_space","ok","no disk space check (v0.5.1 placeholder)",0));let s=M(),a={"better-sqlite3":false,"node:sqlite":false,"@tursodatabase/database":false},d=createRequire(import.meta.url);try{d.resolve("better-sqlite3"),a["better-sqlite3"]=!0;}catch{}a["node:sqlite"]=typeof process.versions.sqlite=="string";try{d.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(O("backend",c,m,Date.now()-s));let h=M(),p;if(!n.llm.initialized||!n.llm.capabilities.embedding)p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","llm not initialized; probe skipped",Date.now()-h);else if(!n.dbExists)p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","db not initialized; probe skipped",Date.now()-h);else try{let u=await a$3.probeEmbeddingDims({timeoutMs:5e3});typeof u!="number"?p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info","probe failed (network / model error)",Date.now()-h):n.embeddingDims===void 0?p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info",`probe=${u}, meta missing \u2014 next status will sync`,Date.now()-h):u!==n.embeddingDims?p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"warn",`probe=${u} but meta.embeddingDims=${n.embeddingDims} (drift detected)`,Date.now()-h,{probed:u,recorded:n.embeddingDims}):p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"ok",`probe=${u} matches meta`,Date.now()-h,{probed:u});}catch(u){p=O(EMBEDDING_DIMS_CONSISTENCY_CHECK,"info",`probe threw: ${errorMeta(u).message}`,Date.now()-h);}if(t.push(p),n.dbExists){let u=M();try{let{DatabaseManager:E}=await import('./database-manager-KM7BOISA.mjs'),x=new E(n.dbPath);try{let{issues:f,stats:k}=x.checkIntegrity();i=k;for(let g of f)t.push(O("integrity_stats",g.severity,g.message,0,{source:"database.checkIntegrity"}));i.parse_errors===0&&t.push(O("parse_errors_zero","info","parse_errors: 0 (no parse errors recorded)",0)),i.unresolved_refs===0&&t.push(O("unresolved_refs_zero","info","unresolved_refs: 0 (resolution pipeline not active)",0)),i.name_segment_vocab===0&&t.push(O("name_segment_vocab_zero","info","name_segment_vocab: 0 (identifier-segments not active)",0)),i.project_metadata===0&&t.push(O("project_metadata_zero","info","project_metadata: 0 (CodeBase.initialize not run)",0));}finally{x.close();}}catch(E){t.push(O("integrity_stats","warn",`db integrity check failed: ${errorMeta(E).message}`,Date.now()-u));}}let w=M();if(!n.llm.initialized)t.push(O("llm","info","Llm namespace not initialized (calls `easbot codebase init` first)",Date.now()-w));else {let u=[];n.llm.capabilities.embedding||u.push("embedding"),n.llm.capabilities.evaluation||u.push("evaluation"),t.push(O("llm",u.length===0?"ok":"info",u.length===0?"embedding + evaluation configured":`missing capabilities: ${u.join(", ")}`,Date.now()-w,{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 O(o,e,n,t,i){return {code:o.toUpperCase().replace(/[^A-Z0-9]+/g,"_"),severity:e,name:o,message:n,details:i,durationMs:t}}var Co=Log.create({service:"codebase.cmd.index"});function ve(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){var E=[];try{let e=await b.getRootDir();let n=a(e);let t=b$5(e);await I();let{CodeBase:i}=await import('./code-base-M4EMTQTG.mjs');let{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s}=await import('@easbot/types');let a$1=o.batch??l.batchSize??50;let d=new i({workspaceDir:e,database:{path:c$1(e),walMode:!0},embedding:o.noEmbed===!1?r:void 0,indexer:{...l,batchSize:a$1},parser:s,sync:{onBoot:!1,onSearch:!1,onSessionStart:!1,intervalMs:0}});let c=Date.now();let m=b$2(E,Co.time("codebaseIndex",{level:"DEBUG"}));let h=-1;let p=0;let w=!o.quiet;let u;try{await d.initialize(),registerActiveProgressLine(process.stderr);let g=await d.indexDirectory(e,w?y=>{let S=Math.max(y.total,1),j=Math.min(100,Math.floor(y.processed/S*100)),C=Date.now();if(j!==h||C-p>3e4){let F=String(j).padStart(3," ");clearActiveProgressLine(),process.stderr.write(` \u{1F4A1} [${F}%] ${y.stage}: ${y.processed}/${y.total} files`),h=j,p=C;}}:void 0);u={rootDir:e,success:g.success,filesProcessed:g.filesProcessed,nodesCreated:g.nodesCreated,edgesCreated:g.edgesCreated,errorCount:g.errors.length,errors:g.errors,durationMs:g.duration,embedded:!o.noEmbed,batchSize:a$1};}finally{clearActiveProgressLine(),unregisterActiveProgressLine(process.stderr),await d.close();}return u}catch(x){var f=x,k=true;}finally{c$2(E,f,k);}}function Ie(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 je(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 Te(o){let e=await b.getRootDir(),n=c$1(e),{CodeBase:t}=await import('./code-base-M4EMTQTG.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,d={_lastPct:-1,_lastProgressAt:0};try{await s.initialize(),registerActiveProgressLine(process.stderr);let c=await s.sync(o.quiet?void 0:h=>{let p=Math.max(h.total,1),w=Math.min(100,Math.floor(h.processed/p*100)),u=Date.now(),E=w!==d._lastPct,x=u-d._lastProgressAt>3e4;if(E||x){let f=String(w).padStart(3," ");clearActiveProgressLine(),process.stderr.write(` \u{1F4A1} [${f}%] ${h.stage}: ${h.processed}/${h.total} files`),d._lastPct=w,d._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 $e(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 Me(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 Le(o){let e=await b.getRootDir();a(e);let t=c$1(e),i=b$5(e),r=false,l=false;for(let d of [t,`${t}-wal`,`${t}-shm`])if(existsSync(d))try{rmSync(d,{force:!0}),d===t&&(r=!0);}catch{}if(!o.keepConfig&&existsSync(i))try{rmSync(i,{force:!0}),l=!0;}catch{}await I({force:true});let s=false,a$1;if(!o.noReindex){let d=await H({noEmbed:o.noEmbed,quiet:true});s=true,a$1={filesProcessed:d.filesProcessed,nodesCreated:d.nodesCreated,edgesCreated:d.edgesCreated,durationMs:d.durationMs,embedded:d.embedded};}return {rootDir:e,removedDb:r,removedConfig:l,recreated:true,reindexed:s,configPath:i,indexSummary:a$1}}function Ae(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 qe(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 Ue(o){let e=await b.getRootDir();a(e);let t=c$1(e),i=b$5(e);if(!existsSync(t))return await I(),{rootDir:e,cleared:false,nodesRemoved:0,edgesRemoved:0,filesRemoved:0,embeddingsPreserved:false,configPreserved:existsSync(i),nextIndexState:"uninitialized"};let{CodeBase:r}=await import('./code-base-M4EMTQTG.mjs'),{DEFAULT_EMBEDDING_CONFIG:l,DEFAULT_INDEXER_CONFIG:s,DEFAULT_PARSER_CONFIG:a$1}=await import('@easbot/types'),d=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 d.initialize();let m={nodes:d.getDatabase().getNodeCount(),edges:d.getDatabase().getEdgeCount(),files:d.getDatabase().getFileCount()};await d.clear({keepEmbeddings:!!o.keepEmbeddings}),d.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 d.close();}return c}function Be(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 Ge=new Set(["backend","schema_version","extraction_version"]);function _o(o){return new Set(["schema_version","extraction_version"]).has(o)?"number":"string"}function ze(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 ko=new Set(["backend","schema_version","extraction_version"]);async function We(o){let e=await b.getConfigPath(),n=await b.exists(),t={rootDir:await b.getRootDir(),configPath:n?e:void 0,exists:n,values:null};if(!n)return t;let i=await b.getCodebaseJson();return i?(o.key?(t.key=o.key,t.value=i[o.key]):t.values={...i},t):{...t,exists:false}}async function Je(o){if(!o.key)throw new b$4.ConfigError({message:"config set requires <key>"});if(o.value===void 0)throw new b$4.ConfigError({message:"config set requires <value> after <key>",field:o.key});if(!Ge.has(o.key))throw new b$4.ConfigError({message:`Unsupported config key: "${o.key}". Allowed: ${Array.from(Ge).join(", ")}`,field:o.key});let e=await b.getConfigPath();if(!await b.exists())throw new b$4.ConfigError({message:`codebase not initialized at ${await b.getRootDir()} \u2014 run \`easbot codebase init\` first`});let n=o.value;if(_o(o.key)==="number"){let l=Number(o.value);if(!Number.isFinite(l))throw new b$4.ConfigError({message:`config key "${o.key}" expects a number, got "${o.value}"`,field:o.key});n=l;}let i=await b.getCodebaseJson()??{},r=i[o.key];return i[o.key]=n,await b.writeCodebaseJson(i),{rootDir:await b.getRootDir(),configPath:e,key:o.key,oldValue:r,newValue:n,requiresRestart:ko.has(o.key)}}function Ke(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 Ve(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 Qe(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 Xe(o){let e=await b.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-KM7BOISA.mjs'),r=new i(t);try{let l=r.db,s=r.isIndexStale(),a=r.getMeta("indexed_with_extraction_version"),d=a?parseInt(a,10):null,c=r.getIndexState(),m=r.getMeta("schema_version"),h=m?parseInt(m,10):0,p={rootDir:e,dbPath:t,wasStale:s,previousVersion:d??null,currentVersion:e$2,applied:!1,schemaMigrated:!1,previousSchemaVersion:h,currentSchemaVersion:h,dryRun:!!o.dryRun,schemaSteps:b$3.map(f=>({id:f.id,description:f.description,status:"pending"})),migrationErrors:[],indexState:c},w;if(o.backup!==!1&&!o.dryRun)try{let f=new Date().toISOString().replace(/[:.]/g,"-");w=join(n,`codebase.db.bak.${f}`),copyFileSync(t,w);for(let k of ["-wal","-shm"]){let g=t+k;existsSync(g)&©FileSync(g,w+k);}p.backupPath=w;}catch(f){let k=errorMeta(f).message;p.recommendation=`Backup failed: ${k}. Continuing without backup.`;}let E=o.schema!==!1;try{let f=c$3(l,a$2,{dryRun:o.dryRun});p.currentSchemaVersion=o.dryRun?f.targetVersion:Math.max(f.currentVersion,f.targetVersion),p.migrationErrors=f.errors.map(g=>({migrationId:g.migrationId,error:g.error}));let k=new Set(f.applied);for(let g of p.schemaSteps)k.has(g.id)&&(g.status=o.dryRun?"pending":"applied");for(let g of p.migrationErrors){let y=p.schemaSteps.find(S=>S.id===g.migrationId);y&&(y.status="failed");}if(p.schemaMigrated=f.applied.length>0&&!o.dryRun,!o.dryRun){let g=d$2(l);p.currentSchemaVersion=g,g>0&&r.setMeta("schema_version",String(g));}}catch(f){let k=errorMeta(f).message;p.migrationErrors.push({migrationId:0,error:k});}let x=s||o.force;return x&&!o.dryRun&&(r.setMeta("indexed_with_extraction_version",String(e$2)),(c==="stale"||c==="failed")&&(r.setIndexState("complete"),p.indexState="complete"),p.applied=!0),o.dryRun?p.migrationErrors.length>0?p.recommendation="dry-run finished. Run without --dry-run to apply.":p.schemaMigrated?p.recommendation="dry-run: schema migration would apply. Run without --dry-run to apply.":p.recommendation="dry-run: nothing to apply.":!x&&!p.schemaMigrated&&p.migrationErrors.length===0?p.recommendation=`Already current (schema_version=${p.currentSchemaVersion}, extraction_version=${e$2}). No upgrade needed.`:p.migrationErrors.length>0?p.recommendation=`Schema migration completed with ${p.migrationErrors.length} error(s). `+(p.backupPath?`Restore from backup: ${p.backupPath}`:"Re-run `recreate` to drop & rebuild."):p.schemaMigrated&&!x?p.recommendation=`Schema migrated (v${p.previousSchemaVersion} \u2192 v${p.currentSchemaVersion}). To apply extraction changes, run \`recreate\` to rebuild data or \`index --force\`.`:p.schemaMigrated&&x?p.recommendation="Schema + extraction metadata both updated. To rebuild data with new extractor, run `recreate` or `index --force`.":p.recommendation="Extraction metadata updated. No schema changes needed.",p}finally{r.close();}}function Ze(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
|
+
`)}var Io=Log.create({service:"codebase.cmd.embed"});function tt(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 Oo=200;function jo(o,e=Oo){return o?o.length<=e?o:o.slice(0,e)+"\u2026":""}async function ot(o){var p=[];try{let e=await b.getRootDir();let n=a(e);let 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();let r=b$2(p,Io.time("codebaseEmbed",{level:"DEBUG",dbPath:t}));let l=process.env.EASBOT_EMBEDDING_MODEL;if(!o.dryRun&&!l)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:s}=await import('./code-base-M4EMTQTG.mjs');let{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:d,DEFAULT_PARSER_CONFIG:c}=await import('@easbot/types');let m={...a$1,modelId:l??"(dry-run)"};let h=new s({workspaceDir:e,database:{path:t,walMode:!0},embedding:m,indexer:d,parser:c,sync:{onBoot:!1,onSearch:!1,onSessionStart:!1,intervalMs:0}});try{await h.initialize();let x=h.getDatabase(),f=x.getNodeCount(),k=x.queryAll("SELECT node_id FROM node_embeddings"),g=new Set(k.map(C=>C.node_id)),y;if(o.all)y=x.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else if(g.size===0)y=x.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else {let C=Array.from(g),v=C.map(()=>"?").join(",");y=x.queryAll(`SELECT id, name, ast_type, language, file_path, text FROM nodes WHERE id NOT IN (${v})`,C);}let S=y.map(C=>({id:C.id,name:C.name,ast_type:C.ast_type,file_path:C.file_path,language:C.language,text_preview:jo(C.text)})),j={rootDir:e,dbPath:t,totalNodes:f,alreadyEmbedded:g.size,newlyEmbedded:0,failed:0,all:!!o.all,dryRun:!!o.dryRun,pendingList:o.pendingList?S:[],duration:Date.now()-i,embeddingModelConfigured:!!l};return o.dryRun?j.recommendation=S.length>0?`dry-run: ${S.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.":S.length===0?j.recommendation="All nodes already have embeddings. Use --all to force regenerate.":j.recommendation=`${S.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).`,j}finally{await h.close();}}catch(w){var u=w,E=true;}finally{c$2(p,u,E);}}function nt(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 st=Log.create({service:"codebase.command.watch"});function it(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 at(o){let e=await b.getRootDir(),n=a(e);existsSync(n)||await I();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),st.debug("watch event",{event:r,relPath:l});let a=`[${new Date(s.at).toISOString()}]`,d=r==="add"?"\x1B[32m+ ADD \x1B[0m":r==="change"?"\x1B[33m~ CHANGE\x1B[0m":"\x1B[31m- UNLINK\x1B[0m";process.stdout.write(`${a} ${d} ${l}
|
|
10
|
+
`);}),await t.start();try{await d(n,process.pid);}catch(r){st.warn("failed to write watcher pid",{error:errorMeta(r)});}return {watcher:t,events:i,startTime:Date.now()}}function rt(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 ct(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 lt(o){let e$1=await b.getRootDir(),n=a(e$1);existsSync(n)||await I();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 dt(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
|
+
`)}var Bo=Log.create({service:"codebase.cmd.query"}),Go=200;function ut(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 mt(o){var h=[];try{let e=await b.getRootDir();let n=a(e);let t=c$1(e);existsSync(n)||await I();if(!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-M4EMTQTG.mjs');let{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s,DEFAULT_SEARCH_CONFIG:a$1}=await import('@easbot/types');let d=new i({workspaceDir:e,database:{path:t,walMode:!0},embedding:o.enableEmbedding?r:void 0,indexer:l,parser:s,search:a$1,sync:{onBoot:!1,onSearch:!1,onSessionStart:!1,intervalMs:0}});let c=Date.now();let m=b$2(h,Bo.time("codebaseQuery",{level:"DEBUG",query:o.query}));try{await d.initialize();let x=await d.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:x.length,results:x.map(f=>({id:f.id,name:f.name,astType:f.ast_type,language:f.language,filePath:f.file_path,startLine:f.start_line??0,endLine:f.end_line??0,snippet:(f.text??"").slice(0,resolveSqlTextLimit(Go)),edgeCount:(f.edges??[]).length})),durationMs:Date.now()-c}}finally{await d.close();}}catch(p){var w=p,u=true;}finally{c$2(h,w,u);}}function gt(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 ht(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 yt(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 b.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await I(),!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$1(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,d=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 p=(c.target.split(":").pop()??"").split("@")[0]??"";m=a$1.includes(".")&&p===a$1||p===d?"in":"out";}else m="out";let h={id:c.id,relation:c.relation,source:c.source,target:c.target,direction:m};(m==="in"?l:s).push(h);}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 xt(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-M4EMTQTG.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 b.getRootDir(),a$1=c$1(s),d=a(s);if(!existsSync(d))if(o.autoInit)await I();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 Ct(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 Et(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 h=[],p=!1;for(;m.length>0;){let f=m.shift();if(f.depth>=e)continue;if(c.size>=n){p=!0;break}let k=a.queryNeighbors(f.nodeId,{direction:t,relationTypes:o.relationTypes,limit:n-c.size+1});for(let g of k.edges){h.push({source:g.source,target:g.target,relation:g.relation});let y=g.source===f.nodeId?g.target:g.source;if(!c.has(y)&&(c.set(y,f.depth+1),m.push({nodeId:y,depth:f.depth+1}),c.size>=n)){p=!0;break}}if(p)break}let w=Array.from(c.keys()),u=w.length>0?s.queryNodes({ids:w}):[],E=new Map(u.map(f=>[f.id,f])),x=[];for(let[f,k]of c.entries()){let g=E.get(f);g&&x.push({id:g.id,name:g.name,astType:g.ast_type,language:g.language,filePath:g.file_path,depth:k});}return {rootDir:r,rootNodeId:o.nodeId,depth:e,totalNodes:x.length,totalEdges:h.length,nodes:x,edges:h,truncated:p}}finally{await l();}}function Rt(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 _t(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 kt(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 Nt(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 Vo="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",Ho=[new RegExp(`(?:^|/)(?:main|index|app|server)\\.(?:${Vo})$`)];function vt(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 It(o){let e=await b.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await I(),!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-M4EMTQTG.mjs'),{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:d,DEFAULT_PARSER_CONFIG:c,DEFAULT_SEARCH_CONFIG:m}=await import('@easbot/types'),h=new s({workspaceDir:e,database:{path:t,walMode:true},embedding:a$1,indexer:d,parser:c,search:m,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await h.initialize();let p=h.getDatabase(),w=h.getQuery(),u=[],E=0,x=["CALLS","IMPORTS","TYPE_REFERENCES"],f=p.queryAll("SELECT DISTINCT target FROM edges WHERE relation IN ('CALLS','IMPORTS','TYPE_REFERENCES')"),k=new Set(f.map(g=>g.target));for(let g of i){let y=p.queryNodes({astType:g,limit:1e5});for(let S of y){if(l&&Ho.some(j=>j.test(S.file_path))){E++;continue}if(!k.has(S.id)&&(u.push({id:S.id,name:S.name,astType:S.ast_type,filePath:S.file_path,startLine:S.start_line??0}),u.length>=r))break}if(u.length>=r)break}return {rootDir:e,totalCandidates:u.length,excludedEntry:E,candidates:u.slice(0,r)}}finally{await h.close();}}function Ot(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 Tt(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 Qo(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 d=o.get(a)??[];for(let c of d)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 $t(o){let e=await b.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await I(),!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-M4EMTQTG.mjs'),{DEFAULT_EMBEDDING_CONFIG:l,DEFAULT_INDEXER_CONFIG:s,DEFAULT_PARSER_CONFIG:a$1,DEFAULT_SEARCH_CONFIG:d}=await import('@easbot/types'),c=new r({workspaceDir:e,database:{path:t,walMode:true},embedding:l,indexer:s,parser:a$1,search:d,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await c.initialize();let m=c.getDatabase(),h=m.queryNodes({limit:1e5}),p=new Map;for(let y of h){let S=p.get(y.file_path)??[];S.push(y.id),p.set(y.file_path,S);}let w=h.map(y=>y.id),u=new Map;for(let y of h)u.set(y.id,y.file_path);let E;if(w.length===0)E=[];else {let y=w.map(()=>"?").join(",");E=m.queryAll(`SELECT * FROM edges WHERE relation = ? AND source IN (${y})`,[i,...w]);}let x=new Map;for(let y of E){let S=u.get(y.source),j=u.get(y.target);if(!S||!j||S===j)continue;let C=x.get(S);C||(C=new Set,x.set(S,C)),C.add(j);}let f=new Map;for(let[y,S]of x.entries())f.set(y,Array.from(S));let g=Qo(f).map(y=>{let S=[];for(let j=0;j<y.length;j++){let C=y[j],v=x.get(C);if(v)for(let F of v)y.includes(F)&&S.push({source:C,target:F});}return {cycle:y,edges:S}});return {rootDir:e,relation:i,totalCycles:g.length,cycles:g.slice(0,50)}}finally{await c.close();}}function Pt(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 Lt(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 At(o){let e=await b.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await I(),!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-M4EMTQTG.mjs'),{DEFAULT_EMBEDDING_CONFIG:s,DEFAULT_INDEXER_CONFIG:a$1,DEFAULT_PARSER_CONFIG:d,DEFAULT_SEARCH_CONFIG:c}=await import('@easbot/types'),m=new l({workspaceDir:e,database:{path:t,walMode:true},embedding:s,indexer:a$1,parser:d,search:c,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await m.initialize();let h=m.getQuery();if(o.fromId===o.toId)return {rootDir:e,found:!0,depth:0,steps:[],pathNodes:[o.fromId]};let p=new Set([o.fromId]),w=new Map,u=[o.fromId],E=!1;e:for(let g=0;g<=i;g++){let y=[];for(let S of u){let j=h.queryNeighbors(S,{direction:"both",relationTypes:r,limit:1e3});for(let C of j.edges){let v=C.source===S?C.target:C.source;if(!p.has(v)){if(p.add(v),w.set(v,{via:S,relation:C.relation}),v===o.toId){E=!0;break e}y.push(v);}}}u.length=0,u.push(...y);}if(!E)return {rootDir:e,found:!1,depth:0,steps:[],pathNodes:[]};let x=[o.toId],f=[],k=o.toId;for(;k!==o.fromId;){let g=w.get(k);if(!g)break;f.unshift({from:g.via,to:k,relation:g.relation}),x.unshift(g.via),k=g.via;}return {rootDir:e,found:!0,depth:f.length,steps:f,pathNodes:x}}finally{await m.close();}}function qt(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 Gt(o){let e={};for(let n of o)(n==="--help"||n==="-h")&&(e.help=true);return e}async function zt(o){let e=await b.getRootDir(),n=a(e),t=c$1(e);if(existsSync(n)||await I(),!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-M4EMTQTG.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:l,DEFAULT_PARSER_CONFIG:s,DEFAULT_SEARCH_CONFIG:a$1}=await import('@easbot/types'),{CodebaseStdioServer:d}=await import('./stdio-server-QP63TXGI.mjs'),c="0.0.0";try{let u=dirname(fileURLToPath(import.meta.url));for(let E=0;E<8;E++){try{let f=JSON.parse(readFileSync(join(u,"package.json"),"utf-8"));if(f?.name==="@easbot/codebase"&&typeof f.version=="string"){c=f.version;break}}catch{}let x=dirname(u);if(x===u)break;u=x;}}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 h={id:"easbot-codebase-mcp",name:"EASBot Codebase MCP",version:c,transportType:ServerTransportType.STDIO},p=await d.start(m,h);return {rootDir:e,tools:p.tools}}var an=Log.create({service:"codebase.command.callers"});function Wt(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 Jt(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 b.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 an.debug("callers command done",{symbol:o.symbol,count:i.callers.length,rootDir:e}),{rootDir:e,serviceResult:i,durationMs:Date.now()-n}}function Kt(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 ln=Log.create({service:"codebase.command.callees"});function Vt(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 Ht(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 b.getRootDir(),n=Date.now(),i=await f({workspaceDir:e,rootDir:e},{name:o.symbol,nodeId:o.nodeId,file:o.file,kind:o.kind,maxResults:o.maxResults});return ln.debug("callees command done",{symbol:o.symbol,count:i.callees.length,rootDir:e}),{rootDir:e,serviceResult:i,durationMs:Date.now()-n}}function Yt(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 un=Log.create({service:"codebase.command.explore"});function Qt(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 Xt(o){if(!o.query)throw new NameErrors.MissingFieldError({field:"query",message:"explore command requires a <query> argument"});let e=await b.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 un.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 Zt(o){let e={pendingFiles:[],toolName:"codebase_explore",writeToDisk:false};return await F(o.serviceResult,e)}var eo={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 gn=eo.languages,fn=gn.filter(o=>o.supported).map(o=>o.value),q={defaultLocale:"zh-CN",locales:fn},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 bn={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}}"}},to=bn;var hn={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}}"}},oo=hn;var yn=()=>{X("zh-CN"),X("en-US"),Q("zh-CN",to),Q("en-US",oo);};yn();var ie=new Map;var ae=new Map;var xn=o=>{if(ae.has(o))return ae.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 ae.set(o,r),r},no=(o,e)=>{if(!o||typeof o!="string")return "";if(!e||Object.keys(e).length===0)return o;let{regex:n,keys:t}=xn(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)})},Sn=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},so=o=>{if(!ie.has(o)){let{resources:e}=X(o);ie.set(o,e);}return ie.get(o)},wn=(o,e={})=>{let n=Sn(e.locale),i=so(n)?.translation[o];if(i&&typeof i=="string"){let r=no(i,e.vars);return r!=null?String(r):String(o)}if(n!==q.defaultLocale){let l=so(q.defaultLocale)?.translation[o];if(l&&typeof l=="string"){let s=no(l,e.vars);return s!=null?String(s):String(o)}}return String(e.fallback??o)},re=wn;var ce=Log.create({service:"codebase.cli"});async function Dn(){try{let{Llm:o}=await import('./llm-WS3XKT46.mjs'),{CodebaseCache:e}=await import('./cache-D7NVUXB2.mjs'),n=await e.getCodebaseJson();o.init({models:{embedding:n?.embedding_model??void 0,evaluation:n?.evaluation_model??void 0},evaluationThreshold:n?.evaluation_threshold});}catch(o){let{errorMeta:e}=await import('@easbot/utils');ce.warn("Llm init failed; Llm-related features will be disabled",{error:e(o)});}}function le(o){return resolveLocaleLang(o?.locale)}function ro(o){let e=(t,i,r)=>re(t,{locale:o,vars:r,fallback:i}),n=(t,i,r)=>{let l=In.filter(s=>s.group===t).map(s=>` ${On(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 vn(o){let e=le(o);console.log(ro(e));}function Ir(o){let e=le(o);console.log(ro(e));}var In=[{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 On(o){return o.length>=18?o:o+" ".repeat(18-o.length)}var ao=false;function jn(){if(ao)return;ao=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 Or(o,e){jn();let n=le(e),t=(s,a,d)=>re(s,{locale:n,vars:d,fallback:a});if(await Dn(),o.length===0)return vn(e),{code:0,handled:false};let i=o[0],r=o.slice(1),l=r.includes("--json");try{switch(i){case "init":{let s=_e(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 I({...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 d={dbPath:a.dbPath};return typeof a.migrationsApplied=="number"&&(d.migrationsApplied=a.migrationsApplied),typeof a.tablesCreated=="number"&&(d.tablesCreated=a.tablesCreated),typeof a.durationMs=="number"&&(d.durationMs=`${a.durationMs}ms`),printHuman([formatKnowledgeInit({packageName:"codebase",configPath:a.configPath,backend:a.backend,schemaVersion:a.schemaVersion,skipped:a.skipped===!0,extras:d})],{title:"init codebase workspace",boxed:!0,skipOutro:a.skipped===!0}),{code:0,handled:!0,command:i}}case "status":{let s=Tn(r),a=await V(s);return s.json?emitJsonOk(a,{healthy:a.healthy}):printHuman([formatKnowledgeStatus(Pn(a))],{title:t("cli.cmd.status.description","Show index state / db / config"),boxed:!0}),{code:0,handled:!0,command:i}}case "doctor":{let s=$n(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 Ne(s);return s.json?emitJsonOk(a,{healthy:a.healthy,checkCount:a.checks.length,issueCount:a.issues.length,errorCount:a.checks.filter(d=>d.severity==="error").length,warnCount:a.checks.filter(d=>d.severity==="warn").length}):printHuman([formatKnowledgeDoctor(Fn(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=ve(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([Ie(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=je(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 Te(s);return s.json?emitJsonOk(a,{success:a.success,quiet:s.quiet===!0}):printHuman([$e(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=Me(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 Le(s);return s.json?emitJsonOk(a,{keepConfig:s.keepConfig===!0,force:s.force===!0}):printHuman([Ae(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=qe(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 Ue(s);return s.json?emitJsonOk(a,{keepEmbeddings:s.keepEmbeddings===!0,force:s.force===!0}):printHuman([Be(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=ze(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 We(s);return s.json?emitJsonOk(a,{subcommand:"get",key:s.key??null}):printHuman([Ke(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 Je(s);return s.json?emitJsonOk(a,{subcommand:"set",key:s.key??null}):printHuman([Ve(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=Qe(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 Xe(s);return s.json?emitJsonOk(a,{schema:s.schema===!0,force:s.force===!0}):printHuman([Ze(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=tt(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 ot(s);return s.json?emitJsonOk(a,{all:s.all===!0,dryRun:!0,pendingList:s.pendingList===!0,batchSize:s.batchSize??null}):printHuman([nt(a)],{title:t("cli.cmd.embed.description","Inspect node embeddings (statistical only)")}),{code:0,handled:!0,command:i}}case "query":{let s=ut(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 mt(s);return s.json?emitJsonOk(a,{query:s.query??"",language:s.language??null,astType:s.astType??null,maxResults:s.maxResults??null}):printHuman([gt(a)],{title:t("cli.cmd.query.description","Hybrid search (FTS + vector + basic)")}),{code:0,handled:!0,command:i}}case "node":{let s=ht(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 yt(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([xt(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=Ct(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 Et(s);return s.json?emitJsonOk(a,{nodeId:s.nodeId??"",depth:s.depth??null,direction:s.direction??"both"}):printHuman([Rt(a)],{title:t("cli.cmd.context.description","Build sub-graph context around a node")}),{code:0,handled:!0,command:i}}case "impact":{let s=_t(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 kt(s);return s.json?emitJsonOk(a,{nodeId:s.nodeId??"",depth:s.depth??null}):printHuman([Nt(a)],{title:t("cli.cmd.impact.description","Blast radius (BFS incoming edges)")}),{code:0,handled:!0,command:i}}case "callers":{let s=Wt(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 Jt(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([Kt(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=Vt(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 Ht(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([Yt(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=Qt(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 Xt(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 Zt(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=vt(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 It(s);return s.json?emitJsonOk(a,{astTypes:s.astTypes??null,limit:s.limit??null,excludeEntry:s.excludeEntry!==!1}):printHuman([Ot(a)],{title:t("cli.cmd.dead_code.description","Find unused symbols")}),{code:0,handled:!0,command:i}}case "circular":{let s=Tt(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 $t(s);return s.json?emitJsonOk(a,{relation:s.relation??null,scope:s.scope??null}):printHuman([Pt(a)],{title:t("cli.cmd.circular.description","Detect circular dependencies (Tarjan SCC)")}),{code:0,handled:!0,command:i}}case "path":{let s=Lt(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 At(s);return s.json?emitJsonOk(a,{fromId:s.fromId??"",toId:s.toId??"",depth:s.depth??null}):printHuman([qt(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=Gt(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 zt(s),{code:0,handled:!0,command:i})}case "watch":{let s=it(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 at(s);return console.log(rt(a.events)),await new Promise(d=>{let c=()=>{ce.info("watcher received signal, stopping"),d();};process.once("SIGINT",c),process.once("SIGTERM",c);}),await a.watcher.dispose(),{code:0,handled:!0,command:i}}case "stop":{let s=ct(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 lt(s);return s.json?emitJsonOk(a,{force:s.force===!0}):printHuman([dt(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),d=a.message;return l?emitJsonError(i,d):console.error(t("cli.command_failed",`codebase ${i} failed: ${d}`,{command:i,message:d})),ce.error("codebase CLI error",{command:i,error:a}),{code:1,handled:true,command:i}}}function Tn(o){let e={};for(let n of o)n==="--json"&&(e.json=true);return e}function $n(o){let e={};for(let n of o)n==="--help"||n==="-h"?e.help=true:n==="--json"&&(e.json=true);return e}function Pn(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 Fn(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{vn as a,Ir as b,In as c,Or as d,Fn as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {z}from'zod';var s={provider:"easbot-local",model:"bge-base-zh-v1.5",batchSize:32},i={batchSize:50,ignorePatterns:["node_modules/**","dist/**","build/**",".git/**","__pycache__/**","*.min.js","*.min.ts"],incremental:true},r={languages:["ts","tsx","js","py","rs","go","c","cpp","csharp","java","scala","ruby","php","zig"],lazyLoad:true},l={dictPath:[]},c=z.object({version:z.literal(1).optional(),schema_version:z.number().int().nonnegative().optional(),extraction_version:z.number().int().nonnegative().optional(),index_state:z.string().optional(),backend:z.string().optional(),created_at:z.string().optional(),embedding_model:z.string().nullable().optional(),evaluation_model:z.string().nullable().optional(),evaluation_threshold:z.number().min(0).max(1).optional()}).loose(),o=.85,p={version:1,schema_version:1,extraction_version:1,index_state:"uninitialized",backend:"better-sqlite3",created_at:"",embedding_model:null,evaluation_model:null,evaluation_threshold:o};export{s as a,i as b,r as c,l as d,c as e,o as f,p as g};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';var chunkTBDAGLC4_cjs=require('./chunk-TBDAGLC4.cjs'),chunkW5SMGCKO_cjs=require('./chunk-W5SMGCKO.cjs'),utils=require('@easbot/utils'),database=require('@easbot/database'),types=require('@easbot/types'),fs=require('fs');var ee=utils.Log.create({service:"codebase.services.codebase"}),N=utils.Filesystem.toUnixPath;function Pe(e,t){let n={exact:1,qualified:.85,substring:.5}[e];return t?Math.min(1,n+.2):n}function Re(e,t){if(!t)return false;if(e===t)return true;let n=e.split(/[/\\]/).pop()??"",s=t.split(/[/\\]/).pop()??"";return !!(n&&s&&n===s||t.includes("/")&&e.endsWith("/"+t))}async function $(e,t,n){if(n.nodeId){let o=e.getNode(n.nodeId);if(!o)throw new utils.ServiceError({code:"NOT_FOUND",message:`Node not found: nodeId=${n.nodeId}`,details:{name:n.nodeId}});return {node:o,candidates:[]}}if(!n.name)throw new utils.ServiceError({code:"NOT_FOUND",message:"Either name or nodeId is required",details:{...n}});let l=e.getDatabase().findNodesByName({name:n.name,file:n.file,kind:n.kind,limit:50});if(l.length===0)throw new utils.ServiceError({code:"NOT_FOUND",message:`Node not found: ${n.name}`,details:{name:n.name,candidates:[]}});let a=!!n.file,c=n.file?N(n.file):null,i=l.map(o=>{let u=c?Re(N(o.node.file_path),c):false;return {node:o.node,score:Pe(o.matchKind,u),matchKind:o.matchKind,inFile:u}});if(i.sort((o,u)=>u.score-o.score),i.length===1)return {node:i[0].node,candidates:i.map(o=>({node:o.node,score:o.score}))};let d=i[0].score,r=i.filter(o=>o.score===d);if(r.length===1)return {node:r[0].node,candidates:i.slice(0,10).map(o=>({node:o.node,score:o.score}))};if(a&&r.length>1){let o=r.filter(u=>u.inFile);if(o.length===1)return {node:o[0].node,candidates:i.slice(0,10).map(u=>({node:u.node,score:u.score}))}}throw new utils.ServiceError({code:"AMBIGUOUS",message:`Ambiguous name "${n.name}" \u2014 ${i.length} candidates`,details:{name:n.name,candidates:i.slice(0,10).map(o=>({node:o.node,score:o.score}))}})}async function P(e){let t=chunkTBDAGLC4_cjs.c(e.rootDir),n=new chunkTBDAGLC4_cjs.r({workspaceDir:e.workspaceDir,database:{path:t,walMode:true},embedding:types.DEFAULT_EMBEDDING_CONFIG,indexer:types.DEFAULT_INDEXER_CONFIG,parser:types.DEFAULT_PARSER_CONFIG,search:types.DEFAULT_SEARCH_CONFIG,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});return await n.initialize(),n}function U(e,t,n,s){let l=n.map(()=>"?").join(","),a=t.name.split("@")[0]??t.name,c=a.includes(".")?a.split(".").pop()??a:a,i=new Set([`${t.language}:*:*:${a}`]);c!==a&&i.add(`${t.language}:*:*:${c}`);let d=[];c!==a&&d.push(`${t.language}:*:*:%${c}`);let r=Array.from(i),o=r.map(()=>"?").join(","),g=d.length>0?"OR LOWER(target) LIKE LOWER(?)":"";r.length>1&&ee.warn("queryIncomingEdgesWithWildcard: multi-variant wildcards (bare+namespaced)",{rootName:t.name,wildcards:r,hint:"\u540C\u540D\u540C namespace \u4E0D\u540C file \u7684\u65B9\u6CD5\u53EF\u80FD\u90FD\u88AB\u547D\u4E2D\uFF0CLLM \u63A8\u7406\u8BF7\u7528 file \u8FC7\u6EE4\u8F85\u4F50"});let m=`
|
|
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 (${o})
|
|
8
|
+
${g}
|
|
9
|
+
)
|
|
10
|
+
GROUP BY id
|
|
11
|
+
LIMIT ?
|
|
12
|
+
`;return e.queryAll(m,[...n,t.id,...r,...d,s])}function Se(e){return e==="class_declaration"||e==="class_definition"||e==="interface_declaration"||e==="struct_declaration"||e==="struct_specifier"||e==="record_declaration"}function Ce(e,t,n,s,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(r=>r.id),i=new Set,d=[];for(let r of n)r.id&&!i.has(r.id)&&(i.add(r.id),d.push(r));if(c.length>0){let r=s.map(()=>"?").join(","),o=c.map(()=>"?").join(","),u=`
|
|
13
|
+
SELECT id, source, target, relation, created_at FROM edges
|
|
14
|
+
WHERE relation IN (${r})
|
|
15
|
+
AND source != target
|
|
16
|
+
AND source IN (${o})
|
|
17
|
+
GROUP BY id
|
|
18
|
+
LIMIT ?
|
|
19
|
+
`,g=e.queryAll(u,[...s,...c,l]);for(let m of g)m.id&&!i.has(m.id)&&(i.add(m.id),d.push(m));}return d.slice(0,l)}function te(e,t,n,s){let a=`
|
|
20
|
+
SELECT id, source, target, relation, created_at FROM edges
|
|
21
|
+
WHERE relation IN (${n.map(()=>"?").join(",")})
|
|
22
|
+
AND source != target
|
|
23
|
+
AND source = ?
|
|
24
|
+
LIMIT ?
|
|
25
|
+
`;return e.queryAll(a,[...n,t.id,s])}function ne(e,t,n,s){let l=s==="in"?e.source:e.target;t.id;let c=n.getNodeById(l);if(!c&&l.includes(":*:")){let i=l.split(":").pop()??l,d=i.split("@")[0]??i;if(d&&d!==l){let r=n.findNodesByName({name:d}),o=t.file_path??"",u=o.split(/[/\\]/).pop()??"",g=o.split(/[/\\]/).filter(Boolean),m=r.find(p=>p.node.file_path?p.node.file_path===o:false)??r.find(p=>!p.node.file_path||!u?false:p.node.file_path.split(/[/\\]/).pop()===u)??r.find(p=>{if(!p.node.file_path)return false;let f=p.node.file_path.split(/[/\\]/).filter(Boolean);return g.length<2||f.length<2?false:g[0]===f[0]&&g[1]===f[1]})??null;m&&(c=m.node);}}if(!c){let i=l.split(":").pop()??l;return {id:l,name:i,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 re(e,t){let n=Date.now(),l=(await P(e)).getQuery(),a=database.resolveSqlTextLimit(t.snippetMaxChars??database.SQL_TEXT_LIMIT_DEFAULT),i=await l.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,snippetMaxChars:a});if(t.kind){let o=t.kind.toLowerCase();i=i.filter(u=>u.ast_type.includes(o)||u.name.toLowerCase().includes(o));}if(t.file){let o=N(t.file);i=i.filter(u=>N(u.file_path).endsWith(o)||N(u.file_path).includes(o));}let d=t.maxEdgesPerNode??10,r=i.map(o=>({nodeId:o.id,name:o.name,kind:o.ast_type??"unknown",filePath:N(o.file_path),startLine:o.start_line,endLine:o.end_line,edges:(o.edges??[]).slice(0,d),source:"basic",score:0,snippet:(o.text??"").slice(0,a).replace(/\s+/g," ").trim()}));return {total:r.length,hits:r,durationMs:Date.now()-n,truncated:false}}async function Ie(e,t){let n=await P(e),s=n.getQuery(),l=n.getDatabase(),{node:a}=await $(s,e,t),c=[];if(t.includeEdges){let i=t.maxEdgesPerNode??10,d=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"],r=U(l,a,d,i+1),o=te(l,a,d,i+1),u=new Set,g=[];for(let m of [...r,...o])m.id&&!u.has(m.id)&&(u.add(m.id),g.push(m));c=g.slice(0,i);}return {node:a,edges:c}}var Le=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function Te(e,t){let n=await P(e),s=n.getQuery(),l=n.getDatabase(),{node:a}=await $(s,e,t);if(!a)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let c=t.depth??2,i=t.maxNodes??100,d=t.direction??"both";t.maxEdgesPerNode??10;let o=new Map,u=[{nodeId:a.id,depth:0}];o.set(a.id,0);let g=[],m=false;for(;u.length>0;){let y=u.shift();if(y.depth>=c)continue;if(o.size>=i){m=true;break}let I=s.queryNeighbors(y.nodeId,{direction:d,relationTypes:t.relationTypes??Le,limit:i-o.size+1});for(let b of I.edges){g.push(b);let L=b.source===y.nodeId?b.target:b.source;if(!o.has(L)&&(o.set(L,y.depth+1),u.push({nodeId:L,depth:y.depth+1}),o.size>=i)){m=true;break}}if(m)break}let p=new Set,f=[];for(let y of g)!y.id||p.has(y.id)||(p.add(y.id),f.push(y));let E=Array.from(o.keys()),h=E.length>0?l.queryNodes({ids:E}):[],C=new Map(h.map(y=>[y.id,y])),x=[];for(let[y,I]of o.entries()){let b=C.get(y);b&&x.push({node:b,depth:I});}return {root:a,nodes:x,edges:f,truncated:m,totalNodes:x.length,totalEdges:g.length}}var $e=["CALLS","IMPORTS","TYPE_REFERENCES"];async function _e(e,t){let n=await P(e),s=n.getQuery(),l=n.getDatabase(),{node:a}=await $(s,e,t);if(!a)return {root:null,totalImpacted:0,buckets:[]};let c=t.depth??2,i=t.maxResults??10,d=t.relationTypes??$e,r=t.maxEdgesPerNode??10,o=new Set([a.id]),u=[],g=[a.id];for(let m=1;m<=c&&!(g.length===0||o.size-1>=i);m++){let p=U(l,a,d,r+1),f=[],E=new Set;for(let h of p)if(!o.has(h.source)&&!E.has(h.source)&&(E.add(h.source),o.add(h.source),f.push(h.source),o.size-1>=i))break;if(f.length>0){let h=f.slice(0,10),C=l.queryNodes({ids:h}),x=new Map(C.map(b=>[b.id,b])),y=new Map;for(let b of p)y.has(b.source)||y.set(b.source,b.relation);let I=h.map(b=>{let L=x.get(b);return {id:b,name:L?.name??"(unknown)",filePath:L?N(L.file_path):"(unknown)",relation:y.get(b)??"CALLS"}});u.push({depth:m,count:f.length,sample:I});}g=f;}return u.length===0&&ee.warn("impact: no incoming edges found",{root:a.name,depth:c,relationTypes:d}),{root:a,totalImpacted:o.size-1,buckets:u}}var oe=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function we(e,t){return se(e,t)}async function Fe(e,t){return ie(e,t)}async function se(e,t){let n=await P(e),s=n.getQuery(),l=n.getDatabase(),{node:a}=await $(s,e,t);if(!a)return {root:null,callers:[],truncated:false};let c=t.maxResults??10,i=t.maxEdgesPerNode??c,d=t.relationTypes??oe,r=U(l,a,d,i+1),o=[];for(let g of r){let m=ne(g,a,l,"in");m&&o.push(m);}let u=o.length>c;return {root:a,callers:u?o.slice(0,c):o,truncated:u}}async function ie(e,t){let n=await P(e),s=n.getQuery(),l=n.getDatabase(),{node:a}=await $(s,e,t);if(!a)return {root:null,callees:[],truncated:false};let c=t.maxResults??10,i=t.maxEdgesPerNode??c,d=t.relationTypes??oe,r=te(l,a,d,i+1),o=Se(a.ast_type)?Ce(l,a,r,d,i+1):r,u=[];for(let m of o){let p=ne(m,a,l,"out");p&&u.push(p);}let g=u.length>c;return {root:a,callees:g?u.slice(0,c):u,truncated:g}}async function Ae(e,t){if(!t.query)throw new utils.ServiceError({code:"NOT_FOUND",message:"explore requires a non-empty query",details:{query:t.query}});let s=await P(e),l=s.getQuery(),a=s.getDatabase(),c=database.resolveSqlTextLimit(t.snippetMaxChars??database.SQL_TEXT_LIMIT_DEFAULT),d=(await re(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true,snippetMaxChars:c})).hits;if(t.file||t.kind)try{let m=await $(l,e,{name:t.query,file:t.file,kind:t.kind});if(m?.node){let p={nodeId:m.node.id,name:m.node.name,kind:m.node.ast_type,filePath:N(m.node.file_path),startLine:m.node.start_line,endLine:m.node.end_line,edges:[],source:"basic",score:0,snippet:(m.node.text??"").slice(0,c).replace(/\s+/g," ").trim()},f=d.filter(E=>E.nodeId!==p.nodeId);d=[p,...f];}}catch{}let r=new Map;for(let m of d){let p=N(m.filePath),f=r.get(p);f?f.push(m):r.set(p,[m]);}let o=t.maxSymbols??3,u=t.maxEdgesPerNode??10,g=[];for(let[m,p]of r){let f=p.slice(0,o),E=[];for(let h of f){let C=await se(e,{name:h.name,file:m,kind:t.kind,maxResults:u,maxEdgesPerNode:u}),x=await ie(e,{name:h.name,file:m,kind:t.kind,maxResults:u,maxEdgesPerNode:u});E.push({node:(()=>{let y={id:h.nodeId,name:h.name,ast_type:h.kind,language:"ts",file_path:h.filePath,start_line:h.startLine??0,end_line:h.endLine??0};try{let I=a.getNodeById(h.nodeId);return {...y,text:I?.text??""}}catch{return {...y,text:""}}})(),callers:C.callers,callees:x.callees});}g.push({file:m,symbols:E});}return {query:t.query,entryPoints:g,totalHits:d.length}}async function De(e,t){let s=await(await P(e)).getStatus();s.package="codebase",s.workspaceDir=e.workspaceDir;let l=chunkTBDAGLC4_cjs.b(e.workspaceDir),a=fs.existsSync(l),c=fs.existsSync(s.dbPath),i;if(c)try{i=fs.statSync(s.dbPath).size;}catch{}s.configPath=l,s.configExists=a,s.dbExists=c,s.dbSize=i,s.vectorEnabled=s.meta?.vector_enabled==="true"||s.meta?.vector_enabled==="1";let d=s.meta?.embeddingDims;d&&Number.isFinite(Number.parseInt(d,10))&&(s.embeddingDims=Number.parseInt(d,10));let r={initialized:false,capabilities:{embedding:false,evaluation:false}};try{let{Llm:o}=await import('./llm-S6D5ICOO.cjs');if(o.isInitialized()){r.initialized=!0;let u=o.capabilities();r.capabilities={embedding:u.embedding===!0,evaluation:u.evaluation===!0},r.embeddingModel=r.capabilities.embedding?"configured":void 0,r.evaluationModel=r.capabilities.evaluation?"configured":void 0;}}catch{}s.llm=r;try{let{DatabaseManager:o}=await import('./database-manager-LTHK7MM6.cjs'),u=new o(s.dbPath);try{let{stats:g}=u.checkIntegrity();s.dbStats=g,s.ftsAvailable=u.isFtsAvailable();}finally{u.close();}}catch{}return s}async function Oe(e,t){return await(await P(e)).healthCheck()}var Me=utils.Log.create({service:"codebase.services.init"}),ae=false;async function He(){ae||(ae=true,Me.info("codebase service init"),await utils.ServiceErrorBus.init(),await chunkW5SMGCKO_cjs.e());}var Ue=200,le=utils.Filesystem.toUnixPath;function ze(e){let t=e.text??"";if(!t)return false;let n=t.slice(0,80);return /\bexport\s/.test(n)||/\bpublic\s/.test(n)?true:(false)}function Ke(e){let t=e.text??"";if(!t)return [];let n=t.slice(0,80),s=[];return /\basync\s/.test(n)&&s.push("async"),/\bstatic\s/.test(n)&&s.push("static"),/\babstract\s/.test(n)&&s.push("abstract"),/\breadonly\s/.test(n)&&s.push("readonly"),/\bconst\s/.test(n)&&s.push("const"),/\blet\s/.test(n)&&s.push("let"),s}function R(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:le(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:ze(e),modifiers:Ke(e)}}function _(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function z(e){return e.map(t=>({node:{id:t.nodeId,name:t.name,astType:t.kind,language:"typescript",filePath:le(t.filePath),startLine:t.startLine??0,endLine:t.endLine??0,isExported:false,modifiers:[]},source:t.source,score:t.score,snippet:(t.snippet??"").slice(0,database.resolveSqlTextLimit(Ue)),edges:(t.edges??[]).slice(0,10).map(n=>_({...n}))}))}function K(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var Ge=utils.Log.create({service:"codebase.format.truncate"}),j="**`",Qe="**",ce=24e3,ue=25e3;async function D(e,t={}){let n=t.softLimit??ce,s=t.hardCeiling??ue,l=t.toolName??"codebase",a=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let c=e.slice(0,s),i=c.lastIndexOf(`
|
|
26
|
+
${j}`),d=c.lastIndexOf(`
|
|
27
|
+
`),r;i>s*.5?r=i:d>0?r=d:r=-1;let o=r>0?c.slice(0,r):c,g=o+"\n\n... (output truncated to budget; the source above is complete and verbatim \u2014 treat it as already Read. For any area not covered, make ANOTHER `<tool>` targeting those names \u2014 do NOT Read these files.)";if(!a)return {content:g,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-o.length}/${e.length} characters truncated ...`};try{let m=await utils.TruncateContent.truncate(e,{maxChars:o.length,direction:"head",label:`${l}-output`});return m.truncated?{content:g,truncated:!0,outputPath:m.outputPath,hint:utils.TruncateContent.formatHint(m),info:`... ${m.removedLength}/${m.originalLength} characters truncated ...`}:{content:g,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-o.length}/${e.length} characters truncated ...`}}catch(m){return Ge.warn("TruncateContent.truncate failed, returning without disk hint",{error:utils.errorMeta(m)}),{content:g,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-o.length}/${e.length} characters truncated ...`}}}function O(e,t={}){let n=t.softLimit??ce,s=t.hardCeiling??ue;if(e.length<=n)return {content:e,truncated:false};let l=e.slice(0,s),a=l.lastIndexOf(`
|
|
28
|
+
${j}`),c=l.lastIndexOf(`
|
|
29
|
+
`),i;a>s*.5?i=a:c>0?i=c:i=-1;let d=i>0?l.slice(0,i):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 Ye(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));return n>60?">60s ago":`${n}s ago`}function k(e,t){if(!e||e.length===0)return null;let n=e.filter(l=>t.has(l.path));return n.length===0?null:`\u26A0\uFE0F Index may be stale for: ${n.map(l=>`${l.path} (edited ${Ye(l.lastEventAt)})`).join(", ")}
|
|
32
|
+
|
|
33
|
+
`}function A(e,t,n={}){return (me[e]??me.default).replace(/<(\w+)>/g,(l,a)=>a==="tool"?t:n[a]??`<${a}>`)}var me={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 v(e,t){let{pendingFiles:n,toolName:s,sync:l=false}=t;if(e.length===0)return w(s,"No matches found.","Try broader search terms, or use `explore` to read source.");let a=Xe(e),c=new Set(a.keys()),i=[];i.push(k(n,c)??"");let d="[[codebase-search-summary]]";i.push(d+`
|
|
40
|
+
`);let r=e.length;i.push(`**Files with matches:** ${a.size}
|
|
41
|
+
`);for(let[m,p]of a){let f=p.map(x=>x.node.name),E=f.slice(0,5).join(", "),h=f.length>5?`, +${f.length-5} more`:"";i.push(`**\`${m}\`** \u2014 ${E}${h}
|
|
42
|
+
`);let C=p[0]?.node.language??"";i.push("```"+C);for(let x of p)i.push(`L${x.node.startLine} ${x.snippet}`);i.push("```\n");}i.push(A("search",s,{}));let o=i.join(`
|
|
43
|
+
`),u=`Found ${r} symbol${r===1?"":"s"} across ${a.size} file${a.size===1?"":"s"}.`,g=o.replace(d,u);return F(g,t,l)}async function M(e,t,n){let{pendingFiles:s,toolName:l,sync:a=false}=n;if(t.length===0||t.every(r=>r.count===0))return w(l,`No incoming edges for \`${e.name}\`.`,"This symbol has no callers \u2014 safe to refactor.");let c=t.reduce((r,o)=>r+o.count,0),i=Ve(c),d=[];d.push(k(s,new Set([e.filePath]))??""),d.push(`**Impact for \`${e.name}\`** (root: ${e.filePath}:${e.startLine}, total impacted: ${c})
|
|
44
|
+
`);for(let r of t){d.push(`- **d=${r.depth}** (${r.count} nodes) \u2014 ${r.riskLabel}`);for(let o of r.samples.slice(0,5))d.push(` - \`${o.name}\` ${o.file}:${o.line} [${o.relation}]`);r.samples.length>5&&d.push(` - ... and ${r.samples.length-5} more`);}return d.push(A("impact",l,{root:e.name,riskLevel:i})),F(d.join(`
|
|
45
|
+
`),n,a)}function Ve(e){return e>=100?"CRITICAL":e>=50?"HIGH":e>=10?"MEDIUM":"LOW"}function W(e){return e===1?"WILL BREAK (direct callers)":e===2?"LIKELY AFFECTED (indirect)":"MAY NEED TESTING (transitive)"}async function G(e,t){let{root:n,incoming:s,outgoing:l,neighbors:a}=e,{pendingFiles:c,toolName:i,sync:d=false}=t;if(s.length===0&&l.length===0&&a.length===0)return w(i,`No relations found for \`${n.name}\`.`,"This is a leaf node.");let r=[];r.push(k(c,new Set([n.filePath]))??""),r.push(`**Context for \`${n.name}\`** (${n.astType}, ${n.language}, ${n.filePath}:${n.startLine})
|
|
46
|
+
`),r.push(`**Incoming** (${s.length}):`);for(let o of s.slice(0,10))r.push(`- ${o.source} \u2192 [${o.relation}] \u2192 \`${n.name}\``);s.length>10&&r.push(`- ... and ${s.length-10} more`),r.push(""),r.push(`**Outgoing** (${l.length}):`);for(let o of l.slice(0,10))r.push(`- \`${n.name}\` \u2192 [${o.relation}] \u2192 ${o.target}`);if(l.length>10&&r.push(`- ... and ${l.length-10} more`),r.push(""),a.length>0){r.push(`**Neighbors** (${a.length}):`);for(let o of a.slice(0,20))r.push(`- [d=${o.depth}] \`${o.node.name}\` (${o.node.astType}) ${o.node.filePath}:${o.node.startLine}`);a.length>20&&r.push(`- ... and ${a.length-20} more`),r.push("");}return r.push(A("context",i,{})),F(r.join(`
|
|
47
|
+
`),t,d)}async function H(e,t,n){let{pendingFiles:s,toolName:l,sync:a=false}=n;if(!e.id)return w(l,"Node not found.","Check the node ID or use `search` to find it.");let c=t.filter(r=>r.direction==="in"),i=t.filter(r=>r.direction==="out"),d=[];d.push(k(s,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: ${i.length}):`);for(let r of c.slice(0,5))d.push(`- \u2190 [${r.relation}] ${r.source}`);for(let r of i.slice(0,5))d.push(`- \u2192 [${r.relation}] ${r.target}`);return t.length>10&&d.push(`- ... and ${t.length-10} more`),d.push(A("default",l,{})),F(d.join(`
|
|
49
|
+
`),n,a)}async function q(e,t,n,s,l){let{toolName:a,sync:c=false}=l,i=n==="callers"?"Callers":"Callees",d="of",r=n==="callers"?"Use `node <name>` to read full source of any caller.":"Use `node <name>` to read full source of any callee.",o=t?.name??"?";if(e.length===0)return w(a,`**${i} ${d} \`${o}\`** (0)`,n==="callers"?"This symbol has no callers \u2014 safe to refactor.":"This symbol has no outgoing calls \u2014 leaf node.");let u=[];u.push(`**${i} ${d} \`${o}\`** (${e.length}${s?"+":""})
|
|
50
|
+
`);for(let g of e.slice(0,10)){let m=g.filePath==="(unresolved)",p=m?g.filePath:`${g.filePath}:${g.startLine}`,f=m?" _(wildcard)_":"";u.push(`- [${g.relation}] \`${g.name}\` ${p}${f}`);}return e.length>10&&u.push(`- ... and ${e.length-10} more`),u.push(`
|
|
51
|
+
---
|
|
52
|
+
> ${r}`),F(u.join(`
|
|
53
|
+
`),l,c)}async function ge(e,t){let{entryPoints:n,totalHits:s,query:l}=e,{toolName:a,sync:c=false}=t;if(n.length===0)return w(a,`No matches for \`${l}\`.`,"Try broader search terms, or use `callers` / `callees` to traverse from a known symbol.");let i=[];i.push(`## Code Context
|
|
54
|
+
`),i.push(`**Query:** ${l} `),i.push(`**Total hits:** ${s} `),i.push(`**Entry points:** ${n.length}
|
|
55
|
+
`);for(let d of n){i.push(`**\`${d.file}\`** \u2014 ${d.symbols.length} symbol${d.symbols.length===1?"":"s"}
|
|
56
|
+
`);for(let r of d.symbols){let o=(r.source??"").trim()||"(source not included)",u=r.node.language;if(i.push("```"+u),i.push(`L${r.node.startLine}-L${r.node.endLine} ${r.node.name} (${r.node.astType}${r.node.modifiers.length>0?`, ${r.node.modifiers.join(" ")}`:""})`),i.push(""),i.push(o),i.push("```\n"),r.callers.length>0){i.push(`**Callers of \`${r.node.name}\` (${r.callers.length}):**`);for(let g of r.callers.slice(0,5))i.push(`- [${g.relation}] \`${g.name}\` ${g.filePath}:${g.startLine}`);r.callers.length>5&&i.push(`- ... and ${r.callers.length-5} more`),i.push("");}if(r.callees.length>0){i.push(`**Callees of \`${r.node.name}\` (${r.callees.length}):**`);for(let g of r.callees.slice(0,5))i.push(`- [${g.relation}] \`${g.name}\` ${g.filePath}:${g.startLine}`);r.callees.length>5&&i.push(`- ... and ${r.callees.length-5} more`),i.push("");}}}return i.push(`---
|
|
57
|
+
`),i.push(A("context",a,{})),F(i.join(`
|
|
58
|
+
`),t,c)}function Xe(e){let t=new Map;for(let n of e){let s=n.node.filePath,l=t.get(s);l?l.push(n):t.set(s,[n]);}return t}function w(e,t,n){return `**${e}**
|
|
59
|
+
|
|
60
|
+
${t}
|
|
61
|
+
|
|
62
|
+
> **Tip:** ${n}`}async function F(e,t,n){let s={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?O(e,s):await D(e,s)).content}var Ze=utils.Log.create({service:"codebase.format.render"});async function et(e,t){if(e.length===0)return v([],t);let n=z(e);return v(n,t)}async function tt(e,t,n){if(t.length===0)return M(R(e),[],n);let s=[{depth:1,count:t.length,riskLabel:W(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 M(R(e),s,n)}async function nt(e,t,n,s,l){let a=R(e),c=t.map(r=>_(r,"in")),i=n.map(r=>_(r,"out")),d=s.map(r=>({node:R(r),depth:1}));return G({root:a,incoming:c,outgoing:i,neighbors:d},l)}async function rt(e,t){return q(e.callers,e.root,"callers",e.truncated,t)}async function ot(e,t){return q(e.callees,e.root,"callees",e.truncated,t)}async function st(e,t){let{renderKnowledgeStatus:n}=await import('@easbot/terminal');return n({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 s=e.meta?.schema_version;return s&&Number.isFinite(Number.parseInt(s,10))?Number.parseInt(s,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 s={};if(e.isStale===true&&(s.stale="yes \u2014 reindex recommended"),typeof e.ftsAvailable=="boolean"&&(s.fts_available=e.ftsAvailable?"yes":"no"),e.meta&&typeof e.meta=="object")for(let[l,a]of Object.entries(e.meta))a!=null&&(s[`meta/${l}`]=String(a));return Object.keys(s).length>0?s:void 0})()})}async function it(e,t,n){if(!e)return H(K(),[],n);let s=R(e),l=t.map(a=>{let c=a.target===e.id?"in":"out";return _(a,c)});return H(s,l,n)}async function at(e,t){let n={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(s=>({file:s.file,symbols:s.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 ge(n,t)}Ze.debug("format/render.ts loaded");exports.A=nt;exports.B=rt;exports.C=ot;exports.D=st;exports.E=it;exports.F=at;exports.a=re;exports.b=Ie;exports.c=Te;exports.d=_e;exports.e=we;exports.f=Fe;exports.g=Ae;exports.h=De;exports.i=Oe;exports.j=He;exports.k=R;exports.l=_;exports.m=z;exports.n=K;exports.o=j;exports.p=Qe;exports.q=D;exports.r=O;exports.s=v;exports.t=M;exports.u=W;exports.v=G;exports.w=H;exports.x=q;exports.y=et;exports.z=tt;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';var chunkVZCOLSBF_cjs=require('./chunk-VZCOLSBF.cjs'),utils=require('@easbot/utils'),llm=require('@easbot/llm');exports.a=void 0;(C=>{let a=utils.Log.create({service:"codebase.llm"}),e=null,m=()=>{if(!e)throw new utils.NameErrors.OperationFailedError({message:"Llm is not initialized. Please call Llm.init() first.",operation:"llm-not-initialized"});return e};function T(t){if(c())return;let i=t;e={models:i.models,options:{evaluation:i.options?.evaluation},evaluationThreshold:d(i.evaluationThreshold)},llm.ModelManager.declare(e.models),a.info("Llm initialized",{evaluation:!!i.models.evaluation,embedding:!!i.models.embedding,evaluationThreshold:e.evaluationThreshold});}C.init=T;function E(){return e?.evaluationThreshold??chunkVZCOLSBF_cjs.f}C.getEvaluationThreshold=E;function c(){return e!==null}C.isInitialized=c;function L(){e=null;}C._resetForTest=L;function O(){return e?{evaluation:e.models.evaluation!==void 0,embedding:e.models.embedding!==void 0}:{evaluation:false,embedding:false}}C.capabilities=O;async function I(t){let i=m();if(i.models.embedding)return llm.probeEmbeddingDims(i.models.embedding,{timeoutMs:t?.timeoutMs??5e3})}C.probeEmbeddingDims=I;function M(){return e?.models.evaluation}C.getEvaluation=M;function R(){return e?.models.embedding}C.getEmbedding=R;async function N(t,i){if(!e?.models.evaluation)return a.debug("Llm.generateText: evaluation model not configured, return empty string"),"";try{return (await llm.LanguageProvider.generate({model:e.models.evaluation,user:{id:utils.Identifier.ascending("message"),sessionId:utils.Identifier.ascending("session"),model:{providerId:"",modelId:""}},sessionId:utils.Identifier.ascending("session"),agent:{name:"codebase-eval"},messages:[{role:"user",content:[{type:"text",text:t}]}],maxOutputTokens:i?.maxOutputTokens??e.options.evaluation?.maxOutputTokens,temperature:i?.temperature??e.options.evaluation?.temperature,activeTools:[]})).text}catch(n){return a.error("Llm.generateText failed",{error:utils.errorMeta(n)}),""}}C.generateText=N;let p=`The content under review is an automatic code knowledge graph extraction.
|
|
2
|
+
The reference extraction to compare against is provided as supporting material.
|
|
3
|
+
|
|
4
|
+
The extraction and the reference extraction use ONE of TWO JSON shapes \u2014 detect the shape from the JSON itself:
|
|
5
|
+
|
|
6
|
+
**Shape A \u2014 flat symbol list (common for search / recall evaluation):**
|
|
7
|
+
{ "expected": ["MemorySystem", "NoteKnowledge"], "query": "core classes" }
|
|
8
|
+
{ "actual": ["MemorySystem", "./parser"] }
|
|
9
|
+
|
|
10
|
+
**Shape B \u2014 structured extraction (full relation evaluation):**
|
|
11
|
+
{ "entities": [{ "name": "Foo", "type": "class" }], "relations": [{ "source": "Foo", "target": "Bar", "relation": "EXTENDS" }] }
|
|
12
|
+
{ "entities": [{ "name": "Foo", "type": "class" }], "relations": [] }
|
|
13
|
+
|
|
14
|
+
Grade the extraction against ALL of these criteria:
|
|
15
|
+
|
|
16
|
+
1. **Entity name match**: case-insensitive exact match is preferred; accept clear semantic synonyms (e.g. "UserService" \u2248 "UserSvc"); REJECT type-mismatched candidates (a file path is not a class name, and a class name is not a file path).
|
|
17
|
+
2. **Relation endpoints**: the source and target of a predicted relation must denote the same conceptual entities as in the reference.
|
|
18
|
+
3. **Relation type accuracy**: relation types are distinct \u2014 CALLS, REFERENCES and IMPORTS are not interchangeable.
|
|
19
|
+
4. **Type / category match**: a predicted entity must carry the same type as its reference counterpart.
|
|
20
|
+
|
|
21
|
+
Additional requirements:
|
|
22
|
+
5. The extraction MUST NOT contain entities absent from the reference (no hallucinated symbols).
|
|
23
|
+
6. The extraction MUST NOT contain factual errors about the codebase.
|
|
24
|
+
|
|
25
|
+
Scoring guidance:
|
|
26
|
+
- 1.0 \u2014 every entity and every relation matches the reference exactly
|
|
27
|
+
- 0.7-0.9 \u2014 most entities match, only minor relations are off
|
|
28
|
+
- 0.4-0.6 \u2014 about half match, significant misses
|
|
29
|
+
- 0.0-0.3 \u2014 little to no match (e.g. the extraction holds file paths while the reference holds class names)`,g=`How to read the inputs of this evaluation:
|
|
30
|
+
- CONTENT (the material under review) is the PREDICTED extraction \u2014 the actual output of the extractor.
|
|
31
|
+
- DOCUMENT (the supporting material) is the GOLD extraction \u2014 the ground truth it is measured against.
|
|
32
|
+
|
|
33
|
+
When the two JSON shapes above are present:
|
|
34
|
+
- Shape A: GOLD carries the "expected" array; PREDICTED carries the "actual" array.
|
|
35
|
+
- Shape B: both carry "entities" and "relations" arrays; compare them element-wise.
|
|
36
|
+
|
|
37
|
+
If the DOCUMENT section is absent, judge only against the criteria above.`;async function S(t){if(!e?.models.evaluation)return {score:-1,details:"evaluation model not configured",missingEntities:[],extraEntities:[],wrongRelations:[],missingRelations:[],passing:false};let i=d(t.threshold??e.evaluationThreshold);try{let n=await llm.EvaluationProvider.evaluate({type:"content-quality",query:p,response:t.predicted,document:t.gold,context:g,model:e.models.evaluation,maxOutputTokens:t.options?.maxOutputTokens??e.options.evaluation?.maxOutputTokens});if(n.type!=="content-quality")throw new utils.NameErrors.OperationFailedError({message:`Unexpected evaluation result type: ${n.type}`,operation:"codebase-evaluate-extraction"});let h=n.passing||n.score>=i;return {score:n.score,details:n.summary||n.feedback,missingEntities:n.violations,extraEntities:[],wrongRelations:[],missingRelations:[],passing:h}}catch(n){return a.error("Llm.evaluateExtraction failed",{error:utils.errorMeta(n)}),{score:-1,details:`evaluation failed: ${utils.errorMeta(n).message}`,missingEntities:[],extraEntities:[],wrongRelations:[],missingRelations:[],passing:false}}}C.evaluateExtraction=S;function d(t){return typeof t!="number"||!Number.isFinite(t)?chunkVZCOLSBF_cjs.f:t<=0||t>1?chunkVZCOLSBF_cjs.f:t}})(exports.a||(exports.a={}));var U=exports.a;exports.b=U;
|