codeindex
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecodeindex - Semantic Code Search & Indexing
codeindex - 语义代码搜索与索引
codeindexcodeindexOwnership
所有权
The agent owns the lifecycle for the current project — initialization, indexing, and searching. Do not ask the user to perform these steps; handle them automatically.
codeindex- Initialization: If or
codeindex searchfails with an initialization error (e.g., "Not in an initialized project directory"), runcodeindex indexfrom the project root directory, thencodeindex initto build the index, then retry the original command.codeindex index - Index freshness: Keep the index up to date by running when the index may be stale — e.g., at the start of a session, or after making significant code changes (new files, refactors, renamed modules). There is no need to re-index between consecutive searches if no code was changed in between.
codeindex index - Installation: If itself is not found (command not found), refer to management.md for installation instructions and inform the user.
codeindex
Agent 负责当前项目中 的生命周期——初始化、索引和搜索。请勿要求用户执行这些步骤;请自动处理。
codeindex- 初始化:如果 或
codeindex search因初始化错误(例如“Not in an initialized project directory”)失败,请从项目根目录运行codeindex index,然后运行codeindex init构建索引,之后重试原命令。codeindex index - 索引新鲜度:当索引可能过期时(例如会话开始时,或进行重大代码变更后,如新增文件、重构、重命名模块),运行 以保持索引最新。如果两次连续搜索之间没有修改代码,则无需重新索引。
codeindex index - 安装:如果未找到 (command not found),请参考 management.md 获取安装说明并告知用户。
codeindex
Searching the Codebase
搜索代码库
To perform a semantic search:
bash
codeindex search <query terms>To perform a sematic search filter by path:
bash
codeindex search -path . "authentication logic"Note: Flags must precede the query string.
The query should describe the concept, functionality, or behavior to find, not exact code syntax. For example:
bash
codeindex search database connection pooling
codeindex search user authentication flow
codeindex search error handling retry logic执行语义搜索:
bash
codeindex search <query terms>按路径过滤执行语义搜索:
bash
codeindex search -path . "authentication logic"注意:标志必须位于查询字符串之前。
查询应描述要查找的概念、功能或行为,而非确切的代码语法。例如:
bash
codeindex search database connection pooling
codeindex search user authentication flow
codeindex search error handling retry logicFiltering Results
过滤结果
-
By language (): restrict results to specific languages (comma-separated).
-langbashcodeindex search -lang python,markdown database schema -
By path (): restrict results to files matching glob patterns (comma-separated).
-globbashcodeindex search -glob 'src/api/**' request validation -
Limit results (): maximum number of results (default: from config
-limit).search_limitbashcodeindex search -limit 10 database schema -
Files only (): show only file paths and metadata without content.
-filesbashcodeindex search -files database schema -
Hybrid search (): combine vector embeddings with keyword matching (TF-IDF) for better precision with technical terms.
-hybridbashcodeindex search -hybrid "EmbeddingProvider interface" -
Score threshold: Results below(from config) are automatically filtered out.
score_threshold
Hybrid Search:
Hybrid search combines semantic vector search with keyword matching:
- Vector search: Understands semantic meaning ("database connection" → connection pooling code)
- Keyword matching: Finds exact terms ("EmbeddingProvider" → exact interface name)
- Combined score:
vector_weight * vector_score + keyword_weight * keyword_score
Enable in config:
json
{
"hybrid_search": true,
"vector_weight": 0.7,
"keyword_weight": 0.3
}Or use per-query with flag.
-hybrid-
按语言 ():将结果限制为特定语言(逗号分隔)。
-langbashcodeindex search -lang python,markdown database schema -
按路径 ():将结果限制为匹配glob模式的文件(逗号分隔)。
-globbashcodeindex search -glob 'src/api/**' request validation -
限制结果数量 ():结果的最大数量(默认值:来自配置
-limit)。search_limitbashcodeindex search -limit 10 database schema -
仅显示文件 ():仅显示文件路径和元数据,不显示内容。
-filesbashcodeindex search -files database schema -
混合搜索 ():将向量嵌入与关键词匹配(TF-IDF)相结合,提高技术术语的搜索精度。
-hybridbashcodeindex search -hybrid "EmbeddingProvider interface" -
分数阈值:低于配置中的结果会被自动过滤掉。
score_threshold
混合搜索:
混合搜索结合了语义向量搜索与关键词匹配:
- 向量搜索:理解语义含义(例如“database connection”会找到连接池代码)
- 关键词匹配:查找确切术语(例如“EmbeddingProvider”会找到确切的接口名称)
- 综合分数:
vector_weight * vector_score + keyword_weight * keyword_score
在配置中启用:
json
{
"hybrid_search": true,
"vector_weight": 0.7,
"keyword_weight": 0.3
}或在每次查询时使用 标志。
-hybridPagination
分页
Results default to the first page (limit: 5). To retrieve additional results:
bash
codeindex search -offset 5 -limit 5 database schemaIf all returned results look relevant, use to fetch the next page — there are likely more useful matches beyond the first page.
-offset结果默认显示第一页(限制:5条)。要获取更多结果:
bash
codeindex search -offset 5 -limit 5 database schema如果返回的所有结果看起来都相关,请使用 获取下一页——第一页之外可能还有更多有用的匹配项。
-offsetWorking with Search Results
处理搜索结果
Search results include file paths and line ranges. To explore a result in more detail:
- Use the editor's built-in file reading capabilities (e.g., the tool) to load the matched file and read lines around the returned range for full context.
Read - When working in a terminal without a file-reading tool, use to extract a specific line range.
sed -n '<start>,<end>p' <file>
搜索结果包含文件路径和行范围。要更详细地查看结果:
- 使用编辑器内置的文件读取功能(例如 工具)加载匹配的文件,并读取返回范围周围的行以获取完整上下文。
Read - 在没有文件读取工具的终端中,使用 提取特定行范围。
sed -n '<start>,<end>p' <file>
Settings
设置
To view or edit embedding model configuration, include/exclude patterns, or language overrides, see settings.md.
要查看或编辑嵌入模型配置、包含/排除模式或语言覆盖设置,请参阅 settings.md。
Management & Troubleshooting
管理与故障排除
For installation, initialization, troubleshooting, and cleanup commands, see management.md.
有关安装、初始化、故障排除和清理命令,请参阅 management.md。