Metadata-Version: 2.4
Name: capyidx
Version: 0.1.1
Summary: Codebase indexing with incremental re-indexing and deterministic symbol lookup for repositories.
License: MIT License
        
        Copyright (c) 2026 Satyam Kumar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/satkr22/CapyIdx
Project-URL: Repository, https://github.com/satkr22/CapyIdx
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pathspec>=0.12
Requires-Dist: tiktoken>=0.7
Requires-Dist: tree-sitter>=0.22
Requires-Dist: tree-sitter-language-pack>=0.7
Requires-Dist: watchdog>=4.0
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: ollama
Requires-Dist: ollama>=0.3; extra == "ollama"
Provides-Extra: local-embeddings
Requires-Dist: sentence-transformers>=3.0; extra == "local-embeddings"
Provides-Extra: vector
Requires-Dist: lancedb>=0.15; extra == "vector"
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Provides-Extra: all
Requires-Dist: build>=1.2; extra == "all"
Requires-Dist: lancedb>=0.15; extra == "all"
Requires-Dist: ollama>=0.3; extra == "all"
Requires-Dist: openai>=1.0; extra == "all"
Requires-Dist: pathspec>=0.12; extra == "all"
Requires-Dist: pytest>=8.0; extra == "all"
Requires-Dist: sentence-transformers>=3.0; extra == "all"
Requires-Dist: tiktoken>=0.7; extra == "all"
Requires-Dist: tree-sitter>=0.22; extra == "all"
Requires-Dist: tree-sitter-language-pack>=0.7; extra == "all"
Requires-Dist: watchdog>=4.0; extra == "all"
Dynamic: license-file

# 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

```bash
python -m pip install capyidx
```

For development:

```bash
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:

```bash
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:

```python
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:

```python
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

```bash
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.
