xIPnexxIPnex

code_search

一句话

code_search 是给 AI 用来快速 grep 代码的工具——比 unified_search.code_search 更轻、调用更快,专攻两个场景:

scope找什么后端
scope="sandbox"当前会话 sandbox 里临时下载/生成的代码ripgrep + ast-grep
scope="kb"知识库里零索引档 / 轻索引档的代码(不需要等索引)ripgrep + ast-grep over 本地缓存

重索引档的代码搜索(trigram、跨仓 navigate、向量语义)走 unified_search.code_searchcode_search 不做这些。


场景用哪个
AI 刚把一个仓库下载到 sandbox 里,要快速找一段代码code_search(scope="sandbox")
知识库里挂了一个零/轻索引代码库,文本/AST grepcode_search(scope="kb", kb_ids=[...])
跨仓查"这个函数被谁调用"——需要语义图unified_search.code_search(mode="navigate")
用自然语言找代码——需要向量召回unified_search.code_search(mode="semantic")

模式

mode引擎适合
textripgrep字面、正则、文件名
astast-grep结构匹配("所有 try-except 没 log 的")

相关

On this page