@easbot/codebase 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{chunk-JDULI4R5.cjs → chunk-4KHRTABC.cjs} +11 -11
- package/dist/chunks/chunk-7ZBQQZOA.mjs +1 -0
- package/dist/chunks/chunk-B4DATLCQ.cjs +48 -0
- package/dist/chunks/chunk-BTEBUBZT.mjs +2 -0
- package/dist/chunks/{chunk-XAODNPHT.cjs → chunk-RPRDGNXG.cjs} +5 -5
- package/dist/chunks/chunk-U5G7MP3K.cjs +1 -0
- package/dist/chunks/chunk-W25T3SKH.mjs +234 -0
- package/dist/chunks/chunk-X72UNXDO.mjs +48 -0
- package/dist/chunks/{chunk-TGMIUXU3.mjs → chunk-XQID3NKI.mjs} +4 -4
- package/dist/chunks/chunk-XSOZHJMZ.cjs +2 -0
- package/dist/chunks/{code-base-HCFLEKJN.cjs → code-base-HBPZXJQZ.cjs} +1 -1
- package/dist/chunks/{code-base-N3PTDWLC.mjs → code-base-MC4K4ST4.mjs} +1 -1
- package/dist/chunks/file-watcher-EASGLNDX.mjs +1 -0
- package/dist/chunks/file-watcher-P3ACFOV5.cjs +1 -0
- package/dist/chunks/{stdio-server-DIGUR2PS.mjs → stdio-server-C7OYLX4I.mjs} +1 -1
- package/dist/chunks/{stdio-server-LJGVWMB7.cjs → stdio-server-UDX3QZNZ.cjs} +6 -6
- package/dist/chunks/sync-HOK662LD.cjs +1 -0
- package/dist/chunks/sync-XBCHGJ2H.mjs +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +7 -9
- package/dist/chunks/chunk-ADWUZMXE.mjs +0 -48
- package/dist/chunks/chunk-CJSKATXN.mjs +0 -2
- package/dist/chunks/chunk-EVDJNYI2.cjs +0 -1
- package/dist/chunks/chunk-HX2Y6JXE.cjs +0 -48
- package/dist/chunks/chunk-IXERCMYQ.cjs +0 -2
- package/dist/chunks/chunk-UEILXBZB.mjs +0 -1
- package/dist/chunks/chunk-VBIXWHTD.mjs +0 -234
- package/dist/chunks/file-watcher-5WEDJY6M.mjs +0 -1
- package/dist/chunks/file-watcher-LZZUEGMY.cjs +0 -1
- package/dist/chunks/sync-52O2GQKE.cjs +0 -1
- package/dist/chunks/sync-JNCNYSWI.mjs +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {c,e,a as a$1,d}from'./chunk-7ZBQQZOA.mjs';import {m,n,o,l}from'./chunk-BTEBUBZT.mjs';import {j,D,i,h,e as e$1}from'./chunk-XQID3NKI.mjs';import {a as a$2}from'./chunk-W25T3SKH.mjs';import {j as j$1,m as m$1,k,i as i$1,l as l$1}from'./chunk-Z4Y3VCYS.mjs';import {a,c as c$1,b}from'./chunk-UTKA3WG3.mjs';import {existsSync,readFileSync,copyFileSync,mkdirSync,rmSync,statSync,writeFileSync}from'fs';import {isAbsolute,join,dirname}from'path';import {createRequire}from'module';import {Log,resolveLocaleLang}from'@easbot/utils';import {fileURLToPath}from'url';import {ServerTransportType}from'@easbot/mcp';function me(o){let t={},i=[];for(let e of o)e==="--force"||e==="-f"?t.force=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function R(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??".");try{let r=await a$2(),{Log:n}=await import('@easbot/utils'),a=n.create({service:"codebase.init"});r.source==="monorepo"?a.debug("better-sqlite3 resolved (monorepo)",{path:r.absolutePath}):a.info("better-sqlite3 auto-installed to cache",{source:r.source,path:r.absolutePath});}catch(r){let{Log:n}=await import('@easbot/utils');n.create({service:"codebase.init"}).warn("better-sqlite3 resolve / install failed; index/sync/mcp may still fail later",{error:r instanceof Error?r.message:String(r),hint:"Run `npm i -g better-sqlite3` then retry, or set EASBOT_CACHE_PATH to a writable directory before running `easbot codebase init`."});}let i=a(t),e=b(t);if(existsSync(e)&&!o.force)return {configPath:e,created:false,skipped:true};existsSync(i)||mkdirSync(i,{recursive:true});let s={version:1,schema_version:i$1,extraction_version:m$1,backend:"better-sqlite3",created_at:new Date().toISOString()};if(writeFileSync(e,JSON.stringify(s,null,2),"utf-8"),o.skipAutoSync===false)try{let{runSync:r}=await import('./sync-XBCHGJ2H.mjs'),n=await r({dir:t,quiet:!0});return {configPath:e,created:!0,skipped:!1,initialSync:{filesAdded:n.filesAdded,filesUpdated:n.filesUpdated,filesDeleted:n.filesDeleted,nodesCreated:n.nodesCreated,edgesCreated:n.edgesCreated,durationMs:n.durationMs}}}catch(r){let{Log:n}=await import('@easbot/utils');n.create({service:"codebase.init"}).warn("initial sync failed (run `easbot codebase sync` to retry)",{error:String(r)});}return {configPath:e,created:true,skipped:false}}async function M(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=t,e=b(t),s=c$1(t),r={rootDir:t,codebaseDir:i,configExists:existsSync(e),dbExists:existsSync(s)};if(r.configExists){r.configPath=e;try{let n=JSON.parse(await import('fs').then(a=>a.promises.readFile(e,"utf-8")));r.indexState=n.index_state,r.schemaVersion=n.schema_version,r.extractionVersion=n.extraction_version,r.backend=n.backend;}catch{}}if(r.dbExists){r.dbPath=s;try{r.dbSize=statSync(s).size;}catch{}try{let{DatabaseManager:n}=await import('./database-manager-WOYUSWKD.mjs'),a=new n(s);try{let c=a.getStatus();r.indexState=c.indexState??r.indexState,r.extractionVersion=c.extractionVersion??r.extractionVersion,r.isStale=c.isStale,r.nodeCount=c.nodeCount,r.edgeCount=c.edgeCount;}finally{a.close();}}catch{}}return r.configExists?r.dbExists?r.indexState==="failed"?r.recommendation="Last sync failed \u2014 run `easbot codebase index` to retry.":r.isStale?r.recommendation="Index is stale (extraction version mismatch) \u2014 run `easbot codebase recreate` to rebuild.":r.indexState==="uninitialized"?r.recommendation="Config exists but index never built \u2014 run `easbot codebase index` to populate.":r.indexState==="partial"&&(r.recommendation="Last sync partially succeeded \u2014 re-run `easbot codebase index` to fill missing files."):r.recommendation="Run `easbot codebase index` to build the index.":r.recommendation="Run `easbot codebase init` to initialize the configuration.",r}function fe(o){let t=[];return t.push("Codebase status"),t.push(` rootDir: ${o.rootDir}`),t.push(` codebaseDir: ${o.rootDir}`),t.push(` config: ${o.configExists?`\u2713 ${o.configPath}`:"\u2717 (run `easbot codebase init`)"}`),o.configExists&&(t.push(` indexState: ${o.indexState??"(unknown)"}${o.isStale?" [STALE \u2014 reindex recommended]":""}`),t.push(` schemaVersion: ${o.schemaVersion??"(unknown)"}`),t.push(` extractionVersion: ${o.extractionVersion??"(unknown)"}`),t.push(` backend: ${o.backend??"(unknown)"}`)),t.push(` db: ${o.dbExists?`\u2713 ${o.dbPath} (${o.dbSize??0} bytes)`:"\u2717"}`),typeof o.nodeCount=="number"&&(t.push(` nodes: ${o.nodeCount}`),t.push(` edges: ${o.edgeCount??0}`)),o.recommendation&&(t.push(""),t.push(` \u{1F4A1} ${o.recommendation}`)),t.join(`
|
|
2
|
+
`)}async function he(o){let t=await M({dir:o.dir}),i=[],e;if(t.dbExists)try{let{DatabaseManager:n}=await import('./database-manager-WOYUSWKD.mjs'),a=new n(t.dbPath);try{let{issues:c,stats:h}=a.checkIntegrity();for(let m of c)i.push({severity:m.severity,message:m.message});e=h,e.parse_errors===0&&i.push({severity:"info",message:"parse_errors: 0 (no parse errors recorded)"}),e.unresolved_refs===0&&i.push({severity:"info",message:"unresolved_refs: 0 (resolution pipeline not active)"}),e.name_segment_vocab===0&&i.push({severity:"info",message:"name_segment_vocab: 0 (identifier-segments not active)"}),e.project_metadata===0&&i.push({severity:"info",message:"project_metadata: 0 (CodeBase.initialize not run)"});}finally{a.close();}}catch(n){i.push({severity:"warn",message:`db integrity check failed: ${n instanceof Error?n.message:String(n)}`});}let s=createRequire(import.meta.url),r={"better-sqlite3":false,"node:sqlite":false,"@tursodatabase/database":false};try{s.resolve("better-sqlite3"),r["better-sqlite3"]=!0;}catch{}r["node:sqlite"]=typeof process.versions.sqlite=="string";try{s.resolve("@tursodatabase/database"),r["@tursodatabase/database"]=!0;}catch{}return t.configExists||i.push({severity:"warn",message:"config not found \u2014 run `easbot codebase init` first"}),t.dbExists||i.push({severity:"info",message:"db not initialized \u2014 run `easbot codebase index` to build"}),!r["better-sqlite3"]&&!r["node:sqlite"]&&i.push({severity:"error",message:"no SQLite backend available (install better-sqlite3 or use Node 22.5+)"}),t.configExists&&t.backend&&!r[t.backend]&&i.push({severity:"error",message:`configured backend "${t.backend}" not available in this environment`}),{healthy:!i.some(n=>n.severity==="error"),issues:i,status:t,backendAvailable:r,dbStats:e??void 0}}function be(o){let t=[];t.push("Codebase doctor"),t.push(` healthy: ${o.healthy?"\u2713":"\u2717"}`),t.push(" backend availability:");for(let[r,n]of Object.entries(o.backendAvailable))t.push(` - ${r}: ${n?"\u2713":"\u2717"}`);let i=o.issues.filter(r=>r.severity==="error"),e=o.issues.filter(r=>r.severity==="warn"),s=o.issues.filter(r=>r.severity==="info");if(o.issues.length===0)t.push(" issues: none");else {t.push(` issues: ${o.issues.length} total (${i.length} error, ${e.length} warn, ${s.length} info)`);for(let r of i)t.push(` [error] ${r.message}`);for(let r of e)t.push(` [warn] ${r.message}`);for(let r of s.slice(0,5))t.push(` [info] ${r.message}`);s.length>5&&t.push(` [info] ... (${s.length-5} more)`);}return t.join(`
|
|
3
|
+
`)}function ye(o){let t={},i=[];for(let e of o)if(e==="--no-embed")t.noEmbed=true;else if(e==="--embed")t.noEmbed=false;else if(e==="--json")t.json=true;else if(e==="--verbose"||e==="-v")t.verbose=true;else if(e==="--quiet"||e==="-q")t.quiet=true;else if(e==="--help"||e==="-h")t.help=true;else if(e.startsWith("--batch=")){let s=e.slice(8),r=Number.parseInt(s,10);Number.isFinite(r)&&r>0&&(t.batch=r);}else e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function xe(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??".");a(t);b(t);await R({dir:t});let {CodeBase:s}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:n,DEFAULT_PARSER_CONFIG:a$1}=await import('@easbot/types'),c=o.batch??n.batchSize??50,h=new s({workspaceDir:t,database:{path:c$1(t),walMode:true},embedding:o.noEmbed===false?r:void 0,indexer:{...n,batchSize:c},parser:a$1,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),b$1=-1,S=0,l$1=!o.quiet,O;try{await h.initialize();let x=await h.indexDirectory(t,l$1?g=>{let E=Math.max(g.total,1),d=Math.min(100,Math.floor(g.processed/E*100)),f=Date.now();if(d!==b$1||f-S>3e4){let y=String(d).padStart(3," ");console.error(` \u{1F4A1} [${y}%] ${g.stage}: ${g.processed}/${g.total} files`),b$1=d,S=f;}}:void 0);O={rootDir:t,success:x.success,filesProcessed:x.filesProcessed,nodesCreated:x.nodesCreated,edgesCreated:x.edgesCreated,errorCount:x.errors.length,errors:x.errors,durationMs:x.duration,embedded:!o.noEmbed,batchSize:c};}finally{await h.close();}return O}function we(o){let t=[];if(t.push("Codebase index"),t.push(` rootDir: ${o.rootDir}`),t.push(` success: ${o.success?"\u2713":"\u2717"}`),t.push(` files processed: ${o.filesProcessed}`),t.push(` nodes created: ${o.nodesCreated}`),t.push(` edges created: ${o.edgesCreated}`),t.push(` embedded: ${o.embedded?"yes":"no (--no-embed)"}`),t.push(` batch size: ${o.batchSize}`),t.push(` duration: ${o.durationMs}ms`),o.errorCount>0){t.push(` errors (${o.errorCount}):`);for(let i of o.errors.slice(0,10))t.push(` - ${i.filePath}: ${i.error}`);o.errors.length>10&&t.push(` ... and ${o.errors.length-10} more`);}return t.join(`
|
|
4
|
+
`)}function Ce(o){let t={},i=[];for(let e of o)e==="--keep-config"?t.keepConfig=true:e==="--force"||e==="-f"?t.force=true:e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function Re(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??".");a(t);let e=c$1(t),s=b(t),r=false,n=false;for(let a of [e,`${e}-wal`,`${e}-shm`])if(existsSync(a))try{rmSync(a,{force:!0}),a===e&&(r=!0);}catch{}if(!o.keepConfig&&existsSync(s))try{rmSync(s,{force:!0}),n=!0;}catch{}return await R({dir:t,force:true}),{rootDir:t,removedDb:r,removedConfig:n,recreated:true,configPath:s}}function ke(o){let t=[];return t.push("Codebase recreate"),t.push(` rootDir: ${o.rootDir}`),t.push(` removed db: ${o.removedDb?"\u2713":"\u2717 (not found)"}`),t.push(` removed config:${o.removedConfig?"\u2713":"(preserved via --keep-config or absent)"}`),t.push(` \u2713 reinitialized at ${o.configPath}`),t.push(""),t.push("\u{1F4A1} Next: run `easbot codebase index` to rebuild the index."),t.join(`
|
|
5
|
+
`)}function Ne(o){let t={},i=[];for(let e of o)e==="--keep-embeddings"?t.keepEmbeddings=true:e==="--force"||e==="-f"?t.force=true:e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function _e(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??".");a(t);let e=c$1(t),s=b(t);if(!existsSync(e))return await R({dir:t}),{rootDir:t,cleared:false,nodesRemoved:0,edgesRemoved:0,filesRemoved:0,embeddingsPreserved:false,configPreserved:existsSync(s),nextIndexState:"uninitialized"};let{CodeBase:r}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:n,DEFAULT_INDEXER_CONFIG:a$1,DEFAULT_PARSER_CONFIG:c}=await import('@easbot/types'),h=new r({workspaceDir:t,database:{path:e,walMode:true},embedding:o.keepEmbeddings?n:void 0,indexer:a$1,parser:c,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),m;try{await h.initialize();let b={nodes:h.getDatabase().getNodeCount(),edges:h.getDatabase().getEdgeCount(),files:h.getDatabase().getFileCount()};await h.clear({keepEmbeddings:!!o.keepEmbeddings}),h.getDatabase().setIndexState("uninitialized"),m={rootDir:t,cleared:!0,nodesRemoved:b.nodes,edgesRemoved:b.edges,filesRemoved:b.files,embeddingsPreserved:!!o.keepEmbeddings,configPreserved:existsSync(s),nextIndexState:"uninitialized"};}finally{await h.close();}return m}function je(o){let t=[];return t.push("Codebase clear"),t.push(` rootDir: ${o.rootDir}`),o.cleared?(t.push(" \u2713 cleared data"),t.push(` nodes removed: ${o.nodesRemoved}`),t.push(` edges removed: ${o.edgesRemoved}`),t.push(` file hashes removed: ${o.filesRemoved}`),t.push(` embeddings preserved: ${o.embeddingsPreserved?"yes (--keep-embeddings)":"no"}`),t.push(` config preserved: ${o.configPreserved?"\u2713":"\u2717"}`)):(t.push(" \u2717 db not found at .easbot/db/codebase.db \u2014 nothing to clear"),t.push(` config preserved: ${o.configPreserved?"\u2713":"\u2717"}`)),t.push(""),t.push("\u{1F4A1} Next: run `easbot codebase index` to rebuild."),t.join(`
|
|
6
|
+
`)}var Oe=new Set(["backend","schema_version","extraction_version","index_state"]);function ho(o){return new Set(["schema_version","extraction_version"]).has(o)?"number":"string"}function Ie(o){let t={},i=[];for(let e of o)e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);if(i.length>0)if(t.subcommand=i[0],t.subcommand==="set")i.length>1&&(t.key=i[1]),i.length>2&&(t.value=i[2]),i.length>3&&(t.dir=i[3]);else {if(i.length>=2){let e=i[1]??"";isAbsolute(e)||e==="."||e===".."||e.startsWith("./")||e.startsWith("../")?t.dir=e:t.key=e;}i.length>=3&&(t.dir=i[2]);}return t}function ve(o){let t=readFileSync(o,"utf-8");return JSON.parse(t)}function bo(o,t){writeFileSync(o,JSON.stringify(t,null,2),"utf-8");}function De(o){return o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??".")}async function $e(o){let t=De(o),i=b(t),e=existsSync(i),s={rootDir:t,configPath:e?i:void 0,exists:e,values:null};if(!e)return s;let r;try{r=ve(i);}catch{return s}return o.key?(s.key=o.key,s.value=r[o.key]):s.values=r,s}var yo=new Set(["backend","schema_version","extraction_version","index_state"]);async function Pe(o){if(!o.key)throw new Error("config set requires <key>");if(o.value===void 0)throw new Error("config set requires <value> after <key>");if(!Oe.has(o.key))throw new Error(`Unsupported config key: "${o.key}". Allowed: ${Array.from(Oe).join(", ")}`);let t=De(o),i=a(t),e=b(t);if(!existsSync(i))throw new Error(`codebase not initialized at ${t} \u2014 run \`easbot codebase init\` first`);let s=o.value;if(ho(o.key)==="number"){let c=Number(o.value);if(!Number.isFinite(c))throw new Error(`config key "${o.key}" expects a number, got "${o.value}"`);s=c;}let n=existsSync(e)?ve(e):{},a$1=n[o.key];return n[o.key]=s,existsSync(i)||mkdirSync(i,{recursive:true}),bo(e,n),{rootDir:t,configPath:e,key:o.key,oldValue:a$1,newValue:s,requiresRestart:yo.has(o.key)}}function Le(o){if(!o.exists)return `\u2717 config not found at ${o.configPath??"/.easbot/codebase.json"} \u2014 run \`easbot codebase init\` first`;let t=[];if(t.push(`Codebase config: ${o.configPath}`),o.key!==void 0)t.push(` ${o.key}: ${JSON.stringify(o.value)}`);else if(o.values)for(let[i,e]of Object.entries(o.values))t.push(` ${i}: ${JSON.stringify(e)}`);return t.join(`
|
|
7
|
+
`)}function Fe(o){let t=[];return t.push(`\u2713 ${o.key}: ${JSON.stringify(o.oldValue)} \u2192 ${JSON.stringify(o.newValue)} (${o.configPath})`),o.requiresRestart&&(t.push(""),t.push(" \u26A0\uFE0F this setting affects db connection / sync behavior \u2014 restart CodeBase or run `recreate` for the change to take effect.")),t.join(`
|
|
8
|
+
`)}function qe(o){let t={},i=[];for(let e of o)e==="--schema"?t.schema=true:e==="--force"||e==="-f"?t.force=true:e==="--backup"||e==="-b"?t.backup=true:e==="--dry-run"||e==="-n"?t.dryRun=true:e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function Ue(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first to create it`);let{DatabaseManager:s}=await import('./database-manager-WOYUSWKD.mjs'),r=new s(e);try{let n=r.db,a=r.isIndexStale(),c=r.getMeta("indexed_with_extraction_version"),h=c?parseInt(c,10):null,m=r.getIndexState(),b=r.getMeta("schema_version"),S=b?parseInt(b,10):0,l={rootDir:t,dbPath:e,wasStale:a,previousVersion:h??null,currentVersion:m$1,applied:!1,schemaMigrated:!1,previousSchemaVersion:S,currentSchemaVersion:S,dryRun:!!o.dryRun,schemaSteps:j$1.map(d=>({id:d.id,description:d.description,status:"pending"})),migrationErrors:[],indexState:m},O;if(o.backup!==!1&&!o.dryRun)try{let d=new Date().toISOString().replace(/[:.]/g,"-");O=join(i,`codebase.db.bak.${d}`),copyFileSync(e,O);for(let f of ["-wal","-shm"]){let u=e+f;existsSync(u)&©FileSync(u,O+f);}l.backupPath=O;}catch(d){let f=d instanceof Error?d.message:String(d);l.recommendation=`Backup failed: ${f}. Continuing without backup.`;}let g=o.schema!==!1;try{let d=k(n,i$1,{dryRun:o.dryRun});l.currentSchemaVersion=o.dryRun?d.targetVersion:Math.max(d.currentVersion,d.targetVersion),l.migrationErrors=d.errors.map(u=>({migrationId:u.migrationId,error:u.error}));let f=new Set(d.applied);for(let u of l.schemaSteps)f.has(u.id)&&(u.status=o.dryRun?"pending":"applied");for(let u of l.migrationErrors){let y=l.schemaSteps.find(C=>C.id===u.migrationId);y&&(y.status="failed");}if(l.schemaMigrated=d.applied.length>0&&!o.dryRun,!o.dryRun){let u=l$1(n);l.currentSchemaVersion=u,u>0&&r.setMeta("schema_version",String(u));}}catch(d){let f=d instanceof Error?d.message:String(d);l.migrationErrors.push({migrationId:0,error:f});}let E=a||o.force;return E&&!o.dryRun&&(r.setMeta("indexed_with_extraction_version",String(m$1)),(m==="stale"||m==="failed")&&(r.setIndexState("complete"),l.indexState="complete"),l.applied=!0),o.dryRun?l.migrationErrors.length>0?l.recommendation="dry-run finished. Run without --dry-run to apply.":l.schemaMigrated?l.recommendation="dry-run: schema migration would apply. Run without --dry-run to apply.":l.recommendation="dry-run: nothing to apply.":!E&&!l.schemaMigrated&&l.migrationErrors.length===0?l.recommendation=`Already current (schema_version=${l.currentSchemaVersion}, extraction_version=${m$1}). No upgrade needed.`:l.migrationErrors.length>0?l.recommendation=`Schema migration completed with ${l.migrationErrors.length} error(s). `+(l.backupPath?`Restore from backup: ${l.backupPath}`:"Re-run `recreate` to drop & rebuild."):l.schemaMigrated&&!E?l.recommendation=`Schema migrated (v${l.previousSchemaVersion} \u2192 v${l.currentSchemaVersion}). To apply extraction changes, run \`recreate\` to rebuild data or \`index --force\`.`:l.schemaMigrated&&E?l.recommendation="Schema + extraction metadata both updated. To rebuild data with new extractor, run `recreate` or `index --force`.":l.recommendation="Extraction metadata updated. No schema changes needed.",l}finally{r.close();}}function Be(o){let t=[];if(t.push(`Codebase upgrade${o.dryRun?" (dry-run)":""}`),t.push(` db: ${o.dbPath}`),o.backupPath&&t.push(` backup: ${o.backupPath}`),t.push(` previous version: ${o.previousVersion??"(none)"}`),t.push(` current version: ${o.currentVersion}`),t.push(` previous schema_version: ${o.previousSchemaVersion}`),t.push(` current schema_version: ${o.currentSchemaVersion}`),t.push(` was stale: ${o.wasStale?"yes":"no"}`),t.push(` applied: ${o.applied?"\u2713":"(noop \u2014 already current)"}`),(o.schemaSteps??[]).length>0){t.push(""),t.push(" schema steps:");for(let i of o.schemaSteps){let e=i.status==="applied"?"\u2713":i.status==="pending"?"\xB7":i.status==="failed"?"\u2717":"-";t.push(` [${e}] v${i.id}: ${i.description}`);}}if((o.migrationErrors??[]).length>0){t.push(""),t.push(` migration errors: ${o.migrationErrors.length}`);for(let i of o.migrationErrors)t.push(` - v${i.migrationId}: ${i.error}`);}return t.push(` index_state: ${o.indexState}`),o.recommendation&&(t.push(""),t.push(` \u{1F4A1} ${o.recommendation}`)),t.join(`
|
|
9
|
+
`)}function Ge(o){let t={},i=[];for(let e of o)if(e==="--all")t.all=true;else if(e==="--dry-run"||e==="-n")t.dryRun=true;else if(e==="--pending-list"||e==="-p")t.pendingList=true;else if(e.startsWith("--batch=")){let s=parseInt(e.slice(8),10);Number.isFinite(s)&&s>0&&(t.batchSize=s);}else e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}var Eo=200;function Co(o,t=Eo){return o?o.length<=t?o:o.slice(0,t)+"\u2026":""}async function ze(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(!existsSync(i))throw new Error(`codebase not initialized at ${t} \u2014 run \`easbot codebase init\` first`);if(!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first to build`);let s=Date.now(),r=process.env.EASBOT_EMBEDDING_MODEL;if(!o.dryRun&&!r)throw new Error('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:n}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:c,DEFAULT_PARSER_CONFIG:h}=await import('@easbot/types'),m={...a$1,modelId:r??"(dry-run)"},b=new n({workspaceDir:t,database:{path:e,walMode:true},embedding:m,indexer:c,parser:h,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await b.initialize();let S=b.getDatabase(),l=S.getNodeCount(),O=S.queryAll("SELECT node_id FROM node_embeddings"),x=new Set(O.map(f=>f.node_id)),g;if(o.all)g=S.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else if(x.size===0)g=S.queryAll("SELECT id, name, ast_type, language, file_path, text FROM nodes");else {let f=Array.from(x),u=f.map(()=>"?").join(",");g=S.queryAll(`SELECT id, name, ast_type, language, file_path, text FROM nodes WHERE id NOT IN (${u})`,f);}let E=g.map(f=>({id:f.id,name:f.name,ast_type:f.ast_type,file_path:f.file_path,language:f.language,text_preview:Co(f.text)})),d={rootDir:t,dbPath:e,totalNodes:l,alreadyEmbedded:x.size,newlyEmbedded:0,failed:0,all:!!o.all,dryRun:!!o.dryRun,pendingList:o.pendingList?E:[],duration:Date.now()-s,embeddingModelConfigured:!!r};return o.dryRun?d.recommendation=E.length>0?`dry-run: ${E.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.":E.length===0?d.recommendation="All nodes already have embeddings. Use --all to force regenerate.":d.recommendation=`${E.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).`,d}finally{await b.close();}}function Je(o){let t=[],i=o.dryRun?" (dry-run)":"";if(t.push(`Codebase embed${i}`),t.push(` db: ${o.dbPath}`),t.push(` mode: ${o.all?"all (force regenerate)":"incremental (only missing)"}`),t.push(` embedding model: ${o.embeddingModelConfigured?"configured":"(none)"}`),t.push(` total nodes: ${o.totalNodes}`),t.push(` already embedded: ${o.alreadyEmbedded}`),t.push(` newly embedded: ${o.newlyEmbedded}`),o.failed>0&&t.push(` failed: ${o.failed}`),t.push(` pending: ${o.pendingList.length}`),t.push(` duration: ${o.duration}ms`),o.dryRun&&o.pendingList.length>0){t.push(""),t.push(" \u{1F4A1} first 5 pending nodes:");for(let e of o.pendingList.slice(0,5))t.push(` - ${e.id} (${e.ast_type})`);}return o.recommendation&&(t.push(""),t.push(` \u{1F4A1} ${o.recommendation}`)),t.join(`
|
|
10
|
+
`)}var Ve=Log.create({service:"codebase-watch"});function Ke(o){let t={},i=[];for(let e of o)if(e.startsWith("--debounce=")){let s=parseInt(e.slice(11),10);Number.isFinite(s)&&s>0&&(t.debounce=s);}else if(e.startsWith("--interval=")){let s=parseInt(e.slice(11),10);Number.isFinite(s)&&s>0&&(t.interval=s);}else if(e.startsWith("--backend=")){let s=e.slice(10);(s==="fs-events"||s==="inotify"||s==="windows"||s==="brute-force"||s==="watchman"||s==="auto")&&(t.backend=s);}else e.startsWith("--ignore=")?(t.ignore||(t.ignore=[]),t.ignore.push(e.slice(9))):e==="--on-load-failure=throw"?t.onLoadFailure="throw":e==="--on-load-failure=warn"?t.onLoadFailure="warn":e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function He(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=a(t);existsSync(i)||await R({dir:t});let e=new a$1({workspaceDir:t,backend:o.backend??"auto",ignorePatterns:o.ignore,onLoadFailure:o.onLoadFailure??"warn"}),s=[];e.on((r,n)=>{s.push({event:r,relPath:n,at:Date.now()}),Ve.info("watch event",{event:r,relPath:n});}),await e.start();try{await d(i,process.pid);}catch(r){Ve.warn("failed to write watcher pid",{error:String(r)});}return {watcher:e,events:s,startTime:Date.now()}}function Ye(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 Xe(o){let t={},i=[];for(let e of o)e==="--force"||e==="-f"?t.force=true:e==="--json"?t.json=true:e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function Ze(o){let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=a(t);existsSync(i)||await R({dir:t});let e$1=join(i,".watcher.pid"),s=c(i);if(s===null)return {rootDir:t,pidFile:e$1,pid:null,stopped:false,error:"No watcher running (no .easbot/.watcher.pid found)"};try{return process.kill(s,"SIGTERM"),await e(i),{rootDir:t,pidFile:e$1,pid:s,stopped:!0}}catch(r){await e(i);let n=r instanceof Error?r.message:String(r);return {rootDir:t,pidFile:e$1,pid:s,stopped:false,error:n}}}function et(o){let t=[];return t.push("Codebase stop"),t.push(` pid file: ${o.pidFile}`),t.push(` pid: ${o.pid??"(none)"}`),t.push(` stopped: ${o.stopped?"\u2713":"\u2717"}`),o.error?(t.push(` error: ${o.error}`),t.push(""),t.push(" \u{1F4A1} If a stale watcher was running, its process may have already exited.")):(t.push(""),t.push(" \u{1F4A1} Use `easbot codebase watch [dir]` to start a new watcher session.")),t.join(`
|
|
12
|
+
`)}function ot(o){let t={includeEdges:true,enableEmbedding:true},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e==="--no-edges")t.includeEdges=false;else if(e==="--no-vector"||e==="--no-embed")t.enableEmbedding=false;else if(e.startsWith("-l=")||e.startsWith("--language="))t.language=e.includes("=")?e.split("=")[1]:void 0;else if(!(e==="-l"||e==="--language"))if(e.startsWith("--ast="))t.astType=e.slice(6);else if(e.startsWith("-n=")||e.startsWith("--max=")){let s=parseInt(e.split("=")[1]??"",10);Number.isFinite(s)&&s>0&&(t.maxResults=s);}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.query=i.join(" ")),t}async function nt(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);let{CodeBase:s}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:n,DEFAULT_PARSER_CONFIG:a$1,DEFAULT_SEARCH_CONFIG:c}=await import('@easbot/types'),h=new s({workspaceDir:t,database:{path:e,walMode:true},embedding:o.enableEmbedding?r:void 0,indexer:n,parser:a$1,search:c,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),m=Date.now();try{await h.initialize();let S=await h.getQuery().search(o.query??"",{maxResults:o.maxResults??20,language:o.language,astType:o.astType,includeEdges:o.includeEdges,enableEmbedding:o.enableEmbedding});return {rootDir:t,query:o.query??"",totalResults:S.length,results:S.map(l=>({id:l.id,name:l.name,astType:l.ast_type,language:l.language,filePath:l.file_path,startLine:l.start_line??0,endLine:l.end_line??0,snippet:(l.text??"").slice(0,200),edgeCount:(l.edges??[]).length})),durationMs:Date.now()-m}}finally{await h.close();}}function it(o){let t=[];t.push(`Codebase query: ${JSON.stringify(o.query)}`),t.push(` results: ${o.totalResults} (in ${o.durationMs}ms)`);for(let i of o.results)t.push(` ${i.name} (${i.astType}) \u2014 ${i.language} ${i.filePath}:${i.startLine}-${i.endLine} [${i.edgeCount} edges]`),t.push(` ${i.snippet.replace(/\s+/g," ").slice(0,100)}`);return t.join(`
|
|
13
|
+
`)}function rt(o){let t={includeEdges:false},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e==="--edges")t.includeEdges=true;else if(e.startsWith("--file="))t.file=e.slice(7);else if(e.startsWith("--kind="))t.kind=e.slice(7);else if(e.startsWith("--max=")){let s=parseInt(e.slice(6),10);Number.isFinite(s)&&s>0&&(t.edgesLimit=s);}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.name=i[0],t.nodeId=i[0]),t}async function at(o){if(!o.name&&!o.nodeId)throw new Error("node command requires a <name> or <node-id> argument");let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);let r=await e$1({workspaceDir:t,rootDir:t},{name:o.name,nodeId:o.nodeId,file:o.file,kind:o.kind,includeEdges:o.includeEdges??false,includeContent:true,edgesLimit:o.edgesLimit??50});if(!r.node)return {rootDir:t,found:false,incomingEdges:[],outgoingEdges:[]};let n=[],a$1=[];for(let c of r.edges)c.target===r.node.id?n.push({id:c.id,relation:c.relation,source:c.source,target:c.target,direction:"in"}):a$1.push({id:c.id,relation:c.relation,source:c.source,target:c.target,direction:"out"});return {rootDir:t,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:n,outgoingEdges:a$1}}function ct(o){if(!o.found||!o.node)return `\u2717 node not found (rootDir: ${o.rootDir})`;let t=[];if(t.push(`Codebase node: ${o.node.id}`),t.push(` name: ${o.node.name}`),t.push(` type: ${o.node.astType}`),t.push(` language: ${o.node.language}`),t.push(` location: ${o.node.filePath}:${o.node.startLine}-${o.node.endLine}`),t.push(` edges: ${o.incomingEdges.length} incoming / ${o.outgoingEdges.length} outgoing`),o.incomingEdges.length>0&&typeof o.incomingEdges[0]=="object"&&"relation"in o.incomingEdges[0]){t.push(""),t.push(" incoming edges:");for(let i of o.incomingEdges.slice(0,20))t.push(` [${i.relation}] ${i.source} \u2192 ${i.target}`);t.push(" outgoing edges:");for(let i of o.outgoingEdges.slice(0,20))t.push(` [${i.relation}] ${i.source} \u2192 ${i.target}`);}return t.join(`
|
|
14
|
+
`)}function dt(o){let t={direction:"both"},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e.startsWith("--depth=")){let s=parseInt(e.slice(8),10);Number.isFinite(s)&&s>0&&(t.depth=s);}else if(e.startsWith("--max=")){let s=parseInt(e.slice(6),10);Number.isFinite(s)&&s>0&&(t.maxNodes=s);}else if(e.startsWith("--direction=")){let s=e.slice(12);(s==="incoming"||s==="outgoing"||s==="both")&&(t.direction=s);}else if(e.startsWith("--relation=")){let s=e.slice(11).split(",").map(r=>r.trim()).filter(Boolean);t.relationTypes=s;}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.nodeId=i[0]),t}async function ut(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);if(!o.nodeId)throw new Error("context command requires a <node-id> argument");let s=o.depth??2,r=o.maxNodes??100,n=o.direction??"both",{CodeBase:a$1}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:c,DEFAULT_INDEXER_CONFIG:h,DEFAULT_PARSER_CONFIG:m,DEFAULT_SEARCH_CONFIG:b}=await import('@easbot/types'),S=new a$1({workspaceDir:t,database:{path:e,walMode:true},embedding:c,indexer:h,parser:m,search:b,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await S.initialize();let l=S.getDatabase(),O=S.getQuery();if(!l.getNodeById(o.nodeId))return {rootDir:t,rootNodeId:o.nodeId,depth:s,totalNodes:0,totalEdges:0,nodes:[],edges:[],truncated:!1};let g=new Map,E=[{nodeId:o.nodeId,depth:0}];g.set(o.nodeId,0);let d=[],f=!1;for(;E.length>0;){let k=E.shift();if(k.depth>=s)continue;if(g.size>=r){f=!0;break}let D=O.queryNeighbors(k.nodeId,{direction:n,relationTypes:o.relationTypes,limit:r-g.size+1});for(let v of D.edges){d.push({source:v.source,target:v.target,relation:v.relation});let W=v.source===k.nodeId?v.target:v.source;if(!g.has(W)&&(g.set(W,k.depth+1),E.push({nodeId:W,depth:k.depth+1}),g.size>=r)){f=!0;break}}if(f)break}let u=Array.from(g.keys()),y=u.length>0?l.queryNodes({ids:u}):[],C=new Map(y.map(k=>[k.id,k])),T=[];for(let[k,D]of g.entries()){let v=C.get(k);v&&T.push({id:v.id,name:v.name,astType:v.ast_type,language:v.language,filePath:v.file_path,depth:D});}return {rootDir:t,rootNodeId:o.nodeId,depth:s,totalNodes:T.length,totalEdges:d.length,nodes:T,edges:d,truncated:f}}finally{await S.close();}}function pt(o){let t=[];t.push(`Codebase context: ${o.rootNodeId} (depth=${o.depth})`),t.push(` nodes: ${o.totalNodes}${o.truncated?" [TRUNCATED]":""}`),t.push(` edges: ${o.totalEdges}`);for(let i of o.nodes.slice(0,50))t.push(` [d=${i.depth}] ${i.name} (${i.astType}) \u2014 ${i.language} ${i.filePath}`);return o.nodes.length>50&&t.push(` ... and ${o.nodes.length-50} more`),t.join(`
|
|
15
|
+
`)}function gt(o){let t={},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e.startsWith("-d=")||e.startsWith("--depth=")){let s=parseInt(e.split("=")[1]??"",10);Number.isFinite(s)&&s>0&&(t.depth=s);}else if(e.startsWith("--relation=")){let s=e.slice(11).split(",").map(r=>r.trim()).filter(Boolean);t.relationTypes=s;}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.nodeId=i[0]),t}async function ft(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);if(!o.nodeId)throw new Error("impact command requires a <node-id> argument");let s=o.depth??3,r=o.relationTypes??["CALLS","REFERENCES","USES"],{CodeBase:n}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:c,DEFAULT_PARSER_CONFIG:h,DEFAULT_SEARCH_CONFIG:m}=await import('@easbot/types'),b=new n({workspaceDir:t,database:{path:e,walMode:true},embedding:a$1,indexer:c,parser:h,search:m,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await b.initialize();let S=b.getQuery(),l=b.getDatabase(),O=new Set([o.nodeId]),x=[],g=[o.nodeId];for(let E=1;E<=s&&g.length!==0;E++){let d=[],f=new Set;if(g.length>0){let u=g.map(()=>"?").join(","),y=r.map(()=>"?").join(","),C=l.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${u}) AND relation IN (${y})`,[...g,...r]);for(let T of C)!O.has(T.source)&&!f.has(T.source)&&(f.add(T.source),O.add(T.source),d.push(T.source));}if(d.length>0){let u=d.slice(0,10),y=u.length>0?l.queryNodes({ids:u}):[],C=new Map(y.map(k=>[k.id,k])),T=u.map(k=>{let D=C.get(k);return {id:k,name:D?.name??"(unknown)",filePath:D?.file_path??"(unknown)"}});x.push({depth:E,count:d.length,sample:T});}g=d;}return {rootDir:t,rootNodeId:o.nodeId,totalImpacted:O.size-1,depth:s,buckets:x}}finally{await b.close();}}function ht(o){let t=[];t.push(`Codebase impact: ${o.rootNodeId} (depth=${o.depth})`),t.push(` total impacted: ${o.totalImpacted}`);for(let i of o.buckets){t.push(` d=${i.depth}: ${i.count} nodes`);for(let e of i.sample.slice(0,5))t.push(` - ${e.name} (${e.filePath})`);}return t.join(`
|
|
16
|
+
`)}var qo="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",Uo=[new RegExp(`(?:^|/)(?:main|index|app|server)\\.(?:${qo})$`)];function yt(o){let t={excludeEntry:true};for(let i of o)if(i==="--help"||i==="-h")t.help=true;else if(i==="--json")t.json=true;else if(i==="--no-exclude-entry")t.excludeEntry=false;else if(i.startsWith("--type="))t.astTypes=i.slice(7).split(",").map(e=>e.trim()).filter(Boolean);else if(i.startsWith("--limit=")){let e=parseInt(i.slice(8),10);Number.isFinite(e)&&e>0&&(t.limit=e);}return t}async function xt(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);let s=o.astTypes??["function","method","class"],r=o.limit??100,n=o.excludeEntry!==false,{CodeBase:a$1}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:c,DEFAULT_INDEXER_CONFIG:h,DEFAULT_PARSER_CONFIG:m,DEFAULT_SEARCH_CONFIG:b}=await import('@easbot/types'),S=new a$1({workspaceDir:t,database:{path:e,walMode:true},embedding:c,indexer:h,parser:m,search:b,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await S.initialize();let l=S.getDatabase(),O=S.getQuery(),x=[],g=0,E=["CALLS","IMPORTS","TYPE_REFERENCES"],d=l.queryAll("SELECT DISTINCT target FROM edges WHERE relation IN ('CALLS','IMPORTS','TYPE_REFERENCES')"),f=new Set(d.map(u=>u.target));for(let u of s){let y=l.queryNodes({astType:u,limit:1e5});for(let C of y){if(n&&Uo.some(T=>T.test(C.file_path))){g++;continue}if(!f.has(C.id)&&(x.push({id:C.id,name:C.name,astType:C.ast_type,filePath:C.file_path,startLine:C.start_line??0}),x.length>=r))break}if(x.length>=r)break}return {rootDir:t,totalCandidates:x.length,excludedEntry:g,candidates:x.slice(0,r)}}finally{await S.close();}}function wt(o){let t=[];t.push("Codebase dead-code"),t.push(` total candidates: ${o.totalCandidates}`),o.excludedEntry>0&&t.push(` excluded (entry files): ${o.excludedEntry}`);for(let i of o.candidates.slice(0,50))t.push(` - ${i.name} (${i.astType}) \u2014 ${i.filePath}:${i.startLine}`);return o.candidates.length>50&&t.push(` ... and ${o.candidates.length-50} more`),t.join(`
|
|
17
|
+
`)}function Et(o){let t={relation:"IMPORTS",scope:"file"};for(let i of o)if(i==="--help"||i==="-h")t.help=true;else if(i==="--json")t.json=true;else if(i.startsWith("--relation="))t.relation=i.slice(11);else if(i.startsWith("--scope=")){let e=i.slice(8);(e==="file"||e==="module")&&(t.scope=e);}return t}function Go(o){let t=0,i=new Map,e=new Map,s=new Set,r=[],n=[];function a(c){i.set(c,t),e.set(c,t),t++,r.push(c),s.add(c);let h=o.get(c)??[];for(let m of h)i.has(m)?s.has(m)&&e.set(c,Math.min(e.get(c),i.get(m))):(a(m),e.set(c,Math.min(e.get(c),e.get(m))));if(e.get(c)===i.get(c)){let m=[],b;do b=r.pop(),s.delete(b),m.push(b);while(b!==c);m.length>1&&n.push(m);}}for(let c of o.keys())i.has(c)||a(c);return n}async function Ct(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);let s=o.relation??"IMPORTS",{CodeBase:r}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:n,DEFAULT_INDEXER_CONFIG:a$1,DEFAULT_PARSER_CONFIG:c,DEFAULT_SEARCH_CONFIG:h}=await import('@easbot/types'),m=new r({workspaceDir:t,database:{path:e,walMode:true},embedding:n,indexer:a$1,parser:c,search:h,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await m.initialize();let b=m.getDatabase(),S=b.queryNodes({limit:1e5}),l=new Map;for(let y of S){let C=l.get(y.file_path)??[];C.push(y.id),l.set(y.file_path,C);}let O=S.map(y=>y.id),x=new Map;for(let y of S)x.set(y.id,y.file_path);let g;if(O.length===0)g=[];else {let y=O.map(()=>"?").join(",");g=b.queryAll(`SELECT * FROM edges WHERE relation = ? AND source IN (${y})`,[s,...O]);}let E=new Map;for(let y of g){let C=x.get(y.source),T=x.get(y.target);if(!C||!T||C===T)continue;let k=E.get(C);k||(k=new Set,E.set(C,k)),k.add(T);}let d=new Map;for(let[y,C]of E.entries())d.set(y,Array.from(C));let u=Go(d).map(y=>{let C=[];for(let T=0;T<y.length;T++){let k=y[T],D=E.get(k);if(D)for(let v of D)y.includes(v)&&C.push({source:k,target:v});}return {cycle:y,edges:C}});return {rootDir:t,relation:s,totalCycles:u.length,cycles:u.slice(0,50)}}finally{await m.close();}}function Rt(o){let t=[];t.push(`Codebase circular (relation=${o.relation})`),t.push(` total cycles: ${o.totalCycles}`);for(let i=0;i<o.cycles.length;i++){let e=o.cycles[i];t.push(` cycle #${i+1} (${e.cycle.length} files):`),t.push(` ${e.cycle.join(" \u2192 ")} \u2192 ${e.cycle[0]}`);}return t.join(`
|
|
18
|
+
`)}function Nt(o){let t={},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e.startsWith("-d=")||e.startsWith("--depth=")){let s=parseInt(e.split("=")[1]??"",10);Number.isFinite(s)&&s>0&&(t.depth=s);}else if(e.startsWith("--relation=")){let s=e.slice(11).split(",").map(r=>r.trim()).filter(Boolean);t.relationTypes=s;}else e.startsWith("-")||i.push(e);return i.length>0&&(t.fromId=i[0]),i.length>1&&(t.toId=i[1]),t}async function _t(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);if(!o.fromId||!o.toId)throw new Error("path command requires <from> and <to> node IDs");let s=o.depth??6,r=o.relationTypes??["CALLS","IMPORTS"],{CodeBase:n}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:a$1,DEFAULT_INDEXER_CONFIG:c,DEFAULT_PARSER_CONFIG:h,DEFAULT_SEARCH_CONFIG:m}=await import('@easbot/types'),b=new n({workspaceDir:t,database:{path:e,walMode:true},embedding:a$1,indexer:c,parser:h,search:m,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});try{await b.initialize();let S=b.getQuery();if(o.fromId===o.toId)return {rootDir:t,found:!0,depth:0,steps:[],pathNodes:[o.fromId]};let l=new Set([o.fromId]),O=new Map,x=[o.fromId],g=!1;e:for(let u=0;u<=s;u++){let y=[];for(let C of x){let T=S.queryNeighbors(C,{direction:"both",relationTypes:r,limit:1e3});for(let k of T.edges){let D=k.source===C?k.target:k.source;if(!l.has(D)){if(l.add(D),O.set(D,{via:C,relation:k.relation}),D===o.toId){g=!0;break e}y.push(D);}}}x.length=0,x.push(...y);}if(!g)return {rootDir:t,found:!1,depth:0,steps:[],pathNodes:[]};let E=[o.toId],d=[],f=o.toId;for(;f!==o.fromId;){let u=O.get(f);if(!u)break;d.unshift({from:u.via,to:f,relation:u.relation}),E.unshift(u.via),f=u.via;}return {rootDir:t,found:!0,depth:d.length,steps:d,pathNodes:E}}finally{await b.close();}}function jt(o){let t=[];if(!o.found)return t.push("Codebase path: NOT FOUND within depth limit"),t.join(`
|
|
19
|
+
`);t.push(`Codebase path: depth=${o.depth}`);for(let i=0;i<o.steps.length;i++){let e=o.steps[i];t.push(` ${i+1}. [${e.relation}] ${e.from} \u2192 ${e.to}`);}return t.join(`
|
|
20
|
+
`)}function vt(o){let t={},i=[];for(let e of o)e==="--help"||e==="-h"?t.help=true:e.startsWith("-")||i.push(e);return t.dir=i[0],t}async function Dt(o){let t=isAbsolute(o.dir??"")&&o.dir?o.dir:join(l(),o.dir??"."),i=a(t),e=c$1(t);if(existsSync(i)||await R({dir:t}),!existsSync(e))throw new Error(`db not found at ${e} \u2014 run \`easbot codebase index\` first`);let{CodeBase:s}=await import('./code-base-MC4K4ST4.mjs'),{DEFAULT_EMBEDDING_CONFIG:r,DEFAULT_INDEXER_CONFIG:n,DEFAULT_PARSER_CONFIG:a$1,DEFAULT_SEARCH_CONFIG:c}=await import('@easbot/types'),{CodebaseStdioServer:h}=await import('./stdio-server-C7OYLX4I.mjs'),m="0.0.0";try{let x=dirname(fileURLToPath(import.meta.url));for(let g=0;g<8;g++){try{let d=JSON.parse(readFileSync(join(x,"package.json"),"utf-8"));if(d?.name==="@easbot/codebase"&&typeof d.version=="string"){m=d.version;break}}catch{}let E=dirname(x);if(E===x)break;x=E;}}catch{}let b=new s({workspaceDir:t,database:{path:e,walMode:true},embedding:r,indexer:n,parser:a$1,search:c,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});await b.initialize();let S={id:"easbot-codebase-mcp",name:"EASBot Codebase MCP",version:m,transportType:ServerTransportType.STDIO},l$1=await h.start(b,S);return {rootDir:t,tools:l$1.tools}}var en=Log.create({service:"codebase-cmd-callers"});function $t(o){let t={maxResults:20},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e.startsWith("--file="))t.file=e.slice(7);else if(e.startsWith("--kind="))t.kind=e.slice(7);else if(e.startsWith("--max=")){let s=parseInt(e.slice(6),10);Number.isFinite(s)&&s>0&&(t.maxResults=s);}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.symbol=i[0]),t}async function Pt(o){if(!o.symbol&&!o.nodeId)throw new Error("callers command requires a <symbol> or --nodeId argument");let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=Date.now(),s=await h({workspaceDir:t,rootDir:t},{name:o.symbol,nodeId:o.nodeId,file:o.file,kind:o.kind,maxResults:o.maxResults});return en.debug("callers command done",{symbol:o.symbol,count:s.callers.length,rootDir:t}),{rootDir:t,serviceResult:s,durationMs:Date.now()-i}}function Lt(o){let{serviceResult:t,rootDir:i}=o,e=[],s=t.root?.name??"?",r=t.truncated?"+":"";if(e.push(`Callers of \`${s}\` (${t.callers.length}${r}) [${i}]`),t.callers.length===0)e.push(" (no incoming edges)");else for(let n of t.callers)e.push(` - [${n.relation}] \`${n.name}\` ${n.filePath}:${n.startLine}`);return t.callers.length>0&&(e.push(""),e.push("\u{1F4A1} Use `easbot codebase node <name>` to read full source of any caller.")),e.join(`
|
|
21
|
+
`)}var sn=Log.create({service:"codebase-cmd-callees"});function Ft(o){let t={maxResults:20},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e.startsWith("--file="))t.file=e.slice(7);else if(e.startsWith("--kind="))t.kind=e.slice(7);else if(e.startsWith("--max=")){let s=parseInt(e.slice(6),10);Number.isFinite(s)&&s>0&&(t.maxResults=s);}else e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.symbol=i[0]),t}async function At(o){if(!o.symbol&&!o.nodeId)throw new Error("callees command requires a <symbol> or --nodeId argument");let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i$1=Date.now(),s=await i({workspaceDir:t,rootDir:t},{name:o.symbol,nodeId:o.nodeId,file:o.file,kind:o.kind,maxResults:o.maxResults});return sn.debug("callees command done",{symbol:o.symbol,count:s.callers.length,rootDir:t}),{rootDir:t,serviceResult:s,durationMs:Date.now()-i$1}}function Mt(o){let{serviceResult:t,rootDir:i}=o,e=[],s=t.root?.name??"?",r=t.truncated?"+":"";if(e.push(`Callees of \`${s}\` (${t.callers.length}${r}) [${i}]`),t.callers.length===0)e.push(" (no outgoing edges)");else for(let n of t.callers)e.push(` - [${n.relation}] \`${n.name}\` ${n.filePath}:${n.startLine}`);return t.callers.length>0&&(e.push(""),e.push("\u{1F4A1} Use `easbot codebase node <name>` to read full source of any callee.")),e.join(`
|
|
22
|
+
`)}var ln=Log.create({service:"codebase-cmd-explore"});function qt(o){let t={maxFiles:5,maxSymbols:3,depth:1,includeContent:true},i=[];for(let e of o)if(e==="--help"||e==="-h")t.help=true;else if(e==="--json")t.json=true;else if(e==="--no-content")t.includeContent=false;else if(e.startsWith("--file="))t.file=e.slice(7);else if(e.startsWith("--kind="))t.kind=e.slice(7);else if(e.startsWith("--max-files=")){let s=parseInt(e.slice(12),10);Number.isFinite(s)&&s>0&&(t.maxFiles=s);}else if(e.startsWith("--max-symbols=")){let s=parseInt(e.slice(14),10);Number.isFinite(s)&&s>0&&(t.maxSymbols=s);}else if(e.startsWith("--depth=")){let s=parseInt(e.slice(8),10);Number.isFinite(s)&&s>0&&(t.depth=s);}else e.startsWith("--intent=")?t.intent=e.slice(9):e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return i.length>0&&(t.query=i.join(" ")),t}async function Ut(o){if(!o.query)throw new Error("explore command requires a <query> argument");let t=o.dir&&isAbsolute(o.dir)?o.dir:join(l(),o.dir??"."),i=Date.now(),s=await j({workspaceDir:t,rootDir:t},{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 ln.debug("explore command done",{query:o.query,totalHits:s.totalHits,entryPoints:s.entryPoints.length,rootDir:t}),{rootDir:t,serviceResult:s,durationMs:Date.now()-i}}async function Bt(o){let t={pendingFiles:[],toolName:"codebase_explore",writeToDisk:false};return await D(o.serviceResult,t)}var Wt={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 un=Wt.languages,pn=un.filter(o=>o.supported).map(o=>o.value),P={defaultLocale:"zh-CN",locales:pn},F={},U=(o,t)=>{let i=F[o]||{translation:{}};return F[o]={translation:{...i.translation,...t.translation}},F[o]},B=(o=P.defaultLocale)=>(F[o]||U(o,{translation:{}}),{locale:o,resources:F[o]||{translation:{}}});var mn={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\u6574\u4E2A\u6570\u636E\u5E93\u5E76\u91CD\u65B0\u521D\u59CB\u5316","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\u5E76\u91CD\u65B0\u521D\u59CB\u5316","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] [--force] [dir]","cli.recreate.description":"\u4E22\u5F03\u6574\u4E2A\u6570\u636E\u5E93\uFF08codebase.db + -wal + -shm\uFF09\u5E76\u91CD\u65B0\u521D\u59CB\u5316\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.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\u8BF7\u4E4B\u540E\u8FD0\u884C `index`\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] [--dir=<worktree>]","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.query.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.node.usage":"\u7528\u6CD5: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json] [--dir=<worktree>]","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.node.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.context.usage":"\u7528\u6CD5: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.context.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.impact.usage":"\u7528\u6CD5: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.impact.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.callers.usage":"\u7528\u6CD5: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]","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.callers.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.callees.usage":"\u7528\u6CD5: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]","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.callees.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","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] [--dir=<worktree>]","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.explore.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.dead_code.usage":"\u7528\u6CD5: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json] [--dir=<worktree>]","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.dead_code.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.circular.usage":"\u7528\u6CD5: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json] [--dir=<worktree>]","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.circular.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","cli.path.usage":"\u7528\u6CD5: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.path.opt.dir":"--dir=<worktree> \u76EE\u6807\u5DE5\u4F5C\u6811\uFF08\u9ED8\u8BA4: cwd\uFF09","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}}"}},Gt=mn;var gn={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 Discard the entire db and re-init","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] [--force] [dir]","cli.recreate.description":"Discard the entire db (codebase.db + -wal + -shm) and re-init.","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.force":"--force, -f Skip safety prompts (for scripts)","cli.recreate.warn":"\u26A0\uFE0F This deletes the entire index. Run `index` after.","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] [--dir=<worktree>]","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.query.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.node.usage":"Usage: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json] [--dir=<worktree>]","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.node.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.context.usage":"Usage: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.context.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.impact.usage":"Usage: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.impact.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.callers.usage":"Usage: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]","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.callers.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.callees.usage":"Usage: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]","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.callees.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","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] [--dir=<worktree>]","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.explore.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.dead_code.usage":"Usage: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json] [--dir=<worktree>]","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.dead_code.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.circular.usage":"Usage: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json] [--dir=<worktree>]","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.circular.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","cli.path.usage":"Usage: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]","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.path.opt.dir":"--dir=<worktree> Target worktree (default: cwd)","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}}"}},zt=gn;var fn=()=>{B("zh-CN"),B("en-US"),U("zh-CN",Gt),U("en-US",zt);};fn();var V=new Map;var K=new Map;var hn=o=>{if(K.has(o))return K.get(o);let t=/{{\s*(\w+)\s*}}/g,i=[],e;for(;(e=t.exec(o))!==null;){let n=e[1];n&&!i.includes(n)&&i.push(n);}let s=new RegExp("{{\\s*("+i.join("|")+")\\s*}}","g"),r={keys:i,regex:s};return K.set(o,r),r},Jt=(o,t)=>{if(!o||typeof o!="string")return "";if(!t||Object.keys(t).length===0)return o;let{regex:i,keys:e}=hn(o);return e.length===0||!e.some(r=>r in t)?o:o.replace(i,(r,n)=>{let a=t[n];return a==null?"":String(a)})},bn=o=>{if(o&&P.locales.includes(o))return o;let t=process.env.EASBOT_LANG?.trim()||process.env.LANG?.trim();if(t){let i=t.replace(/_/g,"-");if(P.locales.includes(i))return i;let e=i.split("-")[0];if(e==="zh")return "zh-CN";if(e==="en")return "en-US"}return P.defaultLocale},Vt=o=>{if(!V.has(o)){let{resources:t}=B(o);V.set(o,t);}return V.get(o)},yn=(o,t={})=>{let i=bn(t.locale),s=Vt(i)?.translation[o];if(s&&typeof s=="string"){let r=Jt(s,t.vars);return r!=null?String(r):String(o)}if(i!==P.defaultLocale){let n=Vt(P.defaultLocale)?.translation[o];if(n&&typeof n=="string"){let a=Jt(n,t.vars);return a!=null?String(a):String(o)}}return String(t.fallback??o)},H=yn;var Kt=Log.create({service:"codebase-cli"});function Y(o){return resolveLocaleLang(o?.locale)}function Yt(o){let t=(e,s,r)=>H(e,{locale:o,vars:r,fallback:s}),i=(e,s,r)=>{let n=En.filter(a=>a.group===e).map(a=>` ${Cn(a.name)}${t(a.i18nKey,a.description)}`).join(`
|
|
23
|
+
`);return `${t(s,r)}
|
|
24
|
+
${n}`};return `
|
|
25
|
+
\x1B[1m${t("cli.banner.title","easbot-codebase \u2014 Code Knowledge Graph for EASBot")}\x1B[0m
|
|
26
|
+
|
|
27
|
+
${t("cli.banner.usage","Usage: easbot-codebase <command> [options]")}
|
|
28
|
+
|
|
29
|
+
${i("lifecycle","cli.banner.section.lifecycle","Commands (lifecycle):")}
|
|
30
|
+
|
|
31
|
+
${i("graph","cli.banner.section.graph","Commands (graph query):")}
|
|
32
|
+
|
|
33
|
+
${i("external","cli.banner.section.external","External:")}
|
|
34
|
+
|
|
35
|
+
Run \x1B[1measbot codebase <command> --help\x1B[0m for details.
|
|
36
|
+
|
|
37
|
+
\x1B[1m${t("cli.banner.local.title","Local CLI:")}\x1B[0m
|
|
38
|
+
${t("cli.banner.local.body","This package is also published as `easbot-codebase` for standalone use.")}
|
|
39
|
+
${t("cli.banner.local.agent","Agent CLI users: `easbot codebase <command> ...`")}
|
|
40
|
+
${t("cli.banner.local.standalone","Standalone users: `easbot-codebase <command> ...`")}
|
|
41
|
+
|
|
42
|
+
\x1B[2m$\x1B[0m easbot-codebase init ${t("cli.cmd.init.description","Initialize .easbot/codebase.json in the target directory")}
|
|
43
|
+
\x1B[2m$\x1B[0m easbot-codebase index ${t("cli.cmd.index.description","Build the full index (creates db if missing)")}
|
|
44
|
+
\x1B[2m$\x1B[0m easbot-codebase status ${t("cli.cmd.status.description","Show index state / db / config")}
|
|
45
|
+
\x1B[2m$\x1B[0m easbot-codebase query <q...> ${t("cli.cmd.query.description","Hybrid search (FTS + vector + basic)")}
|
|
46
|
+
\x1B[2m$\x1B[0m easbot-codebase --help ${t("cli.shared.show_help","Show this help")}
|
|
47
|
+
`}function Sn(o){let t=Y(o);console.log(Yt(t));}function la(o){let t=Y(o);console.log(Yt(t));}var En=[{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 [dir]",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:"Discard the entire db and re-init",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",description:"Generate / inspect node embeddings (dry-run / pending-list)",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 [dir]",description:"Start stdio MCP server (exposes 9 codebase tools)",group:"external"}];function Cn(o){return o.length>=18?o:o+" ".repeat(18-o.length)}var Ht=false;function Rn(){if(Ht)return;Ht=true;let o=false,t=i=>{o||(o=true,console.error(`
|
|
48
|
+
[codebase] received ${i}, cleaning up...`),setTimeout(()=>process.exit(130),200));};process.on("SIGINT",t),process.on("SIGTERM",t);}async function da(o$1,t){Rn();let i=Y(t),e=(n,a,c)=>H(n,{locale:i,vars:c,fallback:a});if(o$1.length===0)return Sn(t),{code:0,handled:false};let s=o$1[0],r=o$1.slice(1);try{switch(s){case "init":{let n=me(r);if(n.help)return console.log(e("cli.init.usage","Usage: easbot codebase init [dir] [--force]")),console.log(""),console.log(e("cli.init.description","Initialize .easbot/codebase.json in the target directory.")),console.log(e("cli.init.creates","Creates .easbot/codebase.json with default backend = better-sqlite3.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.init.opt.force","--force, -f Overwrite existing config.json")}`),{code:0,handled:!0,command:s};let a=await R({...n,skipAutoSync:!1});return a.skipped?(console.log(e("cli.init.exists",`codebase config already exists at ${a.configPath} (use --force to overwrite)`,{path:a.configPath})),{code:0,handled:!0,command:s}):(console.log(e("cli.init.created",`\u2713 codebase initialized at ${a.configPath}`,{path:a.configPath})),{code:0,handled:!0,command:s})}case "status":{let n=kn(r),a=await M(n);return n.json?I(a,{dir:n.dir??null}):console.log(fe(a)),{code:0,handled:!0,command:s}}case "doctor":{let n=Nn(r),a=await he(n);return n.json?I(a,{healthy:a.healthy,issueCount:a.issues.length,errorCount:a.issues.filter(c=>c.severity==="error").length,warnCount:a.issues.filter(c=>c.severity==="warn").length,dir:n.dir??null}):console.log(be(a)),{code:a.healthy?0:1,handled:!0,command:s}}case "index":{let n=ye(r);if(n.help)return console.log(e("cli.index.usage","Usage: easbot codebase index [dir] [--embed] [--no-embed] [--batch=N] [--json]")),console.log(""),console.log(e("cli.index.description","Build the full index for the target directory.")),console.log(e("cli.index.auto_init","Auto-initializes .easbot/codebase.json if it does not exist.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.index.opt.embed","--embed Generate node embeddings (default: skip)")}`),console.log(` ${e("cli.index.opt.no_embed","--no-embed Same as default (skip embedding)")}`),console.log(` ${e("cli.index.opt.batch","--batch=N Batch size for indexing (default 50)")}`),console.log(` ${e("cli.index.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:s};let a=await xe(n);return n.json?I(a,{success:a.success,dir:n.dir??null,noEmbed:n.noEmbed!==!1,batch:n.batch??null,verbose:n.verbose===!0,quiet:n.quiet===!0}):console.log(we(a)),{code:a.success?0:1,handled:!0,command:s}}case "sync":{let n$1=m(r);if(n$1.help)return console.log(e("cli.sync.usage","Usage: easbot codebase sync [--embed] [--no-embed] [--quiet] [--json] [dir]")),console.log(""),console.log(e("cli.sync.description","Run incremental sync (only adds/updates/deletes changed files).")),console.log(e("cli.sync.auto_version","Auto-updates meta['indexed_with_version'] on success.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.sync.opt.embed","--embed Enable node embeddings (default off, FTS-only)")}`),console.log(` ${e("cli.sync.opt.no_embed","--no-embed Explicitly disable embeddings (default)")}`),console.log(` ${e("cli.sync.opt.quiet","--quiet, -q Only print summary")}`),console.log(` ${e("cli.sync.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:s};let a=await n(n$1);return n$1.json?I(a,{success:a.success,quiet:n$1.quiet===!0,dir:n$1.dir??null}):console.log(o(a)),{code:a.success?0:1,handled:!0,command:s}}case "recreate":{let n=Ce(r);if(n.help)return console.log(e("cli.recreate.usage","Usage: easbot codebase recreate [--keep-config] [--force] [--json] [dir]")),console.log(""),console.log(e("cli.recreate.description","Discard the entire db (codebase.db + -wal + -shm) and re-init.")),console.log(e("cli.recreate.equivalent","Equivalent to codegraph `recreate()` for safe index recovery.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.recreate.opt.keep_config","--keep-config Keep .easbot/codebase.json (only drop db)")}`),console.log(` ${e("cli.recreate.opt.force","--force, -f Skip safety prompts (for scripts)")}`),console.log(` ${e("cli.recreate.opt.json","--json Output as JSON")}`),console.log(""),console.log(e("cli.recreate.warn","\u26A0\uFE0F This deletes the entire index. Run `index` after.")),{code:0,handled:!0,command:s};let a=await Re(n);return n.json?I(a,{keepConfig:n.keepConfig===!0,force:n.force===!0,dir:n.dir??null}):console.log(ke(a)),{code:0,handled:!0,command:s}}case "clear":{let n=Ne(r);if(n.help)return console.log(e("cli.clear.usage","Usage: easbot codebase clear [--keep-embeddings] [--force] [--json] [dir]")),console.log(""),console.log(e("cli.clear.description","Clear all nodes/edges/file_hashes; keep config.json and meta.")),console.log(e("cli.clear.reset_state",'index_state is reset to "uninitialized" so `status` recommends `index`.')),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.clear.opt.keep_embeddings","--keep-embeddings Preserve node_embeddings / embedding_cache")}`),console.log(` ${e("cli.clear.opt.force","--force, -f Skip safety prompts (for scripts)")}`),console.log(` ${e("cli.clear.opt.json","--json Output as JSON")}`),console.log(""),console.log(e("cli.clear.hint","\u{1F4A1} Use `recreate` if you want to drop the entire db file.")),{code:0,handled:!0,command:s};let a=await _e(n);return n.json?I(a,{keepEmbeddings:n.keepEmbeddings===!0,force:n.force===!0,dir:n.dir??null}):console.log(je(a)),{code:0,handled:!0,command:s}}case "config":{let n=Ie(r);if(n.help)return console.log(e("cli.config.usage","Usage: easbot codebase config <get|set> [key] [value] [--json] [dir]")),console.log(""),console.log(e("cli.config.description","Read or write .easbot/codebase.json fields.")),console.log(""),console.log(e("cli.config.subcommands","Subcommands:")),console.log(` ${e("cli.config.get","get [key] Show all fields (or a specific key)")}`),console.log(` ${e("cli.config.set","set <key> <value> Update a field (must be in allowlist)")}`),console.log(""),console.log(e("cli.config.allowed_keys","Allowed keys: backend, schema_version, extraction_version, index_state")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.config.opt.json","--json Output as JSON (no ANSI)")}`),{code:0,handled:!0,command:s};if(!n.subcommand)return console.error(e("cli.config.no_subcommand","config requires a subcommand: get | set")),{code:1,handled:!0,command:s};if(n.subcommand==="get"){let a=await $e(n);return n.json?I(a,{subcommand:"get",key:n.key??null,dir:n.dir??null}):console.log(Le(a)),{code:0,handled:!0,command:s}}if(n.subcommand==="set"){let a=await Pe(n);return n.json?I(a,{subcommand:"set",key:n.key??null,dir:n.dir??null}):console.log(Fe(a)),{code:0,handled:!0,command:s}}return console.error(e("cli.config.unknown_subcommand",`Unknown config subcommand: ${n.subcommand}`,{subcommand:n.subcommand})),{code:1,handled:!0,command:s}}case "upgrade":{let n=qe(r);if(n.help)return console.log(e("cli.upgrade.usage","Usage: easbot codebase upgrade [--schema] [--force] [dir]")),console.log(""),console.log(e("cli.upgrade.description","Update indexed_with_extraction_version metadata when stale.")),console.log(e("cli.upgrade.does_not_delete","Does NOT delete data \u2014 use `recreate` to drop the db entirely.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.upgrade.opt.schema","--schema Also re-run ensureSchema (idempotent CREATE TABLE IF NOT EXISTS)")}`),console.log(` ${e("cli.upgrade.opt.force","--force, -f Update version even when not stale")}`),{code:0,handled:!0,command:s};let a=await Ue(n);return n.json?I(a,{schema:n.schema===!0,force:n.force===!0,dir:n.dir??null}):console.log(Be(a)),{code:0,handled:!0,command:s}}case "embed":{let n=Ge(r);if(n.help)return console.log(e("cli.embed.usage","Usage: easbot codebase embed [--all] [--dry-run|-n] [--pending-list|-p] [--batch=N] [--json] [dir]")),console.log(""),console.log(e("cli.embed.description","Generate node embeddings for nodes missing from node_embeddings.")),console.log(e("cli.embed.statistical_only","CLI is statistical-only \u2014 actual embedding generation requires")),console.log(e("cli.embed.repl_required","an `easbot` REPL session with an injected EmbeddingModel.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.embed.opt.all","--all Force regenerate for all nodes")}`),console.log(` ${e("cli.embed.opt.dry_run","--dry-run, -n Print statistics only (default behavior in CLI)")}`),console.log(` ${e("cli.embed.opt.pending","--pending-list, -p List node ids that are pending embedding")}`),console.log(` ${e("cli.embed.opt.batch","--batch=N Embedding batch size (default 10)")}`),console.log(` ${e("cli.embed.opt.json","--json Output as JSON")}`),console.log(""),console.log(e("cli.embed.env.heading","Environment:")),console.log(` ${e("cli.embed.env.model","EASBOT_EMBEDDING_MODEL e.g. openai/text-embedding-3-small")}`),{code:0,handled:!0,command:s};let a=await ze(n);return n.json?I(a,{all:n.all===!0,dryRun:n.dryRun===!0,pendingList:n.pendingList===!0,batchSize:n.batchSize??null,dir:n.dir??null}):console.log(Je(a)),{code:0,handled:!0,command:s}}case "query":{let n=ot(r);if(n.help)return console.log(e("cli.query.usage","Usage: easbot codebase query <q...> [--language=<lang>] [--ast=<type>] [--max=N] [--no-edges] [--no-vector|--no-embed] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.query.description","Hybrid search (FTS + vector + basic) over indexed code nodes.")),console.log(e("cli.query.aliases","Aliases: search")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.query.opt.language","--language=<lang> Filter by language (ts / js / py / go / ...)")}`),console.log(` ${e("cli.query.opt.ast","--ast=<type> Filter by AST type (class_declaration / function_declaration / ...)")}`),console.log(` ${e("cli.query.opt.max","--max=<N> Max results (default 20)")}`),console.log(` ${e("cli.query.opt.no_edges","--no-edges Do not include edges in results (default: include)")}`),console.log(` ${e("cli.query.opt.no_vector","--no-vector / --no-embed Disable vector search (FTS + basic only, default: vector on)")}`),console.log(` ${e("cli.query.opt.json","--json JSON output")}`),console.log(` ${e("cli.query.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await nt(n);return n.json?I(a,{query:n.query??"",language:n.language??null,astType:n.astType??null,maxResults:n.maxResults??null,dir:n.dir??null}):console.log(it(a)),{code:0,handled:!0,command:s}}case "node":{let n=rt(r);if(n.help)return console.log(e("cli.node.usage","Usage: easbot codebase node <name|id> [--file=<path>] [--kind=<kind>] [--edges] [--max=N] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.node.description","Show details for a single node.")),console.log(e("cli.node.accepts_name","Accepts a symbol <name> (LLM workflow friendly, tool/MCP-aligned)")),console.log(e("cli.node.accepts_id","or a raw <node-id> from `query` / database.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.node.opt.file","--file=<path> Disambiguate when same-named symbols exist")}`),console.log(` ${e("cli.node.opt.kind","--kind=<kind> Filter / disambiguate by AST kind")}`),console.log(` ${e("cli.node.opt.edges","--edges Include incoming / outgoing edge summaries")}`),console.log(` ${e("cli.node.opt.max","--max=<N> Edge limit (default 50)")}`),console.log(` ${e("cli.node.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.node.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await at(n);return n.json?I(a,{name:n.name??"",nodeId:n.nodeId??null,file:n.file??null,kind:n.kind??null,includeEdges:n.includeEdges===!0,edgesLimit:n.edgesLimit??null,found:a.found,dir:n.dir??null}):console.log(ct(a)),{code:a.found?0:1,handled:!0,command:s}}case "context":{let n=dt(r);if(n.help)return console.log(e("cli.context.usage","Usage: easbot codebase context <id> [--depth=N] [--max=N] [--direction=<incoming|outgoing|both>] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.context.description","Build a sub-graph context around a node (BFS to N-level neighbors).")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.context.opt.depth","--depth=<N> BFS depth (default 2)")}`),console.log(` ${e("cli.context.opt.max","--max=<N> Max nodes (default 100)")}`),console.log(` ${e("cli.context.opt.direction","--direction=<dir> incoming | outgoing | both (default both)")}`),console.log(` ${e("cli.context.opt.relation","--relation=<r1,r2,...> Filter by relation types (CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / USES / REFERENCES)")}`),console.log(` ${e("cli.context.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.context.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await ut(n);return n.json?I(a,{nodeId:n.nodeId??"",depth:n.depth??null,direction:n.direction??"both",dir:n.dir??null}):console.log(pt(a)),{code:0,handled:!0,command:s}}case "impact":{let n=gt(r);if(n.help)return console.log(e("cli.impact.usage","Usage: easbot codebase impact <id> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.impact.description","Blast radius: BFS incoming CALLS / REFERENCES / USES / IMPORTS / TYPE_REFERENCES, bucketed by depth.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.impact.opt.depth","--depth=<N> BFS depth (default 3)")}`),console.log(` ${e("cli.impact.opt.relation","--relation=<r1,r2,...> Filter by relation types")}`),console.log(` ${e("cli.impact.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.impact.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await ft(n);return n.json?I(a,{nodeId:n.nodeId??"",depth:n.depth??null,dir:n.dir??null}):console.log(ht(a)),{code:0,handled:!0,command:s}}case "callers":{let n=$t(r);if(n.help)return console.log(e("cli.callers.usage","Usage: easbot codebase callers <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.callers.description","Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).")),console.log(e("cli.callers.accepts","Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.callers.opt.node_id","--node-id=<id> Raw node id from `query` / database")}`),console.log(` ${e("cli.callers.opt.file","--file=<path> File path or basename to disambiguate when same-named symbols exist")}`),console.log(` ${e("cli.callers.opt.kind","--kind=<kind> Filter by node kind (class_declaration / function_declaration / ...)")}`),console.log(` ${e("cli.callers.opt.max","--max=<N> Max callers (default 20)")}`),console.log(` ${e("cli.callers.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.callers.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await Pt(n);return n.json?I(a,{symbol:n.symbol??"",nodeId:n.nodeId??null,file:n.file??null,kind:n.kind??null,maxResults:n.maxResults??null,dir:n.dir??null}):console.log(Lt(a)),{code:0,handled:!0,command:s}}case "callees":{let n=Ft(r);if(n.help)return console.log(e("cli.callees.usage","Usage: easbot codebase callees <symbol> [--node-id=<id>] [--file=<path>] [--kind=<kind>] [--max=N] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.callees.description","Flat list of what <symbol> calls (outgoing edges).")),console.log(e("cli.callees.accepts","Accepts <symbol> name (LLM-friendly) OR --node-id for raw node id.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.callees.opt.node_id","--node-id=<id> Raw node id from `query` / database")}`),console.log(` ${e("cli.callees.opt.file","--file=<path> File path or basename to disambiguate")}`),console.log(` ${e("cli.callees.opt.kind","--kind=<kind> Filter by node kind")}`),console.log(` ${e("cli.callees.opt.max","--max=<N> Max callees (default 20)")}`),console.log(` ${e("cli.callees.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.callees.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await At(n);return n.json?I(a,{symbol:n.symbol??"",nodeId:n.nodeId??null,file:n.file??null,kind:n.kind??null,maxResults:n.maxResults??null,dir:n.dir??null}):console.log(Mt(a)),{code:0,handled:!0,command:s}}case "explore":{let n=qt(r);if(n.help)return console.log(e("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] [--dir=<worktree>]")),console.log(""),console.log(e("cli.explore.description","PRIMARY tool \u2014 single call to get source code + caller/callee trail.")),console.log(e("cli.explore.query_help","<query> can be a symbol name or natural language.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.explore.opt.file","--file=<path> File path or basename to disambiguate")}`),console.log(` ${e("cli.explore.opt.kind","--kind=<kind> Filter by node kind")}`),console.log(` ${e("cli.explore.opt.max_files","--max-files=<N> Max entry-point files (default 5)")}`),console.log(` ${e("cli.explore.opt.max_symbols","--max-symbols=<N> Max symbols per file (default 3)")}`),console.log(` ${e("cli.explore.opt.depth","--depth=<N> Neighbor depth for caller/callee trail (default 1)")}`),console.log(` ${e("cli.explore.opt.no_content","--no-content Do not include source code (locations only, default: include)")}`),console.log(` ${e("cli.explore.opt.intent","--intent=<ctx> LLM context string for ranking")}`),console.log(` ${e("cli.explore.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.explore.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await Ut(n);return n.json?I(a,{query:n.query??"",file:n.file??null,kind:n.kind??null,maxFiles:n.maxFiles??null,maxSymbols:n.maxSymbols??null,depth:n.depth??null,includeContent:n.includeContent!==!1,intent:n.intent??null,dir:n.dir??null}):console.log(await Bt(a)),{code:0,handled:!0,command:s}}case "dead-code":{let n=yt(r);if(n.help)return console.log(e("cli.dead_code.usage","Usage: easbot codebase dead-code [--type=<t1,t2,...>] [--no-exclude-entry] [--limit=N] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.dead_code.description","Find nodes with no incoming edges (heuristic dead code).")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.dead_code.opt.type","--type=<t1,t2,...> Only consider these AST types")}`),console.log(` ${e("cli.dead_code.opt.no_exclude_entry","--no-exclude-entry Include entry-point files (default: exclude)")}`),console.log(` ${e("cli.dead_code.opt.limit","--limit=<N> Max results (default 100)")}`),console.log(` ${e("cli.dead_code.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.dead_code.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await xt(n);return n.json?I(a,{astTypes:n.astTypes??null,limit:n.limit??null,excludeEntry:n.excludeEntry!==!1,dir:n.dir??null}):console.log(wt(a)),{code:0,handled:!0,command:s}}case "circular":{let n=Et(r);if(n.help)return console.log(e("cli.circular.usage","Usage: easbot codebase circular [--relation=<r>] [--scope=<file|module>] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.circular.description","Detect circular dependencies via Tarjan SCC.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.circular.opt.relation","--relation=<r> Relation type to follow (default IMPORTS)")}`),console.log(` ${e("cli.circular.opt.scope","--scope=<scope> file | module (default file)")}`),console.log(` ${e("cli.circular.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.circular.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await Ct(n);return n.json?I(a,{relation:n.relation??null,scope:n.scope??null,dir:n.dir??null}):console.log(Rt(a)),{code:0,handled:!0,command:s}}case "path":{let n=Nt(r);if(n.help)return console.log(e("cli.path.usage","Usage: easbot codebase path <from> <to> [-d=N | --depth=N] [--relation=<r1,r2,...>] [--json] [--dir=<worktree>]")),console.log(""),console.log(e("cli.path.description","Find shortest path between two nodes (BFS along CALLS / IMPORTS / TYPE_REFERENCES / USES / REFERENCES).")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.path.opt.depth","--depth=<N> BFS depth limit (default 6)")}`),console.log(` ${e("cli.path.opt.relation","--relation=<r1,r2,...> Filter by relation types")}`),console.log(` ${e("cli.path.opt.json","--json Output as JSON")}`),console.log(` ${e("cli.path.opt.dir","--dir=<worktree> Target worktree (default: cwd)")}`),{code:0,handled:!0,command:s};let a=await _t(n);return n.json?I(a,{fromId:n.fromId??"",toId:n.toId??"",depth:n.depth??null,dir:n.dir??null}):console.log(jt(a)),{code:a.found?0:1,handled:!0,command:s}}case "mcp":{let n=vt(r);return n.help?(console.log(e("cli.mcp.usage","Usage: easbot codebase mcp [dir]")),console.log(""),console.log(e("cli.mcp.description","Start a stdio MCP server exposing 9 codebase tools:")),console.log(` ${e("cli.mcp.tools.1"," query / node / context / impact")}`),console.log(` ${e("cli.mcp.tools.2"," callers / callees / explore")}`),console.log(` ${e("cli.mcp.tools.3"," status / doctor")}`),console.log(""),console.log(e("cli.mcp.transport","Connect from MCP clients via stdio JSON-RPC.")),{code:0,handled:!0,command:s}):(await Dt(n),{code:0,handled:!0,command:s})}case "watch":{let n=Ke(r);if(n.help)return console.log(e("cli.watch.usage","Usage: easbot codebase watch [--debounce=N] [--interval=N] [dir]")),console.log(""),console.log(e("cli.watch.description","Watch the workspace directory for file changes and log events.")),console.log(e("cli.watch.pid_file","Writes a pid file at .easbot/.watcher.pid for subsequent `stop`.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.watch.opt.debounce","--debounce=N Per-path debounce in ms (default 200)")}`),console.log(` ${e("cli.watch.opt.interval","--interval=N Polling interval in ms (default 500)")}`),console.log(""),console.log(e("cli.watch.note","NOTE: This command blocks. Press Ctrl+C to exit.")),{code:0,handled:!0,command:s};let a=await He(n);return console.log(Ye(a.events)),await new Promise(c=>{let h=()=>{Kt.info("watcher received signal, stopping"),c();};process.once("SIGINT",h),process.once("SIGTERM",h);}),await a.watcher.dispose(),{code:0,handled:!0,command:s}}case "stop":{let n=Xe(r);if(n.help)return console.log(e("cli.stop.usage","Usage: easbot codebase stop [dir]")),console.log(""),console.log(e("cli.stop.description","Stop a running watcher identified by .easbot/.watcher.pid.")),console.log(""),console.log(e("cli.shared.options_heading","Options:")),console.log(` ${e("cli.stop.opt.force","--force, -f Ignore errors and clear the pid file anyway")}`),{code:0,handled:!0,command:s};let a=await Ze(n);return n.json?I(a,{force:n.force===!0,dir:n.dir??null}):console.log(et(a)),{code:a.stopped?0:1,handled:!0,command:s}}default:return console.error(e("cli.unknown_command",`Unknown command: ${s}`,{command:s})),console.error(e("cli.help_hint","Run `easbot codebase --help` for available commands.")),{code:1,handled:!0,command:s}}}catch(n){let a=n instanceof Error?n.message:String(n);return console.error(e("cli.command_failed",`codebase ${s} failed: ${a}`,{command:s,message:a})),Kt.error("codebase CLI error",{command:s,error:a,stack:n instanceof Error?n.stack:void 0}),{code:1,handled:true,command:s}}}function I(o,t){console.log(JSON.stringify({ok:true,data:o,...t!==void 0?{meta:t}:{}},null,2));}function kn(o){let t={},i=[];for(let e of o)e==="--json"?t.json=true:e.startsWith("--dir=")?t.dir=e.slice(6):e.startsWith("-")||i.push(e);return t.dir===void 0&&i.length>0&&(t.dir=i[0]),t}function Nn(o){let t={},i=[];for(let e of o)e.startsWith("--dir=")?t.dir=e.slice(6):e==="--json"?t.json=true:e.startsWith("-")||i.push(e);return t.dir===void 0&&i.length>0&&(t.dir=i[0]),t}export{Sn as a,la as b,da as c};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {o,l}from'./chunk-
|
|
2
|
-
${
|
|
1
|
+
import {o,l}from'./chunk-W25T3SKH.mjs';import {c}from'./chunk-UTKA3WG3.mjs';import {a}from'./chunk-G3IYU6TZ.mjs';import {Log,Filesystem,TruncateContent}from'@easbot/utils';import {DEFAULT_SEARCH_CONFIG,DEFAULT_PARSER_CONFIG,DEFAULT_INDEXER_CONFIG,DEFAULT_EMBEDDING_CONFIG}from'@easbot/types';var R=class extends Error{constructor(n,l,a$1){super(n);a(this,"code",l);a(this,"details",a$1);this.name="ServiceError";}},P=class extends R{constructor(t,n=[]){super(`Node not found: ${t}`,"NOT_FOUND",{name:t,candidates:n});}},F=class extends R{constructor(t,n){super(`Ambiguous name "${t}" \u2014 ${n.length} candidates`,"AMBIGUOUS",{name:t,candidates:n});}};Log.create({service:"codebase-service"});var N=Filesystem.toUnixPath;async function D(e,t,n){if(n.nodeId){let o=e.getNode(n.nodeId);if(!o)throw new P(`nodeId=${n.nodeId}`);return {node:o,candidates:[]}}if(!n.name)throw new R("Either name or nodeId is required","NOT_FOUND",n);let a=e.queryNodes({limit:5e3});if(n.file){let o=N(n.file),r=a.filter(c=>N(c.file_path).endsWith(o)||N(c.file_path).includes(o));r.length>0&&(a=r);}if(n.kind){let o=n.kind.toLowerCase(),r=a.filter(c=>c.ast_type.includes(o)||c.name.toLowerCase().includes(o));r.length>0&&(a=r);}let i=a.find(o=>o.name===n.name||o.id.split(":").pop()===n.name);if(i)return {node:i,candidates:[]};let d=l(n.name,a,{limit:10,minScore:.5});if(d.length===0)throw new P(n.name);if(d.length===1){let o=e.getNode(d[0].nodeId);if(!o)throw new P(n.name);return {node:o,candidates:d.map(r=>({node:o,score:r.score}))}}let s=[];for(let o of d){let r=e.getNode(o.nodeId);r&&s.push({node:r,score:o.score});}throw s.length===0?new P(n.name):new F(n.name,s)}async function C(e){let t=c(e.rootDir),n=new o({workspaceDir:e.workspaceDir,database:{path:t,walMode:true},embedding:DEFAULT_EMBEDDING_CONFIG,indexer:DEFAULT_INDEXER_CONFIG,parser:DEFAULT_PARSER_CONFIG,search:DEFAULT_SEARCH_CONFIG,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}});return await n.initialize(),n}function ue(e,t,n,l){let a=l==="in"?e.source:e.target,i=n.getNodeById(a);return i?{id:i.id,name:i.name,astType:i.ast_type,filePath:N(i.file_path),startLine:i.start_line??0,relation:e.relation}:null}async function J(e,t){let n=Date.now(),d=await(await C(e)).getQuery().search(t.query??"",{maxResults:t.maxResults??10,language:t.language,filePath:t.file,astType:t.astType,includeEdges:true,enableFts:t.enableFts!==false,enableEmbedding:t.enableEmbedding!==false});if(t.kind){let o=t.kind.toLowerCase();d=d.filter(r=>r.ast_type.includes(o)||r.name.toLowerCase().includes(o));}if(t.file){let o=N(t.file);d=d.filter(r=>N(r.file_path).endsWith(o)||N(r.file_path).includes(o));}let s=d.map(o=>({node:o,edges:o.edges??[],source:"basic",score:0,snippet:(o.text??"").slice(0,200).replace(/\s+/g," ").trim()}));return {total:s.length,hits:s,durationMs:Date.now()-n,truncated:false}}async function pe(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t),d=[];if(t.includeEdges){let s=t.edgesLimit??50;d=a.queryEdges({sourceOrTarget:[i.id],limit:s});}return {node:i,edges:d}}var me=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","HAS_METHOD","HAS_PROPERTY","METHOD_OVERRIDES"];async function ge(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t);if(!i)return {root:null,nodes:[],edges:[],truncated:false,totalNodes:0,totalEdges:0};let d=t.depth??2,s=t.maxNodes??100,o=t.direction??"both",r=new Map,c=[{nodeId:i.id,depth:0}];r.set(i.id,0);let p=[],u=false;for(;c.length>0;){let g=c.shift();if(g.depth>=d)continue;if(r.size>=s){u=true;break}let f=l.queryNeighbors(g.nodeId,{direction:o,relationTypes:t.relationTypes??me,limit:s-r.size+1});for(let h of f.edges){p.push(h);let I=h.source===g.nodeId?h.target:h.source;if(!r.has(I)&&(r.set(I,g.depth+1),c.push({nodeId:I,depth:g.depth+1}),r.size>=s)){u=true;break}}if(u)break}let m=Array.from(r.keys()),y=m.length>0?a.queryNodes({ids:m}):[],E=new Map(y.map(g=>[g.id,g])),b=[];for(let[g,f]of r.entries()){let h=E.get(g);h&&b.push({node:h,depth:f});}return {root:i,nodes:b,edges:p,truncated:u,totalNodes:b.length,totalEdges:p.length}}var fe=["CALLS","IMPORTS","TYPE_REFERENCES"];async function he(e,t){let n=await C(e),l=n.getQuery(),a=n.getDatabase(),{node:i}=await D(l,e,t);if(!i)return {root:null,totalImpacted:0,buckets:[]};let d=t.depth??2,s=t.maxResults??50,o=t.relationTypes??fe,r=new Set([i.id]),c=[],p=[i.id];for(let u=1;u<=d&&!(p.length===0||r.size-1>=s);u++){let m=p.map(()=>"?").join(","),y=o.map(()=>"?").join(","),E=a.queryAll(`SELECT source, target, relation FROM edges WHERE target IN (${m}) AND relation IN (${y})`,[...p,...o]),b=[],g=new Set;for(let f of E)if(!r.has(f.source)&&!g.has(f.source)&&(g.add(f.source),r.add(f.source),b.push(f.source),r.size-1>=s))break;if(b.length>0){let f=b.slice(0,10),h=a.queryNodes({ids:f}),I=new Map(h.map(L=>[L.id,L])),oe=f.map(L=>{let U=I.get(L);return {id:L,name:U?.name??"(unknown)",filePath:U?N(U.file_path):"(unknown)",relation:"CALLS"}});c.push({depth:u,count:b.length,sample:oe});}p=b;}return {root:i,totalImpacted:r.size-1,buckets:c}}var ye=["CALLS","IMPORTS","TYPE_REFERENCES","EXTENDS","IMPLEMENTS","METHOD_OVERRIDES"];async function be(e,t){return k(e,t,"incoming")}async function Ee(e,t){return k(e,t,"outgoing")}async function k(e,t,n,l){let a=await C(e),i=a.getQuery(),d=a.getDatabase(),{node:s}=await D(i,e,t);if(!s)return {root:null,callers:[],truncated:false};let o=t.maxResults??20,r=t.relationTypes??ye,c=i.queryNeighbors(s.id,{direction:n,relationTypes:r,limit:o+1}),p=[];for(let m of c.edges){let y=ue(m,s.id,d,n==="incoming"?"in":"out");y&&p.push(y);}let u=p.length>o;return {root:s,callers:u?p.slice(0,o):p,truncated:u}}async function xe(e,t){if(!t.query)throw new R("explore requires a non-empty query","NOT_FOUND",{query:t.query});let l=await C(e);l.getQuery();l.getDatabase();let s=(await J(e,{query:t.query,file:t.file,kind:t.kind,intent:t.intent,maxResults:t.maxFiles??5,enableFts:true,enableEmbedding:true})).hits,o=new Map;for(let p of s){let u=N(p.node.file_path),m=o.get(u);m?m.push(p):o.set(u,[p]);}let r=t.maxSymbols??3,c=[];for(let[p,u]of o){let m=u.slice(0,r),y=[];for(let E of m){let b=await k(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"incoming"),g=await k(e,{name:E.node.name,file:p,kind:t.kind,maxResults:5},"outgoing");y.push({node:E.node,callers:b.callers,callees:g.callers});}c.push({file:p,symbols:y});}return {query:t.query,entryPoints:c,totalHits:s.length}}async function Ne(e,t){return await(await C(e)).getStatus()}async function Re(e,t){return await(await C(e)).healthCheck()}var Ce=Filesystem.toUnixPath;function Se(e){let t=e.text??"";if(!t)return false;let n=t.slice(0,80);return /\bexport\s/.test(n)||/\bpublic\s/.test(n)?true:(false)}function Te(e){let t=e.text??"";if(!t)return [];let n=t.slice(0,80),l=[];return /\basync\s/.test(n)&&l.push("async"),/\bstatic\s/.test(n)&&l.push("static"),/\babstract\s/.test(n)&&l.push("abstract"),/\breadonly\s/.test(n)&&l.push("readonly"),/\bconst\s/.test(n)&&l.push("const"),/\blet\s/.test(n)&&l.push("let"),l}function x(e){return {id:e.id,name:e.name,astType:e.ast_type,language:e.language,filePath:Ce(e.file_path),startLine:e.start_line??0,endLine:e.end_line??0,isExported:Se(e),modifiers:Te(e)}}function $(e,t){return {id:e.id,source:e.source,target:e.target,relation:e.relation,direction:t}}function j(e,t,n){return e.map((l,a)=>({node:x(l),source:t[a]??"basic",score:n[a]??0,snippet:(l.text??"").slice(0,200).replace(/\s+/g," ").trim(),edges:(l.edges??[]).slice(0,10).map(i=>$(i))}))}function z(){return {id:"",name:"",astType:"",language:"",filePath:"",startLine:0,endLine:0,isExported:false,modifiers:[]}}var Ie=Log.create({service:"codebase-format-truncate"}),Q="**`",Le="**",ee=24e3,te=25e3;async function _(e,t={}){let n=t.softLimit??ee,l=t.hardCeiling??te,a=t.toolName??"codebase",i=t.writeToDisk!==false;if(e.length<=n)return {content:e,truncated:false};let d=e.slice(0,l),s=d.lastIndexOf(`
|
|
2
|
+
${Q}`),o=d.lastIndexOf(`
|
|
3
3
|
`),r;s>l*.5?r=s:o>0?r=o:r=-1;let c=r>0?d.slice(0,r):d,u=c+"\n\n... (output truncated to budget; the source above is complete and verbatim \u2014 treat it as already Read. For any area not covered, make ANOTHER `<tool>` targeting those names \u2014 do NOT Read these files.)";if(!i)return {content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`};try{let m=await TruncateContent.truncate(e,{maxChars:c.length,direction:"head",label:`${a}-output`});return m.truncated?{content:u,truncated:!0,outputPath:m.outputPath,hint:TruncateContent.formatHint(m),info:`... ${m.removedLength}/${m.originalLength} characters truncated ...`}:{content:u,truncated:!0,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}catch(m){return Ie.warn("TruncateContent.truncate failed, returning without disk hint",{error:m instanceof Error?m.message:String(m)}),{content:u,truncated:true,outputPath:"",hint:"Use Grep/Read to inspect the truncated sections.",info:`... ${e.length-c.length}/${e.length} characters truncated ...`}}}function v(e,t={}){let n=t.softLimit??ee,l=t.hardCeiling??te;if(e.length<=n)return {content:e,truncated:false};let a=e.slice(0,l),i=a.lastIndexOf(`
|
|
4
|
-
${
|
|
4
|
+
${Q}`),d=a.lastIndexOf(`
|
|
5
5
|
`),s;i>l*.5?s=i:d>0?s=d:s=-1;let o=s>0?a.slice(0,s):a;return {content:o+`
|
|
6
6
|
|
|
7
7
|
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-o.length}/${e.length} characters truncated ...`}}function Fe(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));return n>60?">60s ago":`${n}s ago`}function H(e,t){if(!e||e.length===0)return null;let n=e.filter(a=>t.has(a.path));return n.length===0?null:`\u26A0\uFE0F Index may be stale for: ${n.map(a=>`${a.path} (edited ${Fe(a.lastEventAt)})`).join(", ")}
|
|
@@ -31,4 +31,4 @@ ${z}`),d=a.lastIndexOf(`
|
|
|
31
31
|
|
|
32
32
|
${t}
|
|
33
33
|
|
|
34
|
-
> **Tip:** ${n}`}async function A(e,t,n){let l={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?v(e,l):await _(e,l)).content}var ke=Log.create({service:"codebase-format-render"});async function De(e,t){if(e.length===0)return M([],t);let n=j(e,e.map(()=>"basic"),e.map(()=>0));return M(n,t)}async function _e(e,t,n){if(t.length===0)return q(x(e),[],n);let l=[{depth:1,count:t.length,riskLabel:K(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:x(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return q(x(e),l,n)}async function ve(e,t,n,l,a){let i=x(e),d=t.map(r=>$(r,"in")),s=n.map(r=>$(r,"out")),o=l.map(r=>({node:x(r),depth:1}));return W({root:i,incoming:d,outgoing:s,neighbors:o},a)}async function He(e,t,n){if(!e)return B(
|
|
34
|
+
> **Tip:** ${n}`}async function A(e,t,n){let l={softLimit:t.softLimit,hardCeiling:t.hardCeiling,toolName:t.toolName,writeToDisk:n?false:t.writeToDisk};return (n?v(e,l):await _(e,l)).content}var ke=Log.create({service:"codebase-format-render"});async function De(e,t){if(e.length===0)return M([],t);let n=j(e,e.map(()=>"basic"),e.map(()=>0));return M(n,t)}async function _e(e,t,n){if(t.length===0)return q(x(e),[],n);let l=[{depth:1,count:t.length,riskLabel:K(1),samples:t.slice(0,10).map(a=>({name:a.source.name,file:x(a.source).filePath,line:a.source.start_line??0,relation:a.relation}))}];return q(x(e),l,n)}async function ve(e,t,n,l,a){let i=x(e),d=t.map(r=>$(r,"in")),s=n.map(r=>$(r,"out")),o=l.map(r=>({node:x(r),depth:1}));return W({root:i,incoming:d,outgoing:s,neighbors:o},a)}async function He(e,t,n){if(!e)return B(z(),[],n);let l=x(e),a=t.map(i=>{let d=i.target===e.id?"in":"out";return $(i,d)});return B(l,a,n)}async function Me(e,t){let n={query:e.query,totalHits:e.totalHits,entryPoints:e.entryPoints.map(l=>({file:l.file,symbols:l.symbols.map(a=>({node:x(a.node),source:a.node.text??"",callers:a.callers.map(i=>({name:i.name,filePath:i.filePath,startLine:i.startLine,relation:i.relation})),callees:a.callees.map(i=>({name:i.name,filePath:i.filePath,startLine:i.startLine,relation:i.relation}))}))}))};return re(n,t)}ke.debug("format/render.ts loaded");export{_e as A,ve as B,He as C,Me as D,R as a,P as b,F as c,J as d,pe as e,ge as f,he as g,be as h,Ee as i,xe as j,Ne as k,Re as l,x as m,$ as n,j as o,z as p,Q as q,Le as r,_ as s,v as t,M as u,q as v,K as w,W as x,B as y,De as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk7XCIIOM6_cjs=require('./chunk-7XCIIOM6.cjs'),path=require('path'),os=require('os'),xdgBasedir=require('xdg-basedir');var u=null,p=null;function F(e){u=e;}function N(){u=null;}function a(){if(u)return u;let e=os.homedir();return {Path:{home:e,data:process.env.EASBOT_DATA_PATH?.trim()||path.join(xdgBasedir.xdgData??path.join(e,".local","share"),"easbot"),config:process.env.EASBOT_CONFIG_PATH?.trim()||path.join(xdgBasedir.xdgConfig??path.join(e,".config"),"easbot"),state:process.env.EASBOT_STATE_PATH?.trim()||path.join(xdgBasedir.xdgState??path.join(xdgBasedir.xdgData??path.join(e,".local","share"),"easbot"),"state"),cache:process.env.EASBOT_CACHE_PATH?.trim()||path.join(xdgBasedir.xdgCache??path.join(e,".cache"),"easbot"),log:process.env.EASBOT_LOG_PATH?.trim()||path.join(xdgBasedir.xdgState??path.join(xdgBasedir.xdgData??path.join(e,".local","share"),"easbot"),"log"),bin:process.env.EASBOT_BIN_PATH?.trim()||path.join(e,".local","bin")}}}function R(e){p=e;}function U(){p=null;}function G(){if(p)return p;let e=process.cwd();return {directory:e,worktree:e}}function g(){return a().Path.home||os.homedir()}function v(){let e=a().Path.data;return e||(xdgBasedir.xdgData??path.join(g(),".local","share"))}function q(){let e=a().Path.config;return e||(xdgBasedir.xdgConfig??path.join(g(),".config"))}function X(){let e=a().Path.state;return e||(xdgBasedir.xdgState??path.join(v(),"state"))}function L(){let e=a().Path.cache;return e||(xdgBasedir.xdgCache??path.join(g(),".cache"))}function _(){return G().directory||process.cwd()}function V(e){let t={},s=[];for(let n of e)n==="--json"?t.json=true:n==="--quiet"||n==="-q"?t.quiet=true:n==="--help"||n==="-h"?t.help=true:n==="--no-embed"?t.noEmbed=true:n==="--embed"?t.noEmbed=false:n.startsWith("-")||s.push(n);return t.dir=s[0],t}async function Y(e){let t=e.dir&&path.isAbsolute(e.dir)?e.dir:path.join(_(),e.dir??"."),s=chunk7XCIIOM6_cjs.c(t),{CodeBase:n}=await import('./code-base-HBPZXJQZ.cjs'),{DEFAULT_EMBEDDING_CONFIG:P,DEFAULT_INDEXER_CONFIG:I,DEFAULT_PARSER_CONFIG:C}=await import('@easbot/types'),c=new n({workspaceDir:t,database:{path:s,walMode:true},embedding:e.noEmbed===false?P:void 0,indexer:I,parser:C,sync:{onBoot:false,onSearch:false,onSessionStart:false,intervalMs:0}}),h,l={_lastPct:-1,_lastProgressAt:0};try{await c.initialize();let o=await c.sync(e.quiet?void 0:i=>{let E=Math.max(i.total,1),f=Math.min(100,Math.floor(i.processed/E*100)),b=Date.now(),T=f!==l._lastPct,O=b-l._lastProgressAt>3e4;if(T||O){let $=String(f).padStart(3," ");console.error(` \u{1F4A1} [${$}%] ${i.stage}: ${i.processed}/${i.total} files`),l._lastPct=f,l._lastProgressAt=b;}}),D=c.getDatabase().getIndexState();h={rootDir:t,success:o.success,filesAdded:o.filesAdded,filesUpdated:o.filesUpdated,filesDeleted:o.filesDeleted,filesSkipped:o.filesSkipped,nodesCreated:o.nodesCreated,edgesCreated:o.edgesCreated,errorCount:o.errors.length,errors:o.errors,durationMs:o.duration,indexState:D};}finally{await c.close();}return h}function Z(e){let t=[];if(t.push("Codebase sync"),t.push(` rootDir: ${e.rootDir}`),t.push(` success: ${e.success?"\u2713":"\u2717"}`),t.push(` indexState: ${e.indexState}`),t.push(` files added: ${e.filesAdded}`),t.push(` files updated: ${e.filesUpdated}`),t.push(` files deleted: ${e.filesDeleted}`),t.push(` files skipped: ${e.filesSkipped}`),t.push(` nodes created: ${e.nodesCreated}`),t.push(` edges created: ${e.edgesCreated}`),t.push(` duration: ${e.durationMs}ms`),e.errorCount>0){t.push(` errors (${e.errorCount}):`);for(let s of e.errors.slice(0,10))t.push(` - ${s.filePath}: ${s.error}`);e.errors.length>10&&t.push(` ... and ${e.errors.length-10} more`);}return t.join(`
|
|
2
|
+
`)}exports.a=F;exports.b=N;exports.c=a;exports.d=R;exports.e=U;exports.f=G;exports.g=g;exports.h=v;exports.i=q;exports.j=X;exports.k=L;exports.l=_;exports.m=V;exports.n=Y;exports.o=Z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk4KHRTABC_cjs=require('./chunk-4KHRTABC.cjs'),chunkRLZHDTHY_cjs=require('./chunk-RLZHDTHY.cjs');require('./chunk-7XCIIOM6.cjs'),require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"CodeBase",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.o}});Object.defineProperty(exports,"EdgeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.h}});Object.defineProperty(exports,"FILE_EXTENSION_MAP",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.b}});Object.defineProperty(exports,"Indexer",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.j}});Object.defineProperty(exports,"NodeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.f}});Object.defineProperty(exports,"ParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.c}});Object.defineProperty(exports,"QueryInterface",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.m}});Object.defineProperty(exports,"createCodebase",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.p}});Object.defineProperty(exports,"createEdgeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.i}});Object.defineProperty(exports,"createIndexer",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.k}});Object.defineProperty(exports,"createNodeExtractor",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.g}});Object.defineProperty(exports,"createQueryInterface",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.n}});Object.defineProperty(exports,"getParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.d}});Object.defineProperty(exports,"resetParserManager",{enumerable:true,get:function(){return chunk4KHRTABC_cjs.e}});Object.defineProperty(exports,"ConfigError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.e}});Object.defineProperty(exports,"DatabaseError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.b}});Object.defineProperty(exports,"DatabaseManager",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.n}});Object.defineProperty(exports,"FileSystemError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.c}});Object.defineProperty(exports,"IndexError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.f}});Object.defineProperty(exports,"ParserError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.a}});Object.defineProperty(exports,"QueryError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.g}});Object.defineProperty(exports,"SchemaError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.d}});Object.defineProperty(exports,"UnsupportedLanguageError",{enumerable:true,get:function(){return chunkRLZHDTHY_cjs.h}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{o as CodeBase,h as EdgeExtractor,b as FILE_EXTENSION_MAP,j as Indexer,f as NodeExtractor,c as ParserManager,m as QueryInterface,p as createCodebase,i as createEdgeExtractor,k as createIndexer,g as createNodeExtractor,n as createQueryInterface,d as getParserManager,e as resetParserManager}from'./chunk-
|
|
1
|
+
export{o as CodeBase,h as EdgeExtractor,b as FILE_EXTENSION_MAP,j as Indexer,f as NodeExtractor,c as ParserManager,m as QueryInterface,p as createCodebase,i as createEdgeExtractor,k as createIndexer,g as createNodeExtractor,n as createQueryInterface,d as getParserManager,e as resetParserManager}from'./chunk-W25T3SKH.mjs';export{e as ConfigError,b as DatabaseError,n as DatabaseManager,c as FileSystemError,f as IndexError,a as ParserError,g as QueryError,d as SchemaError,h as UnsupportedLanguageError}from'./chunk-Z4Y3VCYS.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as FileWatcher,e as clearWatcherPid,b as getWatcherPidPath,c as readWatcherPid,d as writeWatcherPid}from'./chunk-7ZBQQZOA.mjs';import'./chunk-G3IYU6TZ.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkU5G7MP3K_cjs=require('./chunk-U5G7MP3K.cjs');require('./chunk-TS4OAYIJ.cjs');Object.defineProperty(exports,"FileWatcher",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.a}});Object.defineProperty(exports,"clearWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.e}});Object.defineProperty(exports,"getWatcherPidPath",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.b}});Object.defineProperty(exports,"readWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.c}});Object.defineProperty(exports,"writeWatcherPid",{enumerable:true,get:function(){return chunkU5G7MP3K_cjs.d}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,z as z$1,e,C,f as f$1,B,g,A,h,i,j,D as D$1,k,l,b,c,a as a$1}from'./chunk-TGMIUXU3.mjs';import'./chunk-VBIXWHTD.mjs';import'./chunk-Z4Y3VCYS.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';import {ToolRegistry,createAndStartStdioServer}from'@easbot/mcp';import {Log}from'@easbot/utils';var f=Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"],U;(o=>{let n;function r(){return n||(f.debug("initializing CodebaseStdioServer state factory (lazy)"),n=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),n}async function c(s,i){let u=r()(),l=new ToolRegistry;ce(l,s);let g=u.toolNames;f.info("starting codebase MCP stdio server",{id:i.id,name:i.name,toolCount:g.length});let y=await createAndStartStdioServer(i,l),b=null,q=new Promise(d=>{b=d;}),S=d=>{f.info("received signal, stopping MCP server",{signal:d}),b?.();},x=()=>S("SIGINT"),T=()=>S("SIGTERM");process.on("SIGINT",x),process.on("SIGTERM",T);try{await q;}finally{try{process.off("SIGINT",x),process.off("SIGTERM",T);}catch(d){f.warn("failed to remove signal handlers",{error:d instanceof Error?d.message:String(d)});}try{await y.stop();}catch(d){f.warn("server.stop failed during cleanup",{error:d instanceof Error?d.message:String(d)});}try{await s.close();}catch(d){f.warn("codebase.close failed during cleanup",{error:d instanceof Error?d.message:String(d)});}}return {id:i.id,name:i.name,version:i.version,tools:g}}o.start=c;function e(){return r()().toolNames}o.getToolNames=e;function t(){n=void 0;}o.__resetForTests=t;})(U||(U={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",properties:{query:{type:"string",description:'Symbol name or partial name (e.g., "auth", "UserService"). Empty string returns recent nodes.'},kind:{type:"string",description:"Filter by node kind. One of: class, function, method, interface, type, variable, route, component, const.",enum:["class","function","method","interface","type","variable","route","component","const"]},file:{type:"string",description:'Filter by file path (substring match, e.g., "src/auth").'},intent:{type:"string",description:'LLM context for ranking (e.g., "adding OAuth support").'},includeContent:{type:"boolean",description:"Include source code snippets (default false; use `explore` for full code).",default:false},maxResults:{type:"number",description:"Maximum results",default:10,minimum:1,maximum:100},language:{type:"string",description:"Filter by programming language",enum:["ts","tsx","js","py","rs","go","c","cpp","csharp","java","scala","ruby","php","zig"]},astType:{type:"string",description:"Filter by AST node type (more specific than kind)."}},required:[]},X={type:"object",properties:{name:{type:"string",description:'Symbol name (e.g., "AuthService"). Recommended \u2014 LLM workflow: query \u2192 use returned name.'},nodeId:{type:"string",description:"Node ID (direct lookup, zero ambiguity)."},file:{type:"string",description:"File path or basename to disambiguate when multiple same-named symbols exist."},kind:{type:"string",description:"Filter by node kind (class, function, method, interface, type, variable, route, component, const)."},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},includeEdges:{type:"boolean",description:"Include edge listing (incoming + outgoing).",default:true},edgesLimit:{type:"number",description:"Max edges to return (default 50).",default:50}},required:[]},V={type:"object",properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"BFS depth (1 = direct only, 2 = default, 3 = max).",default:2,minimum:1,maximum:3},maxNodes:{type:"number",description:"Max nodes in result.",default:100,minimum:1,maximum:500},direction:{type:"string",description:"Edge direction filter",enum:["incoming","outgoing","both"],default:"both"}},required:[]},z={type:"object",properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"Max BFS depth (1-3).",default:2,minimum:1,maximum:3},maxResults:{type:"number",description:"Max affected symbols.",default:50,minimum:1,maximum:200}},required:[]},P={type:"object",properties:{name:{type:"string",description:"Symbol name to find callers for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callers to return.",default:20,minimum:1,maximum:200}},required:[]},K=P,J={type:"object",properties:{query:{type:"string",description:'Symbol name or natural language query (e.g., "auth flow", "MemorySystem").'},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxFiles:{type:"number",description:"Max entry-point files.",default:5,minimum:1,maximum:20},maxSymbols:{type:"number",description:"Max symbols per file.",default:3,minimum:1,maximum:10},depth:{type:"number",description:"Neighbor depth for callers/callees (default 1).",default:1,minimum:1,maximum:2},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},intent:{type:"string",description:"LLM context for ranking."}},required:["query"]},D={type:"object",properties:{}},Z={query:'Hybrid search over indexed code nodes (FTS + vector + basic + name-segment). Returns symbol locations grouped by file with line-numbered snippets.\n\nWHEN TO USE: Quick lookup of "where is X defined?" \u2014 get symbol locations and snippets in one call. Use `context` to understand a symbol\'s surroundings; use `impact` to see blast radius; use `explore` to get the actual source.\n\nAFTER THIS: Use `node <name>` to fetch full details of one match; use `context` to walk neighbors; use `explore` to get source code.\n\nNOTES: Default FTS-only (fast). Pass `includeContent: true` to include code snippets in results. Use `kind` for friendlier semantic filter (class/function/method/...) instead of `astType`.',node:"Show details for a single symbol: kind, language, location, modifiers, source code, edges.\n\nWHEN TO USE: After `query` / `context` returns a list \u2014 fetch one match's full metadata and edge summary. Pass `name` (preferred) or `nodeId`.\n\nAFTER THIS: Use `context` to walk neighbors; use `impact` for blast radius; use `explore` to get source code + caller/callee trail.\n\nNOTES: `name` is the LLM-friendly input. `file` / `kind` disambiguate when multiple same-named symbols exist. Source code is included by default (set `includeContent: false` for metadata only).",context:"Build a sub-graph around a symbol (BFS to N-level neighbors). Returns incoming/outgoing edges and neighbor nodes grouped by depth.\n\nWHEN TO USE: Understand a symbol's surroundings \u2014 who calls it, what it calls, who extends it. Use after `query` / `node` to get the symbol.\n\nAFTER THIS: Use `impact` for blast-radius (callers only, deeper depth). Use `callers` / `callees` for a flat list. Use `query` to find related symbols.\n\nNOTES: `name` is the LLM-friendly input. Does NOT include source code (use `explore` for code). Set `direction` to narrow to incoming/outgoing only.",impact:"Blast radius of changing a symbol: BFS incoming edges (CALLS / IMPORTS / TYPE_REFERENCES), bucketed by depth. d=1 (WILL BREAK) / d=2 (LIKELY AFFECTED) / d=3 (MAY NEED TESTING).\n\nWHEN TO USE: Before refactoring a symbol \u2014 see what depends on it. Use after `query` to get the symbol.\n\nAFTER THIS: Review d=1 first (those WILL BREAK). Use `node <name>` on high-risk nodes to read their source.\n\nNOTES: `name` is the LLM-friendly input. Returns counts per depth bucket, not full lists. For flat caller list, use `callers`.",callers:'Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / METHOD_OVERRIDES).\n\nWHEN TO USE: Quick "who depends on this?" lookup. Use `impact` for bucketed risk analysis; use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a high-traffic caller to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callers (default 20). Use `file` / `kind` to disambiguate.',callees:'Flat list of what <symbol> calls (outgoing CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).\n\nWHEN TO USE: Quick "what does this function do?" lookup. Use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a key callee to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callees (default 20). Use `file` / `kind` to disambiguate.',explore:"**PRIMARY TOOL \u2014 call FIRST** for almost any question OR before an edit: how does X work, architecture, a bug, where/what is X, surveying an area, or symbols you are about to change.\n\nReturns verbatim source of relevant symbols grouped by file in ONE capped call (Read-equivalent \u2014 treat shown source as already Read; do NOT re-open those files), plus caller/callee trail.\n\nWHEN TO USE: Whenever you need to understand an area of the codebase or before refactoring. Query can be a symbol name or natural language.\n\nAFTER THIS: Use `node <name>` for metadata only; use `impact` for blast-radius; use `callers` / `callees` for flat lists.\n\nNOTES: Usually the ONLY call you need \u2014 more accurate context, in far fewer tokens and round-trips than search/Read/Grep loop. The single most cost-effective tool.",status:`Show index state, db path, node/edge counts, indexed files, meta config.
|
|
1
|
+
import {d,z as z$1,e,C,f as f$1,B,g,A,h,i,j,D as D$1,k,l,b,c,a as a$1}from'./chunk-XQID3NKI.mjs';import'./chunk-W25T3SKH.mjs';import'./chunk-Z4Y3VCYS.mjs';import'./chunk-UTKA3WG3.mjs';import'./chunk-G3IYU6TZ.mjs';import {ToolRegistry,createAndStartStdioServer}from'@easbot/mcp';import {Log}from'@easbot/utils';var f=Log.create({service:"codebase-mcp-stdio"}),Y=["query","node","context","impact","callers","callees","explore","status","doctor"],U;(o=>{let n;function r(){return n||(f.debug("initializing CodebaseStdioServer state factory (lazy)"),n=()=>({toolNames:[...Y],cachedConfigId:"",cachedConfigName:"",cachedConfigVersion:""})),n}async function c(s,i){let u=r()(),l=new ToolRegistry;ce(l,s);let g=u.toolNames;f.info("starting codebase MCP stdio server",{id:i.id,name:i.name,toolCount:g.length});let y=await createAndStartStdioServer(i,l),b=null,q=new Promise(d=>{b=d;}),S=d=>{f.info("received signal, stopping MCP server",{signal:d}),b?.();},x=()=>S("SIGINT"),T=()=>S("SIGTERM");process.on("SIGINT",x),process.on("SIGTERM",T);try{await q;}finally{try{process.off("SIGINT",x),process.off("SIGTERM",T);}catch(d){f.warn("failed to remove signal handlers",{error:d instanceof Error?d.message:String(d)});}try{await y.stop();}catch(d){f.warn("server.stop failed during cleanup",{error:d instanceof Error?d.message:String(d)});}try{await s.close();}catch(d){f.warn("codebase.close failed during cleanup",{error:d instanceof Error?d.message:String(d)});}}return {id:i.id,name:i.name,version:i.version,tools:g}}o.start=c;function e(){return r()().toolNames}o.getToolNames=e;function t(){n=void 0;}o.__resetForTests=t;})(U||(U={}));var G={readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},Q={type:"object",properties:{query:{type:"string",description:'Symbol name or partial name (e.g., "auth", "UserService"). Empty string returns recent nodes.'},kind:{type:"string",description:"Filter by node kind. One of: class, function, method, interface, type, variable, route, component, const.",enum:["class","function","method","interface","type","variable","route","component","const"]},file:{type:"string",description:'Filter by file path (substring match, e.g., "src/auth").'},intent:{type:"string",description:'LLM context for ranking (e.g., "adding OAuth support").'},includeContent:{type:"boolean",description:"Include source code snippets (default false; use `explore` for full code).",default:false},maxResults:{type:"number",description:"Maximum results",default:10,minimum:1,maximum:100},language:{type:"string",description:"Filter by programming language",enum:["ts","tsx","js","py","rs","go","c","cpp","csharp","java","scala","ruby","php","zig"]},astType:{type:"string",description:"Filter by AST node type (more specific than kind)."}},required:[]},X={type:"object",properties:{name:{type:"string",description:'Symbol name (e.g., "AuthService"). Recommended \u2014 LLM workflow: query \u2192 use returned name.'},nodeId:{type:"string",description:"Node ID (direct lookup, zero ambiguity)."},file:{type:"string",description:"File path or basename to disambiguate when multiple same-named symbols exist."},kind:{type:"string",description:"Filter by node kind (class, function, method, interface, type, variable, route, component, const)."},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},includeEdges:{type:"boolean",description:"Include edge listing (incoming + outgoing).",default:true},edgesLimit:{type:"number",description:"Max edges to return (default 50).",default:50}},required:[]},V={type:"object",properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"BFS depth (1 = direct only, 2 = default, 3 = max).",default:2,minimum:1,maximum:3},maxNodes:{type:"number",description:"Max nodes in result.",default:100,minimum:1,maximum:500},direction:{type:"string",description:"Edge direction filter",enum:["incoming","outgoing","both"],default:"both"}},required:[]},z={type:"object",properties:{name:{type:"string",description:"Symbol name \u2014 LLM workflow friendly."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind in BFS result."},depth:{type:"number",description:"Max BFS depth (1-3).",default:2,minimum:1,maximum:3},maxResults:{type:"number",description:"Max affected symbols.",default:50,minimum:1,maximum:200}},required:[]},P={type:"object",properties:{name:{type:"string",description:"Symbol name to find callers for."},nodeId:{type:"string",description:"Node ID (direct lookup)."},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxResults:{type:"number",description:"Max callers to return.",default:20,minimum:1,maximum:200}},required:[]},K=P,J={type:"object",properties:{query:{type:"string",description:'Symbol name or natural language query (e.g., "auth flow", "MemorySystem").'},file:{type:"string",description:"File path or basename to disambiguate."},kind:{type:"string",description:"Filter by node kind."},maxFiles:{type:"number",description:"Max entry-point files.",default:5,minimum:1,maximum:20},maxSymbols:{type:"number",description:"Max symbols per file.",default:3,minimum:1,maximum:10},depth:{type:"number",description:"Neighbor depth for callers/callees (default 1).",default:1,minimum:1,maximum:2},includeContent:{type:"boolean",description:"Include source code body (default true).",default:true},intent:{type:"string",description:"LLM context for ranking."}},required:["query"]},D={type:"object",properties:{}},Z={query:'Hybrid search over indexed code nodes (FTS + vector + basic + name-segment). Returns symbol locations grouped by file with line-numbered snippets.\n\nWHEN TO USE: Quick lookup of "where is X defined?" \u2014 get symbol locations and snippets in one call. Use `context` to understand a symbol\'s surroundings; use `impact` to see blast radius; use `explore` to get the actual source.\n\nAFTER THIS: Use `node <name>` to fetch full details of one match; use `context` to walk neighbors; use `explore` to get source code.\n\nNOTES: Default FTS-only (fast). Pass `includeContent: true` to include code snippets in results. Use `kind` for friendlier semantic filter (class/function/method/...) instead of `astType`.',node:"Show details for a single symbol: kind, language, location, modifiers, source code, edges.\n\nWHEN TO USE: After `query` / `context` returns a list \u2014 fetch one match's full metadata and edge summary. Pass `name` (preferred) or `nodeId`.\n\nAFTER THIS: Use `context` to walk neighbors; use `impact` for blast radius; use `explore` to get source code + caller/callee trail.\n\nNOTES: `name` is the LLM-friendly input. `file` / `kind` disambiguate when multiple same-named symbols exist. Source code is included by default (set `includeContent: false` for metadata only).",context:"Build a sub-graph around a symbol (BFS to N-level neighbors). Returns incoming/outgoing edges and neighbor nodes grouped by depth.\n\nWHEN TO USE: Understand a symbol's surroundings \u2014 who calls it, what it calls, who extends it. Use after `query` / `node` to get the symbol.\n\nAFTER THIS: Use `impact` for blast-radius (callers only, deeper depth). Use `callers` / `callees` for a flat list. Use `query` to find related symbols.\n\nNOTES: `name` is the LLM-friendly input. Does NOT include source code (use `explore` for code). Set `direction` to narrow to incoming/outgoing only.",impact:"Blast radius of changing a symbol: BFS incoming edges (CALLS / IMPORTS / TYPE_REFERENCES), bucketed by depth. d=1 (WILL BREAK) / d=2 (LIKELY AFFECTED) / d=3 (MAY NEED TESTING).\n\nWHEN TO USE: Before refactoring a symbol \u2014 see what depends on it. Use after `query` to get the symbol.\n\nAFTER THIS: Review d=1 first (those WILL BREAK). Use `node <name>` on high-risk nodes to read their source.\n\nNOTES: `name` is the LLM-friendly input. Returns counts per depth bucket, not full lists. For flat caller list, use `callers`.",callers:'Flat list of who calls <symbol> (incoming CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS / METHOD_OVERRIDES).\n\nWHEN TO USE: Quick "who depends on this?" lookup. Use `impact` for bucketed risk analysis; use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a high-traffic caller to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callers (default 20). Use `file` / `kind` to disambiguate.',callees:'Flat list of what <symbol> calls (outgoing CALLS / IMPORTS / TYPE_REFERENCES / EXTENDS / IMPLEMENTS).\n\nWHEN TO USE: Quick "what does this function do?" lookup. Use `context` for both directions.\n\nAFTER THIS: Use `node <name>` on a key callee to read its source.\n\nNOTES: `name` is the LLM-friendly input. Returns up to `maxResults` callees (default 20). Use `file` / `kind` to disambiguate.',explore:"**PRIMARY TOOL \u2014 call FIRST** for almost any question OR before an edit: how does X work, architecture, a bug, where/what is X, surveying an area, or symbols you are about to change.\n\nReturns verbatim source of relevant symbols grouped by file in ONE capped call (Read-equivalent \u2014 treat shown source as already Read; do NOT re-open those files), plus caller/callee trail.\n\nWHEN TO USE: Whenever you need to understand an area of the codebase or before refactoring. Query can be a symbol name or natural language.\n\nAFTER THIS: Use `node <name>` for metadata only; use `impact` for blast-radius; use `callers` / `callees` for flat lists.\n\nNOTES: Usually the ONLY call you need \u2014 more accurate context, in far fewer tokens and round-trips than search/Read/Grep loop. The single most cost-effective tool.",status:`Show index state, db path, node/edge counts, indexed files, meta config.
|
|
2
2
|
|
|
3
3
|
WHEN TO USE: Diagnostic only \u2014 check whether the index is up-to-date or stale. Skip unless debugging.
|
|
4
4
|
|