CapyIdx
CapyIdx indexes source repositories into SQLite and provides deterministic symbol lookup and code reconstruction. It is designed to be embedded in tools that need repository-aware code context. It has incremental re-indexing feature that re-indexes only modified or deleted (deteles indexes of deleted file) files. It looks for files which are modified and after a set interval(default=5 sec) it re-indexes them.
Installation
python -m pip install capyidx
For development:
python -m pip install -e ".[dev]"
The core package uses Tree-sitter for source parsing and tiktoken for chunk
size calculations. Optional integrations can be installed with extras:
python -m pip install "capyidx[openai]"
python -m pip install "capyidx[ollama]"
python -m pip install "capyidx[local-embeddings]"
python -m pip install "capyidx[vector]"
Basic usage
Indexing is asynchronous. The convenience API waits for the initial pass to finish:
import asyncio
from capyidx import index_repo, lookup_symbol
async def main() -> None:
repo = "/path/to/git/repository"
await index_repo(repo)
result = await lookup_symbol(repo, "MyClass", detail="body")
for match in result.matches:
print(match.name, match.path, match.start_line, match.end_line)
if result.selected is not None:
print(result.selected.code)
asyncio.run(main())
Use index_repo_iter when progress updates are needed:
from capyidx import index_repo_iter
async for update in index_repo_iter("/path/to/git/repository"):
print(update.status, update.progress, update.desc)
Pass watch=True to continue indexing changed files after the initial pass.
The watcher uses watchdog(recommended) when installed and otherwise falls back to polling.
Query workflows
lookup_symbolreturns matching symbol metadata and reconstructs a unique exact match.reconstruct_symbolreconstructs a previously selected symbol by ID.resolve_lookupreconstructs every match for a name.open_lookupreuses one database connection for multiple queries.
Use detail="signature" for declaration-only results, and use
filter_paths to restrict lookup to selected path prefixes.
Current scope
The public convenience API currently builds the chunk/symbol index and exposes
deterministic symbol retrieval. FTS, code-snippet, embedding, and LanceDB
backends are present as lower-level components but are not automatically wired
into index_repo yet.
Indexes are stored under ~/.capyidx/.codebase_index by default. Set
CAPYIDX_HOME to use a different data directory.
Development checks
python -m compileall -q src tests
pytest
python -m build
The repository's CI runs these checks on Python 3.10, 3.11, and 3.12.
Release files for capyidx 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| capyidx-0.1.2.tar.gz | 75.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| capyidx-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 165.6 kB
Release files / capyidx-0.1.2.tar.gz
| Download URL | capyidx-0.1.2.tar.gz |
|---|---|
| Size | 75.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cad4285bb6fb0153c257e5f18fe390516029225e3183a6bd47185c1db0c0a4de
|
|
BLAKE2b-256 checksum How to use checksums |
3a6338094547e9d6578efdf5d6f48ba71efa652ca2bcebc511cdb9d1ae0a4afa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Release files / capyidx-0.1.2-py3-none-any.whl
| Download URL | capyidx-0.1.2-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d0ae1fc1ac5978a5b03ac9b8f11c36a3a1e04f2ee0d462e5541b6f7d107affb
|
|
BLAKE2b-256 checksum How to use checksums |
c510e7b0d1546cc12afb5a056dda621558ddb04305e04e4083af47b151c0be66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|