Skip to main content

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_symbol returns matching symbol metadata and reconstructs a unique exact match.
  • reconstruct_symbol reconstructs a previously selected symbol by ID.
  • resolve_lookup reconstructs every match for a name.
  • open_lookup reuses 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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for capyidx 0.1.3
File Size Uploaded
capyidx-0.1.3.tar.gz 76.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for capyidx 0.1.3
File Interpreter ABI Platform
capyidx-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 166.0 kB

Release files / capyidx-0.1.3.tar.gz

Download URL capyidx-0.1.3.tar.gz
Size 76.1 kB
Tags Source
SHA-256 checksum
How to use checksums
72db51bc74b1b510b229522cbe3c79f30bbeeb58e31f5246e1d146b3ec8f9bc5
BLAKE2b-256 checksum
How to use checksums
e9b4e097120ac8a96b748d1d360906e995f4f7f2d12d5f2ebef64d9c20987ff3
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.3-py3-none-any.whl

Download URL capyidx-0.1.3-py3-none-any.whl
Size 89.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9576a03582c784a88b9a689a6ac4abe27689a2e9de44d16e648d0f91859b391f
BLAKE2b-256 checksum
How to use checksums
7e2125c3e19ce18ded4df558cb3882de848e994c2d99b8fab27916882367fb0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page