feat(search): query other indexes with -C and the MCP repo argument
Lets you query a second index without custom index locations. Each tree keeps its own <root>/.vera. The use case comes from @ple1n (#302): searching a project plus an index of the local cargo crate cache.
CLI
vera -C <DIR>(--directory) changes directory before running the command, likegit -C. It is accepted only before the subcommand:vera index ~/.cargo/registry/src --full-text-only vera -C ~/.cargo/registry/src search "retry backoff"vera grepgets-Cas the short form of--context, matching grep and rg habits.vera grep foo -C 3used to be a parse error. Because the top-level-Cis not global, the two never collide:vera -C dir grep foo -C 1works.
MCP
- Every tool accepts an optional
repoargument. The existing search context is keyed by configuration, not repository, so one long-running server already serves any number of indexes with a single loaded model. - A
repoother than the server's working directory must already be indexed. It is never auto-indexed or watched, so a wrong path such as/cannot start a filesystem-wide index or a huge inotify watch. - Omitting
repokeeps today's behavior.
This replaces the --save/--index-dir plus load_index/list_indexes design from #302. Vera derives the repository root from the index directory in many places, so moving indexes would mean threading an explicit root through about 25 files. The use case works without that.
Tests:
- CLI:
-Cwith absolute and relative directories,--directory, and grep-C N. - MCP: all seven tools against a secondary keyword index, refusal of an unindexed
repowithout creating anything, and root resolution.
Summary by cubic
Lets you query a second index without custom index locations. Each tree keeps its own <root>/.vera, so you can search a dependency download directory and your project from the same session. Tests cover CLI -C with absolute and relative directories, grep -C N, and MCP queries against a secondary index.
CLI
vera -C <DIR>(--directory) changes directory before running the command, likegit -C. It is accepted only before the subcommand.vera grepgets-Cas the short form of--context, matching grep and rg habits. The top-level-Cis not global, sovera -C dir grep foo -C 1works.vera watch .now watches the index that covers., likevera update, instead of a subdirectory without its own index.
MCP
- Every tool accepts an optional
repoargument. One long-running server serves any number of indexes with a single loaded model. - A
repoother than the server's working directory must already be indexed. It is never auto-indexed or watched. get_statsandget_overviewkeep their existingpathargument;repotakes precedence when both are given. Omittingrepokeeps today's behavior.- Stale-index warnings now suggest the matching
vera -C <repo>command, shell-quoting paths that need it. Docs and the Vera skill explain pointing Vera at its ownvera serveinstance to reuse one loaded model across commands, sessions, and indexes.
Summary by CodeRabbit
-
New Features
- Added a global
-C/--directoryoption to run commands from a specified directory. - MCP tools can query a selected, pre-indexed repository using the
repoargument. - Added
-Cas a shortcut for setting grep context lines.
- Added a global
-
Bug Fixes
- Improved index discovery and watching for repositories, including paths with spaces.
- Stale-index notices now provide commands tailored to the selected repository.
-
Documentation
- Updated CLI and MCP guidance for directory selection, repository indexing, and persistent inference servers.