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 deletedd (deteles indexes of deleted file) files. It looks for files which are modified and after a set interval(default=5 sec (modifiable)) 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.1
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.1.tar.gz | 75.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| capyidx-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 164.8 kB
Release files / capyidx-0.1.1.tar.gz
| Download URL | capyidx-0.1.1.tar.gz |
|---|---|
| Size | 75.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f87c1df40f45522c51d85c070c73f5d7fda5191283a5fec84d739ca8c21c0f6b
|
|
BLAKE2b-256 checksum How to use checksums |
3d6fa0c9f7012d8ec26f4c11da3c7176fe1ca4d8ef0bcef0725ea054166c5e0e
|
| 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.1-py3-none-any.whl
| Download URL | capyidx-0.1.1-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3bfcfa1420b6950ade01cbc0c96ce37de9c7f12f6ad91aab9544aa2f13a35e65
|
|
BLAKE2b-256 checksum How to use checksums |
252cd3930b374334336b22545f4d16fe7a0b7f184ad3105e20c185ab63be8eee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|