capyidx 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. capyidx-0.1.0/LICENSE +21 -0
  2. capyidx-0.1.0/PKG-INFO +163 -0
  3. capyidx-0.1.0/README.md +95 -0
  4. capyidx-0.1.0/pyproject.toml +75 -0
  5. capyidx-0.1.0/setup.cfg +4 -0
  6. capyidx-0.1.0/src/capyidx/__init__.py +62 -0
  7. capyidx-0.1.0/src/capyidx/api.py +397 -0
  8. capyidx-0.1.0/src/capyidx/base/__init__.py +1 -0
  9. capyidx-0.1.0/src/capyidx/base/index_d.py +194 -0
  10. capyidx-0.1.0/src/capyidx/base/index_types.py +85 -0
  11. capyidx-0.1.0/src/capyidx/base/refresh_index.py +472 -0
  12. capyidx-0.1.0/src/capyidx/chunker/__init__.py +1 -0
  13. capyidx-0.1.0/src/capyidx/chunker/basic.py +50 -0
  14. capyidx-0.1.0/src/capyidx/chunker/chunk.py +161 -0
  15. capyidx-0.1.0/src/capyidx/chunker/chunk_codebase_index.py +351 -0
  16. capyidx-0.1.0/src/capyidx/chunker/code.py +715 -0
  17. capyidx-0.1.0/src/capyidx/codesnippet/__init__.py +1 -0
  18. capyidx-0.1.0/src/capyidx/codesnippet/code_snippets_index.py +634 -0
  19. capyidx-0.1.0/src/capyidx/db/__init__.py +1 -0
  20. capyidx-0.1.0/src/capyidx/db/db.py +107 -0
  21. capyidx-0.1.0/src/capyidx/db/paths.py +28 -0
  22. capyidx-0.1.0/src/capyidx/db/schema.py +119 -0
  23. capyidx-0.1.0/src/capyidx/embeddings/__init__.py +1 -0
  24. capyidx-0.1.0/src/capyidx/embeddings/base.py +8 -0
  25. capyidx-0.1.0/src/capyidx/embeddings/local.py +57 -0
  26. capyidx-0.1.0/src/capyidx/embeddings/ollama.py +24 -0
  27. capyidx-0.1.0/src/capyidx/embeddings/openai.py +42 -0
  28. capyidx-0.1.0/src/capyidx/fts/__init__.py +1 -0
  29. capyidx-0.1.0/src/capyidx/fts/fulltextsearch_codebase_index.py +282 -0
  30. capyidx-0.1.0/src/capyidx/indexer/__init__.py +1 -0
  31. capyidx-0.1.0/src/capyidx/indexer/codebase_indexer.py +876 -0
  32. capyidx-0.1.0/src/capyidx/lance_db/__init__.py +1 -0
  33. capyidx-0.1.0/src/capyidx/lance_db/lancedb_index.py +566 -0
  34. capyidx-0.1.0/src/capyidx/retrieval/__init__.py +1 -0
  35. capyidx-0.1.0/src/capyidx/retrieval/models.py +122 -0
  36. capyidx-0.1.0/src/capyidx/retrieval/retrieval_pipeline.py +653 -0
  37. capyidx-0.1.0/src/capyidx/utils/__init__.py +1 -0
  38. capyidx-0.1.0/src/capyidx/utils/chunk_utils.py +32 -0
  39. capyidx-0.1.0/src/capyidx/utils/count_tokens.py +475 -0
  40. capyidx-0.1.0/src/capyidx/utils/disk_operations.py +144 -0
  41. capyidx-0.1.0/src/capyidx/utils/ignore.py +100 -0
  42. capyidx-0.1.0/src/capyidx/utils/parameters.py +28 -0
  43. capyidx-0.1.0/src/capyidx/utils/paths.py +74 -0
  44. capyidx-0.1.0/src/capyidx/utils/retrieval_utils.py +54 -0
  45. capyidx-0.1.0/src/capyidx/utils/tree_sitter.py +324 -0
  46. capyidx-0.1.0/src/capyidx/utils/uri.py +152 -0
  47. capyidx-0.1.0/src/capyidx/utils/uri2.py +215 -0
  48. capyidx-0.1.0/src/capyidx/walker/__init__.py +1 -0
  49. capyidx-0.1.0/src/capyidx/walker/walk_dir.py +359 -0
  50. capyidx-0.1.0/src/capyidx/watcher/__init__.py +1 -0
  51. capyidx-0.1.0/src/capyidx/watcher/file_watcher.py +272 -0
  52. capyidx-0.1.0/src/capyidx.egg-info/PKG-INFO +163 -0
  53. capyidx-0.1.0/src/capyidx.egg-info/SOURCES.txt +57 -0
  54. capyidx-0.1.0/src/capyidx.egg-info/dependency_links.txt +1 -0
  55. capyidx-0.1.0/src/capyidx.egg-info/requires.txt +37 -0
  56. capyidx-0.1.0/src/capyidx.egg-info/top_level.txt +1 -0
  57. capyidx-0.1.0/tests/test_api_smoke.py +83 -0
  58. capyidx-0.1.0/tests/test_package_surface.py +32 -0
  59. capyidx-0.1.0/tests/test_public_api_contract.py +20 -0
capyidx-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Satyam Kumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
capyidx-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: capyidx
3
+ Version: 0.1.0
4
+ Summary: Codebase indexing and deterministic symbol lookup for repositories.
5
+ License: MIT License
6
+
7
+ Copyright (c) 2026 Satyam Kumar
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Classifier: Development Status :: 3 - Alpha
28
+ Classifier: Intended Audience :: Developers
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.10
32
+ Classifier: Programming Language :: Python :: 3.11
33
+ Classifier: Programming Language :: Python :: 3.12
34
+ Requires-Python: >=3.10
35
+ Description-Content-Type: text/markdown
36
+ License-File: LICENSE
37
+ Requires-Dist: pathspec>=0.12
38
+ Requires-Dist: tiktoken>=0.7
39
+ Requires-Dist: tree-sitter>=0.22
40
+ Requires-Dist: tree-sitter-language-pack>=0.7
41
+ Requires-Dist: watchdog>=4.0
42
+ Provides-Extra: test
43
+ Requires-Dist: pytest>=8.0; extra == "test"
44
+ Provides-Extra: openai
45
+ Requires-Dist: openai>=1.0; extra == "openai"
46
+ Provides-Extra: ollama
47
+ Requires-Dist: ollama>=0.3; extra == "ollama"
48
+ Provides-Extra: local-embeddings
49
+ Requires-Dist: sentence-transformers>=3.0; extra == "local-embeddings"
50
+ Provides-Extra: vector
51
+ Requires-Dist: lancedb>=0.15; extra == "vector"
52
+ Provides-Extra: dev
53
+ Requires-Dist: build>=1.2; extra == "dev"
54
+ Requires-Dist: pytest>=8.0; extra == "dev"
55
+ Provides-Extra: all
56
+ Requires-Dist: build>=1.2; extra == "all"
57
+ Requires-Dist: lancedb>=0.15; extra == "all"
58
+ Requires-Dist: ollama>=0.3; extra == "all"
59
+ Requires-Dist: openai>=1.0; extra == "all"
60
+ Requires-Dist: pathspec>=0.12; extra == "all"
61
+ Requires-Dist: pytest>=8.0; extra == "all"
62
+ Requires-Dist: sentence-transformers>=3.0; extra == "all"
63
+ Requires-Dist: tiktoken>=0.7; extra == "all"
64
+ Requires-Dist: tree-sitter>=0.22; extra == "all"
65
+ Requires-Dist: tree-sitter-language-pack>=0.7; extra == "all"
66
+ Requires-Dist: watchdog>=4.0; extra == "all"
67
+ Dynamic: license-file
68
+
69
+ # CapyIdx
70
+
71
+ CapyIdx indexes source repositories into SQLite and provides deterministic
72
+ symbol lookup and code reconstruction. It is designed to be embedded in tools
73
+ that need repository-aware code context.
74
+
75
+ ## Installation
76
+
77
+ ```bash
78
+ python -m pip install capyidx
79
+ ```
80
+
81
+ For development:
82
+
83
+ ```bash
84
+ python -m pip install -e ".[dev]"
85
+ ```
86
+
87
+ The core package uses Tree-sitter for source parsing and `tiktoken` for chunk
88
+ size calculations. Optional integrations can be installed with extras:
89
+
90
+ ```bash
91
+ python -m pip install "capyidx[openai]"
92
+ python -m pip install "capyidx[ollama]"
93
+ python -m pip install "capyidx[local-embeddings]"
94
+ python -m pip install "capyidx[vector]"
95
+ ```
96
+
97
+ ## Basic usage
98
+
99
+ Indexing is asynchronous. The convenience API waits for the initial pass to
100
+ finish:
101
+
102
+ ```python
103
+ import asyncio
104
+ from capyidx import index_repo, lookup_symbol
105
+
106
+
107
+ async def main() -> None:
108
+ repo = "/path/to/git/repository"
109
+ await index_repo(repo)
110
+
111
+ result = await lookup_symbol(repo, "MyClass", detail="body")
112
+ for match in result.matches:
113
+ print(match.name, match.path, match.start_line, match.end_line)
114
+
115
+ if result.selected is not None:
116
+ print(result.selected.code)
117
+
118
+
119
+ asyncio.run(main())
120
+ ```
121
+
122
+ Use `index_repo_iter` when progress updates are needed:
123
+
124
+ ```python
125
+ from capyidx import index_repo_iter
126
+
127
+ async for update in index_repo_iter("/path/to/git/repository"):
128
+ print(update.status, update.progress, update.desc)
129
+ ```
130
+
131
+ Pass `watch=True` to continue indexing changed files after the initial pass.
132
+ The watcher uses `watchdog` when installed and otherwise falls back to polling.
133
+
134
+ ## Query workflows
135
+
136
+ - `lookup_symbol` returns matching symbol metadata and reconstructs a unique
137
+ exact match.
138
+ - `reconstruct_symbol` reconstructs a previously selected symbol by ID.
139
+ - `resolve_lookup` reconstructs every match for a name.
140
+ - `open_lookup` reuses one database connection for multiple queries.
141
+
142
+ Use `detail="signature"` for declaration-only results, and use
143
+ `filter_paths` to restrict lookup to selected path prefixes.
144
+
145
+ ## Current scope
146
+
147
+ The public convenience API currently builds the chunk/symbol index and exposes
148
+ deterministic symbol retrieval. FTS, code-snippet, embedding, and LanceDB
149
+ backends are present as lower-level components but are not automatically wired
150
+ into `index_repo` yet.
151
+
152
+ Indexes are stored under `~/.coreIndexer/.codebase_index` by default. Set
153
+ `COREINDEXER_HOME` to use a different data directory.
154
+
155
+ ## Development checks
156
+
157
+ ```bash
158
+ python -m compileall -q src tests
159
+ pytest
160
+ python -m build
161
+ ```
162
+
163
+ The repository's CI runs these checks on Python 3.10, 3.11, and 3.12.
@@ -0,0 +1,95 @@
1
+ # CapyIdx
2
+
3
+ CapyIdx indexes source repositories into SQLite and provides deterministic
4
+ symbol lookup and code reconstruction. It is designed to be embedded in tools
5
+ that need repository-aware code context.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ python -m pip install capyidx
11
+ ```
12
+
13
+ For development:
14
+
15
+ ```bash
16
+ python -m pip install -e ".[dev]"
17
+ ```
18
+
19
+ The core package uses Tree-sitter for source parsing and `tiktoken` for chunk
20
+ size calculations. Optional integrations can be installed with extras:
21
+
22
+ ```bash
23
+ python -m pip install "capyidx[openai]"
24
+ python -m pip install "capyidx[ollama]"
25
+ python -m pip install "capyidx[local-embeddings]"
26
+ python -m pip install "capyidx[vector]"
27
+ ```
28
+
29
+ ## Basic usage
30
+
31
+ Indexing is asynchronous. The convenience API waits for the initial pass to
32
+ finish:
33
+
34
+ ```python
35
+ import asyncio
36
+ from capyidx import index_repo, lookup_symbol
37
+
38
+
39
+ async def main() -> None:
40
+ repo = "/path/to/git/repository"
41
+ await index_repo(repo)
42
+
43
+ result = await lookup_symbol(repo, "MyClass", detail="body")
44
+ for match in result.matches:
45
+ print(match.name, match.path, match.start_line, match.end_line)
46
+
47
+ if result.selected is not None:
48
+ print(result.selected.code)
49
+
50
+
51
+ asyncio.run(main())
52
+ ```
53
+
54
+ Use `index_repo_iter` when progress updates are needed:
55
+
56
+ ```python
57
+ from capyidx import index_repo_iter
58
+
59
+ async for update in index_repo_iter("/path/to/git/repository"):
60
+ print(update.status, update.progress, update.desc)
61
+ ```
62
+
63
+ Pass `watch=True` to continue indexing changed files after the initial pass.
64
+ The watcher uses `watchdog` when installed and otherwise falls back to polling.
65
+
66
+ ## Query workflows
67
+
68
+ - `lookup_symbol` returns matching symbol metadata and reconstructs a unique
69
+ exact match.
70
+ - `reconstruct_symbol` reconstructs a previously selected symbol by ID.
71
+ - `resolve_lookup` reconstructs every match for a name.
72
+ - `open_lookup` reuses one database connection for multiple queries.
73
+
74
+ Use `detail="signature"` for declaration-only results, and use
75
+ `filter_paths` to restrict lookup to selected path prefixes.
76
+
77
+ ## Current scope
78
+
79
+ The public convenience API currently builds the chunk/symbol index and exposes
80
+ deterministic symbol retrieval. FTS, code-snippet, embedding, and LanceDB
81
+ backends are present as lower-level components but are not automatically wired
82
+ into `index_repo` yet.
83
+
84
+ Indexes are stored under `~/.coreIndexer/.codebase_index` by default. Set
85
+ `COREINDEXER_HOME` to use a different data directory.
86
+
87
+ ## Development checks
88
+
89
+ ```bash
90
+ python -m compileall -q src tests
91
+ pytest
92
+ python -m build
93
+ ```
94
+
95
+ The repository's CI runs these checks on Python 3.10, 3.11, and 3.12.
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "capyidx"
7
+ version = "0.1.0"
8
+ description = "Codebase indexing and deterministic symbol lookup for repositories."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ ]
21
+ dependencies = [
22
+ "pathspec>=0.12",
23
+ "tiktoken>=0.7",
24
+ "tree-sitter>=0.22",
25
+ "tree-sitter-language-pack>=0.7",
26
+ "watchdog>=4.0",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ test = [
31
+ "pytest>=8.0",
32
+ ]
33
+ openai = [
34
+ "openai>=1.0",
35
+ ]
36
+ ollama = [
37
+ "ollama>=0.3",
38
+ ]
39
+ local-embeddings = [
40
+ "sentence-transformers>=3.0",
41
+ ]
42
+ vector = [
43
+ "lancedb>=0.15",
44
+ ]
45
+ dev = [
46
+ "build>=1.2",
47
+ "pytest>=8.0",
48
+ ]
49
+ all = [
50
+ "build>=1.2",
51
+ "lancedb>=0.15",
52
+ "ollama>=0.3",
53
+ "openai>=1.0",
54
+ "pathspec>=0.12",
55
+ "pytest>=8.0",
56
+ "sentence-transformers>=3.0",
57
+ "tiktoken>=0.7",
58
+ "tree-sitter>=0.22",
59
+ "tree-sitter-language-pack>=0.7",
60
+ "watchdog>=4.0",
61
+ ]
62
+
63
+ [tool.setuptools]
64
+ include-package-data = true
65
+
66
+ [tool.setuptools.packages.find]
67
+ where = ["src"]
68
+
69
+ [tool.setuptools.package-data]
70
+ coreindexer = ["utils/tree_sitter_queries/*.scm"]
71
+
72
+ [tool.pytest.ini_options]
73
+ testpaths = ["tests"]
74
+ addopts = "-ra"
75
+ # anyio = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ """
2
+ CoreIndexer — index a codebase, look up symbols by name.
3
+
4
+ The public surface is re-exported here so consumers can write::
5
+
6
+ from coreindexer import index_repo, lookup_symbol, resolve_lookup
7
+
8
+ rather than reaching into submodules. Everything documented in
9
+ :mod:`coreindexer.api` is available from the package root.
10
+ """
11
+ from __future__ import annotations
12
+
13
+
14
+ from capyidx.api import (
15
+ index_repo,
16
+ index_repo_iter,
17
+ lookup_symbol,
18
+ open_lookup,
19
+ resolve_lookup,
20
+ reconstruct_symbol,
21
+ PathLike,
22
+ ResolvedLookup,
23
+ )
24
+ from capyidx.base.index_d import (
25
+ Chunk,
26
+ Chonk,
27
+ ChunkingResult,
28
+ Symbol,
29
+ BranchAndDir
30
+ )
31
+ from capyidx.retrieval.models import (
32
+ LookupResult,
33
+ SymbolCode,
34
+ SymbolMatch,
35
+ )
36
+
37
+ __version__ = "0.1.0"
38
+
39
+ __all__ = [
40
+ # Types
41
+ "PathLike",
42
+ "__version__",
43
+ # Indexing
44
+ "index_repo",
45
+ "index_repo_iter",
46
+ # Querying
47
+ "open_lookup",
48
+ "lookup_symbol",
49
+ "resolve_lookup",
50
+ "reconstruct_symbol",
51
+ "ResolvedLookup",
52
+ # Result types
53
+ "LookupResult",
54
+ "SymbolCode",
55
+ "SymbolMatch",
56
+ # Core data types
57
+ "Chunk",
58
+ "Chonk",
59
+ "ChunkingResult",
60
+ "Symbol",
61
+ "BranchAndDir"
62
+ ]