smritikosh 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.
- smritikosh-0.1.0/LICENSE +201 -0
- smritikosh-0.1.0/PKG-INFO +242 -0
- smritikosh-0.1.0/README.md +207 -0
- smritikosh-0.1.0/pyproject.toml +123 -0
- smritikosh-0.1.0/setup.cfg +4 -0
- smritikosh-0.1.0/smritikosh/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/adapters/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/adapters/embedder/__init__.py +46 -0
- smritikosh-0.1.0/smritikosh/adapters/embedder/fastembed.py +149 -0
- smritikosh-0.1.0/smritikosh/adapters/file_source/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/adapters/file_source/local.py +46 -0
- smritikosh-0.1.0/smritikosh/adapters/storage/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/adapters/storage/duckdb.py +200 -0
- smritikosh-0.1.0/smritikosh/adapters/vector_store/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/adapters/vector_store/duckdb.py +119 -0
- smritikosh-0.1.0/smritikosh/cli.py +224 -0
- smritikosh-0.1.0/smritikosh/constants.py +19 -0
- smritikosh-0.1.0/smritikosh/engine/__init__.py +50 -0
- smritikosh-0.1.0/smritikosh/engine/_batch.py +217 -0
- smritikosh-0.1.0/smritikosh/engine/_context.py +148 -0
- smritikosh-0.1.0/smritikosh/engine/_decorators.py +116 -0
- smritikosh-0.1.0/smritikosh/engine/_engine.py +124 -0
- smritikosh-0.1.0/smritikosh/engine/_fingerprint.py +64 -0
- smritikosh-0.1.0/smritikosh/engine/_memo.py +122 -0
- smritikosh-0.1.0/smritikosh/exploration.py +616 -0
- smritikosh-0.1.0/smritikosh/exploration_cli.py +465 -0
- smritikosh-0.1.0/smritikosh/indexing/__init__.py +3 -0
- smritikosh-0.1.0/smritikosh/indexing/chunker.py +14 -0
- smritikosh-0.1.0/smritikosh/indexing/discovery.py +63 -0
- smritikosh-0.1.0/smritikosh/indexing/extractor.py +53 -0
- smritikosh-0.1.0/smritikosh/indexing/file_router.py +124 -0
- smritikosh-0.1.0/smritikosh/indexing/parser.py +48 -0
- smritikosh-0.1.0/smritikosh/indexing/pipeline/__init__.py +41 -0
- smritikosh-0.1.0/smritikosh/indexing/pipeline/_pipeline.py +216 -0
- smritikosh-0.1.0/smritikosh/indexing/pipeline/_router.py +44 -0
- smritikosh-0.1.0/smritikosh/indexing/pipeline/_stages.py +40 -0
- smritikosh-0.1.0/smritikosh/indexing/strategies/__init__.py +25 -0
- smritikosh-0.1.0/smritikosh/indexing/strategies/_helpers.py +250 -0
- smritikosh-0.1.0/smritikosh/indexing/strategies/ast.py +173 -0
- smritikosh-0.1.0/smritikosh/indexing/strategies/regex.py +64 -0
- smritikosh-0.1.0/smritikosh/indexing/strategies/section.py +243 -0
- smritikosh-0.1.0/smritikosh/indexing/vector_index.py +67 -0
- smritikosh-0.1.0/smritikosh/models/__init__.py +21 -0
- smritikosh-0.1.0/smritikosh/models/types.py +110 -0
- smritikosh-0.1.0/smritikosh/ports/__init__.py +0 -0
- smritikosh-0.1.0/smritikosh/ports/embedder.py +56 -0
- smritikosh-0.1.0/smritikosh/ports/file_source.py +28 -0
- smritikosh-0.1.0/smritikosh/ports/storage.py +57 -0
- smritikosh-0.1.0/smritikosh/ports/vector_store.py +32 -0
- smritikosh-0.1.0/smritikosh/queries/__init__.py +5 -0
- smritikosh-0.1.0/smritikosh/queries/java/tags.scm +53 -0
- smritikosh-0.1.0/smritikosh/queries/javascript/tags.scm +78 -0
- smritikosh-0.1.0/smritikosh/queries/json/tags.scm +47 -0
- smritikosh-0.1.0/smritikosh/queries/kotlin/tags.scm +75 -0
- smritikosh-0.1.0/smritikosh/queries/markdown/tags.scm +35 -0
- smritikosh-0.1.0/smritikosh/queries/python/tags.scm +105 -0
- smritikosh-0.1.0/smritikosh/queries/typescript/tags.scm +88 -0
- smritikosh-0.1.0/smritikosh.egg-info/PKG-INFO +242 -0
- smritikosh-0.1.0/smritikosh.egg-info/SOURCES.txt +65 -0
- smritikosh-0.1.0/smritikosh.egg-info/dependency_links.txt +1 -0
- smritikosh-0.1.0/smritikosh.egg-info/entry_points.txt +2 -0
- smritikosh-0.1.0/smritikosh.egg-info/requires.txt +9 -0
- smritikosh-0.1.0/smritikosh.egg-info/top_level.txt +1 -0
- smritikosh-0.1.0/tests/test_cli.py +374 -0
- smritikosh-0.1.0/tests/test_end_to_end.py +156 -0
- smritikosh-0.1.0/tests/test_exploration.py +517 -0
- smritikosh-0.1.0/tests/test_exploration_cli.py +406 -0
smritikosh-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smritikosh
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Semantic vector search over a codebase
|
|
5
|
+
Author-email: Shantanu Vashishtha <vashishthashantanu3@gmail.com>, Sarvesh Sawant <sarveshdev92@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/learncoder4848/smritikosh
|
|
8
|
+
Project-URL: Repository, https://github.com/learncoder4848/smritikosh
|
|
9
|
+
Project-URL: Issues, https://github.com/learncoder4848/smritikosh/issues
|
|
10
|
+
Keywords: code-search,semantic-search,embeddings,tree-sitter,duckdb,vector-search,rag
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
21
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
+
Requires-Python: <3.14,>=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: click>=8.1
|
|
26
|
+
Requires-Dist: duckdb>=1.0
|
|
27
|
+
Requires-Dist: pathspec>=1.0
|
|
28
|
+
Requires-Dist: fastembed>=0.3
|
|
29
|
+
Requires-Dist: tree-sitter>=0.25
|
|
30
|
+
Requires-Dist: tree-sitter-language-pack<1.0,>=0.13
|
|
31
|
+
Requires-Dist: truststore>=0.9
|
|
32
|
+
Requires-Dist: watchfiles>=0.21
|
|
33
|
+
Requires-Dist: toons>=0.7
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# smritikosh
|
|
37
|
+
|
|
38
|
+
Semantic vector search over source-code repositories. Smritikosh parses source
|
|
39
|
+
files with tree-sitter, identifies meaningful definitions, turns them into
|
|
40
|
+
chunks, embeds those chunks, and stores the vectors in DuckDB.
|
|
41
|
+
|
|
42
|
+
## Pipeline
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
FileSource FileRouter
|
|
46
|
+
(lists + reads) (extension -> language + strategy)
|
|
47
|
+
| |
|
|
48
|
+
+--------> discovery <+ select once, per file
|
|
49
|
+
|
|
|
50
|
+
| 3 gates: excluded dirs -> gitignore -> router
|
|
51
|
+
v
|
|
52
|
+
SourceFile path, language, content,
|
|
53
|
+
| has_tags_scm, strategy
|
|
54
|
+
v
|
|
55
|
+
[ file unchanged? ] --yes--> skip file file_hashes
|
|
56
|
+
| no
|
|
57
|
+
v
|
|
58
|
+
parser text -> tree-sitter AST
|
|
59
|
+
v
|
|
60
|
+
extractor AST -> definition captures (tags.scm)
|
|
61
|
+
v
|
|
62
|
+
chunker captures -> chunks (ast|section|regex)
|
|
63
|
+
v
|
|
64
|
+
[ chunk text seen? ] --yes--> reuse vector content_hash
|
|
65
|
+
| no
|
|
66
|
+
v
|
|
67
|
+
embedder chunk text -> vector
|
|
68
|
+
v
|
|
69
|
+
DuckDB nodes, vectors, file_hashes, memo_cache
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Routing happens once, in discovery, and is carried on the `SourceFile`. Later
|
|
73
|
+
stages read `language`, `has_tags_scm`, and `strategy` off that object rather
|
|
74
|
+
than re-deriving them from the path.
|
|
75
|
+
|
|
76
|
+
Two skip checks make re-indexing cheap. A file whose SHA-256 is unchanged is
|
|
77
|
+
skipped whole. A chunk is keyed by the hash of its own text, so editing one
|
|
78
|
+
function in a file re-embeds only that function's chunk.
|
|
79
|
+
|
|
80
|
+
The extractor uses packaged `tags.scm` queries for Python, Java, Kotlin,
|
|
81
|
+
TypeScript, JavaScript, Markdown, and JSON. TOML bypasses extraction and uses
|
|
82
|
+
regex chunking. JSON is indexed except for known noise — lockfiles, minified
|
|
83
|
+
bundles, and fixture directories.
|
|
84
|
+
|
|
85
|
+
## Package structure
|
|
86
|
+
|
|
87
|
+
- [`smritikosh/indexing`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/indexing)
|
|
88
|
+
— file router, discovery, parser, extractor, chunker, and pipeline
|
|
89
|
+
orchestration.
|
|
90
|
+
- [`smritikosh/engine`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/engine)
|
|
91
|
+
— memoization, tracking, batching, and concurrent pipeline helpers.
|
|
92
|
+
- [`smritikosh/ports`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/ports)
|
|
93
|
+
— file-source, storage, vector-store, and embedder contracts.
|
|
94
|
+
- [`smritikosh/adapters`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/adapters)
|
|
95
|
+
— local-filesystem, DuckDB, and sentence-transformer implementations of those
|
|
96
|
+
contracts.
|
|
97
|
+
- [`smritikosh/queries`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/queries)
|
|
98
|
+
— packaged tree-sitter tag queries.
|
|
99
|
+
|
|
100
|
+
The extractor stays under `indexing`: it transforms internal pipeline data
|
|
101
|
+
(`ParsedFile -> list[Capture]`) rather than adapting an external system.
|
|
102
|
+
|
|
103
|
+
## Installation
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install smritikosh
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Or with uv, to get the CLI on your PATH without managing a virtualenv:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
uv tool install smritikosh
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Development setup
|
|
116
|
+
|
|
117
|
+
Both **uv** and **Poetry** are supported. uv is recommended for local development
|
|
118
|
+
— it resolves and installs the full dependency tree roughly 5× faster than
|
|
119
|
+
Poetry, thanks to a Rust-based resolver and parallel downloads. (Measured on
|
|
120
|
+
this project: uv locked 94 packages in ~46 s vs Poetry's ~3.5 min.)
|
|
121
|
+
|
|
122
|
+
### uv (recommended)
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Install uv: https://docs.astral.sh/uv/getting-started/installation/
|
|
126
|
+
uv sync # install deps + project into .venv
|
|
127
|
+
uv sync --no-install-project # deps only (skip the editable install)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Poetry
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Requires Poetry >= 2.3
|
|
134
|
+
poetry install # install deps + project into .venv
|
|
135
|
+
poetry install --no-root # deps only
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Running tests
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# uv
|
|
142
|
+
uv run pytest
|
|
143
|
+
|
|
144
|
+
# Poetry / activated venv
|
|
145
|
+
make test
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Both tools create a `.venv` in the project root and share the same `Makefile`
|
|
149
|
+
targets. Pass `TOOL=uv` or `TOOL=poetry` to override the default:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
make install TOOL=uv
|
|
153
|
+
make lock TOOL=uv # regenerates uv.lock
|
|
154
|
+
make test # always uses .venv/bin/python directly
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Lock files are not committed. Smritikosh is a library, so installs resolve from
|
|
158
|
+
the version ranges in `pyproject.toml`; `uv.lock` and `poetry.lock` are local
|
|
159
|
+
artifacts that each tool regenerates on demand.
|
|
160
|
+
|
|
161
|
+
## Read-only exploration CLI
|
|
162
|
+
|
|
163
|
+
The `explore` commands expose the indexed repository to agents without reading
|
|
164
|
+
the source tree or taking a DuckDB write lock:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
smritikosh explore tools
|
|
168
|
+
|
|
169
|
+
smritikosh explore info --db-path smritikosh.duckdb
|
|
170
|
+
|
|
171
|
+
smritikosh explore search \
|
|
172
|
+
"where is access control enforced" \
|
|
173
|
+
"authorization decision logic" \
|
|
174
|
+
--exclude-path 'tests/%' \
|
|
175
|
+
--db-path smritikosh.duckdb
|
|
176
|
+
|
|
177
|
+
smritikosh explore paths permissions \
|
|
178
|
+
--db-path smritikosh.duckdb
|
|
179
|
+
|
|
180
|
+
smritikosh explore chunks src/auth/permissions.py \
|
|
181
|
+
--db-path smritikosh.duckdb
|
|
182
|
+
|
|
183
|
+
smritikosh explore chunks src/auth/permissions.py \
|
|
184
|
+
--start-line 40 --end-line 52 \
|
|
185
|
+
--db-path smritikosh.duckdb
|
|
186
|
+
|
|
187
|
+
smritikosh explore text is_allowed \
|
|
188
|
+
--path src/auth/permissions.py \
|
|
189
|
+
--db-path smritikosh.duckdb
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The two calls that answer most questions are `search`, which reports where the
|
|
193
|
+
answer lives, and `chunks PATH --start-line N --end-line M`, which prints that
|
|
194
|
+
source with line numbers. Without a line range `chunks` outlines what a file
|
|
195
|
+
defines rather than printing it; `--full` restores the whole-chunk dump, on
|
|
196
|
+
both commands.
|
|
197
|
+
|
|
198
|
+
Results come back as [TOON](https://toonformat.dev) — a tabular array that
|
|
199
|
+
declares its columns once and then streams one row per hit:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
[2]{path,start_line,end_line,score,chunk_kind,symbol}:
|
|
203
|
+
src/auth/permissions.py,59,81,0.434,class,PermissionChecker
|
|
204
|
+
src/auth/policy.py,176,193,0.436,method,evaluate
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
That costs roughly half of the equivalent JSON. `--prose` switches any command
|
|
208
|
+
to human-readable output. Source lines are exempt: TOON must quote any value
|
|
209
|
+
containing a colon, so a table of code lines costs more than the numbered text
|
|
210
|
+
it would replace, and `chunks` with a line range always prints numbered text.
|
|
211
|
+
|
|
212
|
+
Multiple semantic queries are embedded in one model call. Results are
|
|
213
|
+
deduplicated and ranked by each chunk's best score across those queries; a hit
|
|
214
|
+
that mostly repeats the lines of a better-scoring one is dropped. Path, text,
|
|
215
|
+
and chunk commands do not load the embedding model.
|
|
216
|
+
|
|
217
|
+
`explore tools` returns a machine-readable command manifest and recommended
|
|
218
|
+
workflow. An agent instruction can therefore stay short:
|
|
219
|
+
|
|
220
|
+
```text
|
|
221
|
+
Use the Smritikosh exploration CLI instead of Grep for code discovery.
|
|
222
|
+
Run `uv run smritikosh explore tools` to discover its commands.
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Contributing
|
|
226
|
+
|
|
227
|
+
See [CONTRIBUTING.md](https://github.com/learncoder4848/smritikosh/blob/main/CONTRIBUTING.md)
|
|
228
|
+
for commit and PR conventions.
|
|
229
|
+
|
|
230
|
+
## Credits
|
|
231
|
+
|
|
232
|
+
Built by [Shantanu Vashishtha](https://github.com/learncoder4848) and
|
|
233
|
+
[Sarvesh Sawant](https://github.com/devsarvesh92).
|
|
234
|
+
|
|
235
|
+
## Status
|
|
236
|
+
|
|
237
|
+
Alpha. The pipeline runs end to end — `index` builds an index, `search` and
|
|
238
|
+
`explore` query it, and re-indexing is incremental at both the file and the
|
|
239
|
+
chunk level. Embedding runs locally on CPU through ONNX Runtime, so the only
|
|
240
|
+
network access is a one-time model download.
|
|
241
|
+
|
|
242
|
+
The CLI surface may still change before 1.0.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# smritikosh
|
|
2
|
+
|
|
3
|
+
Semantic vector search over source-code repositories. Smritikosh parses source
|
|
4
|
+
files with tree-sitter, identifies meaningful definitions, turns them into
|
|
5
|
+
chunks, embeds those chunks, and stores the vectors in DuckDB.
|
|
6
|
+
|
|
7
|
+
## Pipeline
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
FileSource FileRouter
|
|
11
|
+
(lists + reads) (extension -> language + strategy)
|
|
12
|
+
| |
|
|
13
|
+
+--------> discovery <+ select once, per file
|
|
14
|
+
|
|
|
15
|
+
| 3 gates: excluded dirs -> gitignore -> router
|
|
16
|
+
v
|
|
17
|
+
SourceFile path, language, content,
|
|
18
|
+
| has_tags_scm, strategy
|
|
19
|
+
v
|
|
20
|
+
[ file unchanged? ] --yes--> skip file file_hashes
|
|
21
|
+
| no
|
|
22
|
+
v
|
|
23
|
+
parser text -> tree-sitter AST
|
|
24
|
+
v
|
|
25
|
+
extractor AST -> definition captures (tags.scm)
|
|
26
|
+
v
|
|
27
|
+
chunker captures -> chunks (ast|section|regex)
|
|
28
|
+
v
|
|
29
|
+
[ chunk text seen? ] --yes--> reuse vector content_hash
|
|
30
|
+
| no
|
|
31
|
+
v
|
|
32
|
+
embedder chunk text -> vector
|
|
33
|
+
v
|
|
34
|
+
DuckDB nodes, vectors, file_hashes, memo_cache
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Routing happens once, in discovery, and is carried on the `SourceFile`. Later
|
|
38
|
+
stages read `language`, `has_tags_scm`, and `strategy` off that object rather
|
|
39
|
+
than re-deriving them from the path.
|
|
40
|
+
|
|
41
|
+
Two skip checks make re-indexing cheap. A file whose SHA-256 is unchanged is
|
|
42
|
+
skipped whole. A chunk is keyed by the hash of its own text, so editing one
|
|
43
|
+
function in a file re-embeds only that function's chunk.
|
|
44
|
+
|
|
45
|
+
The extractor uses packaged `tags.scm` queries for Python, Java, Kotlin,
|
|
46
|
+
TypeScript, JavaScript, Markdown, and JSON. TOML bypasses extraction and uses
|
|
47
|
+
regex chunking. JSON is indexed except for known noise — lockfiles, minified
|
|
48
|
+
bundles, and fixture directories.
|
|
49
|
+
|
|
50
|
+
## Package structure
|
|
51
|
+
|
|
52
|
+
- [`smritikosh/indexing`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/indexing)
|
|
53
|
+
— file router, discovery, parser, extractor, chunker, and pipeline
|
|
54
|
+
orchestration.
|
|
55
|
+
- [`smritikosh/engine`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/engine)
|
|
56
|
+
— memoization, tracking, batching, and concurrent pipeline helpers.
|
|
57
|
+
- [`smritikosh/ports`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/ports)
|
|
58
|
+
— file-source, storage, vector-store, and embedder contracts.
|
|
59
|
+
- [`smritikosh/adapters`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/adapters)
|
|
60
|
+
— local-filesystem, DuckDB, and sentence-transformer implementations of those
|
|
61
|
+
contracts.
|
|
62
|
+
- [`smritikosh/queries`](https://github.com/learncoder4848/smritikosh/tree/main/smritikosh/queries)
|
|
63
|
+
— packaged tree-sitter tag queries.
|
|
64
|
+
|
|
65
|
+
The extractor stays under `indexing`: it transforms internal pipeline data
|
|
66
|
+
(`ParsedFile -> list[Capture]`) rather than adapting an external system.
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install smritikosh
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or with uv, to get the CLI on your PATH without managing a virtualenv:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv tool install smritikosh
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development setup
|
|
81
|
+
|
|
82
|
+
Both **uv** and **Poetry** are supported. uv is recommended for local development
|
|
83
|
+
— it resolves and installs the full dependency tree roughly 5× faster than
|
|
84
|
+
Poetry, thanks to a Rust-based resolver and parallel downloads. (Measured on
|
|
85
|
+
this project: uv locked 94 packages in ~46 s vs Poetry's ~3.5 min.)
|
|
86
|
+
|
|
87
|
+
### uv (recommended)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Install uv: https://docs.astral.sh/uv/getting-started/installation/
|
|
91
|
+
uv sync # install deps + project into .venv
|
|
92
|
+
uv sync --no-install-project # deps only (skip the editable install)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Poetry
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Requires Poetry >= 2.3
|
|
99
|
+
poetry install # install deps + project into .venv
|
|
100
|
+
poetry install --no-root # deps only
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Running tests
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# uv
|
|
107
|
+
uv run pytest
|
|
108
|
+
|
|
109
|
+
# Poetry / activated venv
|
|
110
|
+
make test
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Both tools create a `.venv` in the project root and share the same `Makefile`
|
|
114
|
+
targets. Pass `TOOL=uv` or `TOOL=poetry` to override the default:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
make install TOOL=uv
|
|
118
|
+
make lock TOOL=uv # regenerates uv.lock
|
|
119
|
+
make test # always uses .venv/bin/python directly
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Lock files are not committed. Smritikosh is a library, so installs resolve from
|
|
123
|
+
the version ranges in `pyproject.toml`; `uv.lock` and `poetry.lock` are local
|
|
124
|
+
artifacts that each tool regenerates on demand.
|
|
125
|
+
|
|
126
|
+
## Read-only exploration CLI
|
|
127
|
+
|
|
128
|
+
The `explore` commands expose the indexed repository to agents without reading
|
|
129
|
+
the source tree or taking a DuckDB write lock:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
smritikosh explore tools
|
|
133
|
+
|
|
134
|
+
smritikosh explore info --db-path smritikosh.duckdb
|
|
135
|
+
|
|
136
|
+
smritikosh explore search \
|
|
137
|
+
"where is access control enforced" \
|
|
138
|
+
"authorization decision logic" \
|
|
139
|
+
--exclude-path 'tests/%' \
|
|
140
|
+
--db-path smritikosh.duckdb
|
|
141
|
+
|
|
142
|
+
smritikosh explore paths permissions \
|
|
143
|
+
--db-path smritikosh.duckdb
|
|
144
|
+
|
|
145
|
+
smritikosh explore chunks src/auth/permissions.py \
|
|
146
|
+
--db-path smritikosh.duckdb
|
|
147
|
+
|
|
148
|
+
smritikosh explore chunks src/auth/permissions.py \
|
|
149
|
+
--start-line 40 --end-line 52 \
|
|
150
|
+
--db-path smritikosh.duckdb
|
|
151
|
+
|
|
152
|
+
smritikosh explore text is_allowed \
|
|
153
|
+
--path src/auth/permissions.py \
|
|
154
|
+
--db-path smritikosh.duckdb
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The two calls that answer most questions are `search`, which reports where the
|
|
158
|
+
answer lives, and `chunks PATH --start-line N --end-line M`, which prints that
|
|
159
|
+
source with line numbers. Without a line range `chunks` outlines what a file
|
|
160
|
+
defines rather than printing it; `--full` restores the whole-chunk dump, on
|
|
161
|
+
both commands.
|
|
162
|
+
|
|
163
|
+
Results come back as [TOON](https://toonformat.dev) — a tabular array that
|
|
164
|
+
declares its columns once and then streams one row per hit:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
[2]{path,start_line,end_line,score,chunk_kind,symbol}:
|
|
168
|
+
src/auth/permissions.py,59,81,0.434,class,PermissionChecker
|
|
169
|
+
src/auth/policy.py,176,193,0.436,method,evaluate
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
That costs roughly half of the equivalent JSON. `--prose` switches any command
|
|
173
|
+
to human-readable output. Source lines are exempt: TOON must quote any value
|
|
174
|
+
containing a colon, so a table of code lines costs more than the numbered text
|
|
175
|
+
it would replace, and `chunks` with a line range always prints numbered text.
|
|
176
|
+
|
|
177
|
+
Multiple semantic queries are embedded in one model call. Results are
|
|
178
|
+
deduplicated and ranked by each chunk's best score across those queries; a hit
|
|
179
|
+
that mostly repeats the lines of a better-scoring one is dropped. Path, text,
|
|
180
|
+
and chunk commands do not load the embedding model.
|
|
181
|
+
|
|
182
|
+
`explore tools` returns a machine-readable command manifest and recommended
|
|
183
|
+
workflow. An agent instruction can therefore stay short:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
Use the Smritikosh exploration CLI instead of Grep for code discovery.
|
|
187
|
+
Run `uv run smritikosh explore tools` to discover its commands.
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Contributing
|
|
191
|
+
|
|
192
|
+
See [CONTRIBUTING.md](https://github.com/learncoder4848/smritikosh/blob/main/CONTRIBUTING.md)
|
|
193
|
+
for commit and PR conventions.
|
|
194
|
+
|
|
195
|
+
## Credits
|
|
196
|
+
|
|
197
|
+
Built by [Shantanu Vashishtha](https://github.com/learncoder4848) and
|
|
198
|
+
[Sarvesh Sawant](https://github.com/devsarvesh92).
|
|
199
|
+
|
|
200
|
+
## Status
|
|
201
|
+
|
|
202
|
+
Alpha. The pipeline runs end to end — `index` builds an index, `search` and
|
|
203
|
+
`explore` query it, and re-indexing is incremental at both the file and the
|
|
204
|
+
chunk level. Embedding runs locally on CPU through ONNX Runtime, so the only
|
|
205
|
+
network access is a one-time model download.
|
|
206
|
+
|
|
207
|
+
The CLI surface may still change before 1.0.
|