Code Index Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/tools/code_index, crates/cheng-code-index/src

Code intelligence over an indexed workspace: jump to a definition, find every reference, or search symbols across the project. These answer structural questions that grep cannot — a reference search returns call sites, not string matches. They all depend on the workspace index, so check tools/code_index_status first when a lookup comes back empty; an unindexed or stale workspace looks exactly like a symbol that does not exist.

Code Index Status — tools/code_index_status

Report code-intelligence index status for the active workspace (files/symbols/references, lifecycle, parser version) and optionally run explicit incremental (re)indexing, blocking or async.

Inputs

FieldTypeRequiredDefaultDescription
reindexboolean—falseRun (incremental) workspace indexing before reporting status. Default false: status query only, never triggers indexing implicitly.
reindex_modeenum—nullWith reindex=true: 'blocking' (default, waits for completion) or 'async' (enqueue a background job and return its id/state immediately; recommended for large workspaces). Options: blocking, async
workspace_pathstring—nullOptional; omit to use the session workspace.

Outputs

FieldTypeDescription
errorstringError message if the operation failed
index_missingbooleanTrue when no files have been indexed yet
indexed_filesintegerNumber of indexed files
job_idstringBackground indexing job ID (async reindex or when an active job exists)
job_statestringBackground indexing job state: queued, running, completed, failed, or cancelled
lifecyclestringIndex lifecycle state: missing, queued, running, ready, stale, or failed
parser_versionstringParser version used by the indexed content
reindexedbooleanTrue when (re)indexing was executed in this call (blocking completed or async enqueued)
reportobjectSummary of the indexing run (blocking reindex only)
stalebooleanTrue when the index is marked stale (e.g. grammar version changed or files modified)
total_referencesintegerTotal number of references in the index
total_symbolsintegerTotal number of symbols in the index
workspace_idstringWorkspace identifier (canonical root path for server-local, or client workspace label for client-local)

Goto Definition — tools/goto_definition

Find the definition site(s) of a symbol by exact name in the active workspace's index. Returns precise name-identifier position plus full definition span. Read-only.

Inputs

FieldTypeRequiredDefaultDescription
symbolstring✅—Exact symbol name (unqualified, e.g. 'compute_total' not 'util::compute_total')
workspace_pathstring—nullOptional; omit to use the session workspace.

Outputs

FieldTypeDescription
auto_reindex_triggeredbooleanTrue when an async reindex was scheduled because this query found the index missing
definitionsarray<object>List of definition sites (ambiguous symbols may have multiple definitions)
errorstringError message if the operation failed
foundbooleanTrue when at least one definition was found
index_missingbooleanTrue when the index is missing (run code_index_status with reindex=true first)
job_idstringAuto-reindex job ID
job_statestringAuto-reindex job state: queued or running
stalebooleanTrue when the index is stale

Find References — tools/find_references

Find usage sites (calls, type references, macro invocations, imports, identifiers) of a symbol by exact name in the active workspace's index. Read-only.

Inputs

FieldTypeRequiredDefaultDescription
kindstring——Optional reference-kind filter: call, type, macro, identifier, import
limitinteger——Max returned references, default 200, hard cap 2000
symbolstring✅—Exact symbol name whose usages to find
workspace_pathstring—nullOptional; omit to use the session workspace.

Outputs

FieldTypeDescription
auto_reindex_triggeredbooleanTrue when an async reindex was scheduled because this query found the index missing
errorstringError message if the operation failed
index_missingbooleanTrue when the index is missing (run code_index_status with reindex=true first)
job_idstringAuto-reindex job ID
job_statestringAuto-reindex job state: queued or running
referencesarray<object>List of reference locations
stalebooleanTrue when the index is stale
totalintegerNumber of returned references
truncatedbooleanTrue when results were truncated by the limit

Workspace Symbols — tools/workspace_symbols

Search indexed symbol definitions across the active workspace by case-insensitive substring. A missing index is asynchronously warmed and reported without delaying this query.

Inputs

FieldTypeRequiredDefaultDescription
limitinteger——Max returned symbols, default 50, hard cap 500
querystring✅—Symbol name query (substring, case-insensitive)
workspace_pathstring—nullOptional; omit to use the session workspace.

Outputs

FieldTypeDescription
auto_reindex_triggeredbooleanTrue when an async reindex was scheduled because this query found the index missing
errorstringError message if the operation failed
index_missingbooleanTrue when the index is missing (async warm-up requested by this query)
job_idstringAuto-reindex job ID (null when the local executor has no persistent job ID)
job_statestringAuto-reindex job state: queued or running
stalebooleanTrue when the index is stale (results may be incomplete or drifted)
symbolsarray<object>List of matched symbols
totalintegerNumber of returned symbols
truncatedbooleanTrue when results were truncated by the limit

Next steps