ccc

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ccc - Semantic Code Search & Indexing

ccc - 语义代码搜索与索引

ccc
is the CLI for CocoIndex Code, providing semantic search over the current codebase and index management.
ccc
是CocoIndex Code的CLI工具,可对当前代码库进行语义搜索并提供索引管理功能。

Prerequisites

前置条件

The current project must be initialized before
ccc search
or
ccc index
can be used. If either command fails with an error about missing initialization or the tool not being found, refer to management.md for installation and initialization instructions.
在使用
ccc search
ccc index
命令前,必须先初始化当前项目。如果任一命令因未初始化或未找到工具而报错,请参考management.md获取安装和初始化说明。

Searching the Codebase

搜索代码库

To perform a semantic search:
bash
ccc search <query terms>
The query should describe the concept, functionality, or behavior to find, not exact code syntax. For example:
bash
ccc search database connection pooling
ccc search user authentication flow
ccc search error handling retry logic
要执行语义搜索:
bash
ccc search <query terms>
查询语句应描述要查找的概念、功能或行为,而非精确的代码语法。例如:
bash
ccc search database connection pooling
ccc search user authentication flow
ccc search error handling retry logic

Filtering Results

过滤结果

  • By language (
    --lang
    , repeatable): restrict results to specific languages.
    bash
    ccc search --lang python --lang markdown database schema
  • By path (
    --path
    ): restrict results to a glob pattern relative to project root. If omitted, defaults to the current working directory (only results under that subdirectory are returned).
    bash
    ccc search --path 'src/api/*' request validation
  • 按语言筛选
    --lang
    ,可重复使用):将结果限制为特定语言。
    bash
    ccc search --lang python --lang markdown database schema
  • 按路径筛选
    --path
    ):将结果限制为相对于项目根目录的通配符模式。如果省略,默认使用当前工作目录(仅返回该子目录下的结果)。
    bash
    ccc search --path 'src/api/*' request validation

Pagination

分页

Results default to the first page. To retrieve additional results:
bash
ccc search --offset 5 --limit 5 database schema
If all returned results look relevant, use
--offset
to fetch the next page — there are likely more useful matches beyond the first page.
结果默认显示第一页。要获取更多结果:
bash
ccc search --offset 5 --limit 5 database schema
如果返回的所有结果看起来都相关,使用
--offset
参数获取下一页——第一页之外可能还有更多有用的匹配结果。

Refreshing the Index Before Search

搜索前刷新索引

To ensure the index reflects the latest code changes before searching:
bash
ccc search --refresh <query terms>
This is equivalent to running
ccc index
followed by
ccc search
.
为确保搜索前索引反映最新的代码变更:
bash
ccc search --refresh <query terms>
这等效于先运行
ccc index
,再运行
ccc search

Working 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
    Read
    tool) to load the matched file and read lines around the returned range for full context.
  • When working in a terminal without a file-reading tool, use
    sed -n '<start>,<end>p' <file>
    to extract a specific line range.
搜索结果包含文件路径和行号范围。要更详细地查看结果:
  • 使用编辑器内置的文件读取功能(例如
    Read
    工具)加载匹配的文件,并读取返回范围附近的行以获取完整上下文。
  • 在没有文件读取工具的终端中,使用
    sed -n '<start>,<end>p' <file>
    命令提取特定行范围。

Updating the Index

更新索引

After making code changes, update the index to keep search results current:
bash
ccc index
This blocks until indexing completes, showing progress. If indexing is already in progress, it waits for completion.
Run
ccc index
proactively after significant code changes (new files, refactors, renamed modules) to ensure subsequent searches return accurate results.
代码变更后,更新索引以保持搜索结果的时效性:
bash
ccc index
该命令会阻塞直到索引完成,并显示进度。如果索引已在进行中,它会等待完成。在重大代码变更(新增文件、重构、重命名模块)后,建议主动运行
ccc index
,以确保后续搜索返回准确结果。

Management & Troubleshooting

管理与故障排除

For installation, initialization, daemon management, troubleshooting, and cleanup commands, see management.md.
关于安装、初始化、守护进程管理、故障排除和清理命令,请参考management.md