@zvec/zvec-grep 0.1.0

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 (201) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +222 -0
  3. package/README_CN.md +222 -0
  4. package/dist/cli/args.d.ts +2 -0
  5. package/dist/cli/args.js +611 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/commands.d.ts +2 -0
  8. package/dist/cli/commands.js +270 -0
  9. package/dist/cli/commands.js.map +1 -0
  10. package/dist/cli/errors.d.ts +6 -0
  11. package/dist/cli/errors.js +97 -0
  12. package/dist/cli/errors.js.map +1 -0
  13. package/dist/cli/format/context.d.ts +5 -0
  14. package/dist/cli/format/context.js +490 -0
  15. package/dist/cli/format/context.js.map +1 -0
  16. package/dist/cli/format/debug.d.ts +4 -0
  17. package/dist/cli/format/debug.js +42 -0
  18. package/dist/cli/format/debug.js.map +1 -0
  19. package/dist/cli/format/highlight.d.ts +3 -0
  20. package/dist/cli/format/highlight.js +106 -0
  21. package/dist/cli/format/highlight.js.map +1 -0
  22. package/dist/cli/format/progress.d.ts +9 -0
  23. package/dist/cli/format/progress.js +92 -0
  24. package/dist/cli/format/progress.js.map +1 -0
  25. package/dist/cli/format/range.d.ts +3 -0
  26. package/dist/cli/format/range.js +24 -0
  27. package/dist/cli/format/range.js.map +1 -0
  28. package/dist/cli/format/status.d.ts +7 -0
  29. package/dist/cli/format/status.js +200 -0
  30. package/dist/cli/format/status.js.map +1 -0
  31. package/dist/cli/help.d.ts +1 -0
  32. package/dist/cli/help.js +88 -0
  33. package/dist/cli/help.js.map +1 -0
  34. package/dist/cli/index.d.ts +2 -0
  35. package/dist/cli/index.js +32 -0
  36. package/dist/cli/index.js.map +1 -0
  37. package/dist/cli/types.d.ts +56 -0
  38. package/dist/cli/types.js +10 -0
  39. package/dist/cli/types.js.map +1 -0
  40. package/dist/cli/version.d.ts +1 -0
  41. package/dist/cli/version.js +11 -0
  42. package/dist/cli/version.js.map +1 -0
  43. package/dist/engine/collection/index.d.ts +50 -0
  44. package/dist/engine/collection/index.js +388 -0
  45. package/dist/engine/collection/index.js.map +1 -0
  46. package/dist/engine/errors/details.d.ts +6 -0
  47. package/dist/engine/errors/details.js +27 -0
  48. package/dist/engine/errors/details.js.map +1 -0
  49. package/dist/engine/errors/index.d.ts +14 -0
  50. package/dist/engine/errors/index.js +16 -0
  51. package/dist/engine/errors/index.js.map +1 -0
  52. package/dist/engine/models/catalog.d.ts +47 -0
  53. package/dist/engine/models/catalog.js +68 -0
  54. package/dist/engine/models/catalog.js.map +1 -0
  55. package/dist/engine/models/embeddings.d.ts +25 -0
  56. package/dist/engine/models/embeddings.js +100 -0
  57. package/dist/engine/models/embeddings.js.map +1 -0
  58. package/dist/engine/models/factory.d.ts +5 -0
  59. package/dist/engine/models/factory.js +66 -0
  60. package/dist/engine/models/factory.js.map +1 -0
  61. package/dist/engine/models/index.d.ts +6 -0
  62. package/dist/engine/models/index.js +5 -0
  63. package/dist/engine/models/index.js.map +1 -0
  64. package/dist/engine/models/providers/index.d.ts +2 -0
  65. package/dist/engine/models/providers/index.js +3 -0
  66. package/dist/engine/models/providers/index.js.map +1 -0
  67. package/dist/engine/models/providers/llama-cpp/embedding.d.ts +94 -0
  68. package/dist/engine/models/providers/llama-cpp/embedding.js +459 -0
  69. package/dist/engine/models/providers/llama-cpp/embedding.js.map +1 -0
  70. package/dist/engine/models/providers/llama-cpp/index.d.ts +1 -0
  71. package/dist/engine/models/providers/llama-cpp/index.js +2 -0
  72. package/dist/engine/models/providers/llama-cpp/index.js.map +1 -0
  73. package/dist/engine/models/providers/qwen/embedding.d.ts +38 -0
  74. package/dist/engine/models/providers/qwen/embedding.js +322 -0
  75. package/dist/engine/models/providers/qwen/embedding.js.map +1 -0
  76. package/dist/engine/models/providers/qwen/index.d.ts +1 -0
  77. package/dist/engine/models/providers/qwen/index.js +2 -0
  78. package/dist/engine/models/providers/qwen/index.js.map +1 -0
  79. package/dist/engine/models/ranking.d.ts +15 -0
  80. package/dist/engine/models/ranking.js +2 -0
  81. package/dist/engine/models/ranking.js.map +1 -0
  82. package/dist/engine/models/types.d.ts +30 -0
  83. package/dist/engine/models/types.js +2 -0
  84. package/dist/engine/models/types.js.map +1 -0
  85. package/dist/engine/pipeline/indexing/extractor/code/adapter.d.ts +19 -0
  86. package/dist/engine/pipeline/indexing/extractor/code/adapter.js +24 -0
  87. package/dist/engine/pipeline/indexing/extractor/code/adapter.js.map +1 -0
  88. package/dist/engine/pipeline/indexing/extractor/code/extractor.d.ts +14 -0
  89. package/dist/engine/pipeline/indexing/extractor/code/extractor.js +594 -0
  90. package/dist/engine/pipeline/indexing/extractor/code/extractor.js.map +1 -0
  91. package/dist/engine/pipeline/indexing/extractor/code/families/c-family.d.ts +2 -0
  92. package/dist/engine/pipeline/indexing/extractor/code/families/c-family.js +116 -0
  93. package/dist/engine/pipeline/indexing/extractor/code/families/c-family.js.map +1 -0
  94. package/dist/engine/pipeline/indexing/extractor/code/families/js-ts.d.ts +12 -0
  95. package/dist/engine/pipeline/indexing/extractor/code/families/js-ts.js +112 -0
  96. package/dist/engine/pipeline/indexing/extractor/code/families/js-ts.js.map +1 -0
  97. package/dist/engine/pipeline/indexing/extractor/code/families/metadata.d.ts +8 -0
  98. package/dist/engine/pipeline/indexing/extractor/code/families/metadata.js +83 -0
  99. package/dist/engine/pipeline/indexing/extractor/code/families/metadata.js.map +1 -0
  100. package/dist/engine/pipeline/indexing/extractor/code/families/name-field.d.ts +3 -0
  101. package/dist/engine/pipeline/indexing/extractor/code/families/name-field.js +22 -0
  102. package/dist/engine/pipeline/indexing/extractor/code/families/name-field.js.map +1 -0
  103. package/dist/engine/pipeline/indexing/extractor/code/languages/c.d.ts +1 -0
  104. package/dist/engine/pipeline/indexing/extractor/code/languages/c.js +15 -0
  105. package/dist/engine/pipeline/indexing/extractor/code/languages/c.js.map +1 -0
  106. package/dist/engine/pipeline/indexing/extractor/code/languages/cpp.d.ts +1 -0
  107. package/dist/engine/pipeline/indexing/extractor/code/languages/cpp.js +18 -0
  108. package/dist/engine/pipeline/indexing/extractor/code/languages/cpp.js.map +1 -0
  109. package/dist/engine/pipeline/indexing/extractor/code/languages/go.d.ts +2 -0
  110. package/dist/engine/pipeline/indexing/extractor/code/languages/go.js +72 -0
  111. package/dist/engine/pipeline/indexing/extractor/code/languages/go.js.map +1 -0
  112. package/dist/engine/pipeline/indexing/extractor/code/languages/java.d.ts +1 -0
  113. package/dist/engine/pipeline/indexing/extractor/code/languages/java.js +17 -0
  114. package/dist/engine/pipeline/indexing/extractor/code/languages/java.js.map +1 -0
  115. package/dist/engine/pipeline/indexing/extractor/code/languages/javascript.d.ts +2 -0
  116. package/dist/engine/pipeline/indexing/extractor/code/languages/javascript.js +25 -0
  117. package/dist/engine/pipeline/indexing/extractor/code/languages/javascript.js.map +1 -0
  118. package/dist/engine/pipeline/indexing/extractor/code/languages/python.d.ts +2 -0
  119. package/dist/engine/pipeline/indexing/extractor/code/languages/python.js +53 -0
  120. package/dist/engine/pipeline/indexing/extractor/code/languages/python.js.map +1 -0
  121. package/dist/engine/pipeline/indexing/extractor/code/languages/rust.d.ts +2 -0
  122. package/dist/engine/pipeline/indexing/extractor/code/languages/rust.js +29 -0
  123. package/dist/engine/pipeline/indexing/extractor/code/languages/rust.js.map +1 -0
  124. package/dist/engine/pipeline/indexing/extractor/code/languages/typescript.d.ts +2 -0
  125. package/dist/engine/pipeline/indexing/extractor/code/languages/typescript.js +37 -0
  126. package/dist/engine/pipeline/indexing/extractor/code/languages/typescript.js.map +1 -0
  127. package/dist/engine/pipeline/indexing/extractor/index.d.ts +44 -0
  128. package/dist/engine/pipeline/indexing/extractor/index.js +281 -0
  129. package/dist/engine/pipeline/indexing/extractor/index.js.map +1 -0
  130. package/dist/engine/pipeline/indexing/extractor/markdown/extractor.d.ts +13 -0
  131. package/dist/engine/pipeline/indexing/extractor/markdown/extractor.js +339 -0
  132. package/dist/engine/pipeline/indexing/extractor/markdown/extractor.js.map +1 -0
  133. package/dist/engine/pipeline/indexing/extractor/tree-sitter/grammar.d.ts +4 -0
  134. package/dist/engine/pipeline/indexing/extractor/tree-sitter/grammar.js +49 -0
  135. package/dist/engine/pipeline/indexing/extractor/tree-sitter/grammar.js.map +1 -0
  136. package/dist/engine/pipeline/indexing/extractor/tree-sitter/nodes.d.ts +3 -0
  137. package/dist/engine/pipeline/indexing/extractor/tree-sitter/nodes.js +26 -0
  138. package/dist/engine/pipeline/indexing/extractor/tree-sitter/nodes.js.map +1 -0
  139. package/dist/engine/pipeline/indexing/extractor/tree-sitter/parser.d.ts +2 -0
  140. package/dist/engine/pipeline/indexing/extractor/tree-sitter/parser.js +31 -0
  141. package/dist/engine/pipeline/indexing/extractor/tree-sitter/parser.js.map +1 -0
  142. package/dist/engine/pipeline/indexing/ids.d.ts +1 -0
  143. package/dist/engine/pipeline/indexing/ids.js +5 -0
  144. package/dist/engine/pipeline/indexing/ids.js.map +1 -0
  145. package/dist/engine/pipeline/indexing/index.d.ts +12 -0
  146. package/dist/engine/pipeline/indexing/index.js +538 -0
  147. package/dist/engine/pipeline/indexing/index.js.map +1 -0
  148. package/dist/engine/pipeline/indexing/root-paths.d.ts +7 -0
  149. package/dist/engine/pipeline/indexing/root-paths.js +151 -0
  150. package/dist/engine/pipeline/indexing/root-paths.js.map +1 -0
  151. package/dist/engine/pipeline/indexing/scanner/index.d.ts +5 -0
  152. package/dist/engine/pipeline/indexing/scanner/index.js +504 -0
  153. package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -0
  154. package/dist/engine/pipeline/search/index.d.ts +12 -0
  155. package/dist/engine/pipeline/search/index.js +761 -0
  156. package/dist/engine/pipeline/search/index.js.map +1 -0
  157. package/dist/engine/service/index.d.ts +2 -0
  158. package/dist/engine/service/index.js +2 -0
  159. package/dist/engine/service/index.js.map +1 -0
  160. package/dist/engine/service/lexical.d.ts +29 -0
  161. package/dist/engine/service/lexical.js +482 -0
  162. package/dist/engine/service/lexical.js.map +1 -0
  163. package/dist/engine/service/root.d.ts +15 -0
  164. package/dist/engine/service/root.js +44 -0
  165. package/dist/engine/service/root.js.map +1 -0
  166. package/dist/engine/service/types.d.ts +157 -0
  167. package/dist/engine/service/types.js +2 -0
  168. package/dist/engine/service/types.js.map +1 -0
  169. package/dist/engine/service/zvec-grep.d.ts +2 -0
  170. package/dist/engine/service/zvec-grep.js +935 -0
  171. package/dist/engine/service/zvec-grep.js.map +1 -0
  172. package/dist/engine/storage/index.d.ts +42 -0
  173. package/dist/engine/storage/index.js +2 -0
  174. package/dist/engine/storage/index.js.map +1 -0
  175. package/dist/engine/storage/zvec.d.ts +51 -0
  176. package/dist/engine/storage/zvec.js +706 -0
  177. package/dist/engine/storage/zvec.js.map +1 -0
  178. package/dist/engine/types.d.ts +266 -0
  179. package/dist/engine/types.js +14 -0
  180. package/dist/engine/types.js.map +1 -0
  181. package/dist/engine/utils/glob.d.ts +6 -0
  182. package/dist/engine/utils/glob.js +110 -0
  183. package/dist/engine/utils/glob.js.map +1 -0
  184. package/dist/engine/utils/hash.d.ts +2 -0
  185. package/dist/engine/utils/hash.js +8 -0
  186. package/dist/engine/utils/hash.js.map +1 -0
  187. package/dist/engine/utils/json.d.ts +4 -0
  188. package/dist/engine/utils/json.js +45 -0
  189. package/dist/engine/utils/json.js.map +1 -0
  190. package/dist/engine/utils/lock.d.ts +19 -0
  191. package/dist/engine/utils/lock.js +254 -0
  192. package/dist/engine/utils/lock.js.map +1 -0
  193. package/dist/engine/utils/path.d.ts +4 -0
  194. package/dist/engine/utils/path.js +18 -0
  195. package/dist/engine/utils/path.js.map +1 -0
  196. package/dist/index.d.ts +6 -0
  197. package/dist/index.js +4 -0
  198. package/dist/index.js.map +1 -0
  199. package/package.json +47 -0
  200. package/skills/zvec-grep/SKILL.md +141 -0
  201. package/skills/zvec-grep/agents/openai.yaml +4 -0
package/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.
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ <p align="right">
2
+ English | <a href="./README_CN.md">中文</a>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <picture>
7
+ <source media="(prefers-color-scheme: dark)" srcset="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_log_2.svg" />
8
+ <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_logo_1.svg" width="400" alt="zvec logo" />
9
+ </picture>
10
+ </div>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/@zvec/zvec-grep"><img src="https://img.shields.io/npm/v/@zvec/zvec-grep.svg" alt="npm Release"/></a>
14
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"/></a>
15
+ <img src="https://img.shields.io/badge/node-%3E%3D20-blue.svg" alt="Node.js >=20"/>
16
+ <img src="https://img.shields.io/badge/CLI-zg-2ea44f.svg" alt="zg CLI"/>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#quickstart">🚀 <strong>Quickstart</strong></a> |
21
+ <a href="#features">💫 <strong>Features</strong></a> |
22
+ <a href="#installation">📦 <strong>Installation</strong></a> |
23
+ <a href="#models">🧠 <strong>Models</strong></a> |
24
+ <a href="#library-api">🛠️ <strong>Library API</strong></a>
25
+ </p>
26
+
27
+ **zvec-grep** is an agent-friendly hybrid code search tool built on Zvec. It gives repositories a root-local semantic index, combines vector search with full-text search, and keeps CLI output compact enough for AI agents while still offering rich terminal output for humans.
28
+
29
+ The command is intentionally short:
30
+
31
+ ```bash
32
+ zg "where query auto update happens"
33
+ ```
34
+
35
+ > [!IMPORTANT]
36
+ > **v0.1.0**
37
+ >
38
+ > - **Hybrid Code Search**: Query code with natural language, exact terms, or both in one command.
39
+ > - **Explicit Index Lifecycle**: New repositories require `zg --init --embedding <model>`; agents do not silently create indexes.
40
+ > - **Automatic Refresh**: Existing anonymous indexes are checked and incrementally updated before normal queries.
41
+ > - **Token-Efficient Output**: Agent output defaults to `--preview none`; `--human` defaults to full source previews.
42
+ > - **No-Index Lexical Search**: `zg --rg` provides managed ripgrep search without requiring an index.
43
+
44
+ ## <a id="features"></a>💫 Features
45
+
46
+ - **Semantic + Lexical Retrieval**: Blend vector search and full-text search for code, docs, tests, scripts, and configuration.
47
+ - **Root-Local Indexes**: Anonymous indexes live under `<repo>/.zvec-grep/`, so repository state stays with the repository.
48
+ - **Agent-Ready Output**: Default output is grouped by file and keeps previews small to save tokens.
49
+ - **Human Output Mode**: Add `--human` for a terminal-friendly summary with full previews by default.
50
+ - **Managed ripgrep Route**: `zg --rg` supports common `rg` flags and works even before a repository is initialized.
51
+ - **Explicit Model Choice**: First init requires a model such as `local/embeddinggemma-300m`, `local/qwen3-embedding-0.6b`, or `qwen/text-embedding-v4`.
52
+ - **Schema Reuse**: Re-running `zg --init` on an existing index reuses the stored embedding schema unless you explicitly change it.
53
+ - **Library API**: Use `createZvecGrep()` directly from Node.js tools, agents, or MCP servers.
54
+
55
+ ## <a id="installation"></a>📦 Installation
56
+
57
+ Install the CLI from npm:
58
+
59
+ ```bash
60
+ npm install -g @zvec/zvec-grep
61
+ zg --version
62
+ ```
63
+
64
+ Or run it without a global install:
65
+
66
+ ```bash
67
+ npx @zvec/zvec-grep --help
68
+ ```
69
+
70
+ ### ✅ Requirements
71
+
72
+ - Node.js 20 or newer
73
+ - macOS, Linux, or Windows
74
+ - A supported embedding model for indexed search
75
+
76
+ `zg --rg` works without any embedding model or index.
77
+
78
+ ## <a id="quickstart"></a>⚡ Quickstart
79
+
80
+ Initialize a repository with an explicit embedding model:
81
+
82
+ ```bash
83
+ zg --init \
84
+ --embedding local/embeddinggemma-300m \
85
+ --include "src/**" \
86
+ --include "docs/**" \
87
+ --include "test/**" \
88
+ --exclude "dist/**,node_modules/**,coverage/**"
89
+ ```
90
+
91
+ Check index state:
92
+
93
+ ```bash
94
+ zg --info
95
+ ```
96
+
97
+ Search with natural language:
98
+
99
+ ```bash
100
+ zg "where query auto update happens"
101
+ ```
102
+
103
+ Combine semantic intent with exact anchors:
104
+
105
+ ```bash
106
+ zg "GPU fallback" --fts "usingCpuFallback" --include "src/**" --limit 5
107
+ ```
108
+
109
+ Use exhaustive lexical search without an index:
110
+
111
+ ```bash
112
+ zg --rg -F "ZVEC_GREP_HOME" src
113
+ ```
114
+
115
+ Switch to human-readable output:
116
+
117
+ ```bash
118
+ zg --human "root local index discovery" --limit 3
119
+ ```
120
+
121
+ ## <a id="models"></a>🧠 Models
122
+
123
+ Local models run through `node-llama-cpp` and keep code search private to your machine:
124
+
125
+ ```bash
126
+ zg --init --embedding local/embeddinggemma-300m
127
+ zg --init --embedding local/qwen3-embedding-0.6b
128
+ ```
129
+
130
+ Remote Qwen embeddings are useful when you prefer a managed embedding service or want to avoid local model setup:
131
+
132
+ ```bash
133
+ zg --init \
134
+ --embedding qwen/text-embedding-v4 \
135
+ --api-key "$DASHSCOPE_API_KEY"
136
+ ```
137
+
138
+ For existing indexes, `zg --init` without `--embedding` reuses the stored schema. Use `--rebuild --embedding <model>` only when you intentionally want to rebuild with a different model:
139
+
140
+ ```bash
141
+ zg --init --rebuild --embedding local/qwen3-embedding-0.6b
142
+ ```
143
+
144
+ ## 🔎 Query Patterns
145
+
146
+ Multiple quoted queries are treated as separate search groups:
147
+
148
+ ```bash
149
+ zg "request validation" "error handling" --limit 5
150
+ ```
151
+
152
+ Use path filters early to keep results focused:
153
+
154
+ ```bash
155
+ zg "cache invalidation" \
156
+ --include "src/**" \
157
+ --exclude "test/**,tests/**,fixtures/**,dist/**"
158
+ ```
159
+
160
+ Use `--preview` to control indexed source previews:
161
+
162
+ ```bash
163
+ zg "plugin lifecycle" --preview none
164
+ zg "plugin lifecycle" --preview short --limit 5
165
+ zg "plugin lifecycle" --preview full --limit 2
166
+ ```
167
+
168
+ For exact text, symbols, flags, or error codes, use `--fts` or `--rg`:
169
+
170
+ ```bash
171
+ zg "authentication flow" --fts "AuthService" "ForbiddenError"
172
+ zg --rg -i -C 2 -g "*.ts" "needle text" src
173
+ ```
174
+
175
+ ## <a id="library-api"></a>🛠️ Library API
176
+
177
+ ```ts
178
+ import { createZvecGrep } from "@zvec/zvec-grep";
179
+
180
+ const zvecGrep = await createZvecGrep({
181
+ root: process.cwd(),
182
+ });
183
+
184
+ const result = await zvecGrep.context({
185
+ query: "ranking implementation",
186
+ limit: 5,
187
+ });
188
+
189
+ for (const item of result.items) {
190
+ console.log(`${item.file.relativePath}:${item.range.startLine}`);
191
+ }
192
+
193
+ await zvecGrep.close();
194
+ ```
195
+
196
+ For explicit no-index lexical search:
197
+
198
+ ```ts
199
+ const result = await zvecGrep.context({
200
+ query: "ZVEC_GREP_HOME",
201
+ rg: true,
202
+ });
203
+ ```
204
+
205
+ ## 🤝 Join the Zvec Community
206
+
207
+ <div align="center">
208
+
209
+ | 💬 DingTalk | 📱 WeChat | 🎮 Discord | X (Twitter) |
210
+ | :---: | :---: | :---: | :---: |
211
+ | <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/dingding.png" width="150" alt="DingTalk QR Code"/> | <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/wechat.png?v=6" width="150" alt="WeChat QR Code"/> | [![Discord](https://img.shields.io/badge/Discord-Join%20Server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rKddFBBu9z) | [![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ZvecAI)](<https://x.com/ZvecAI>) |
212
+ | Scan to join | Scan to join | Click to join | Click to follow |
213
+
214
+ </div>
215
+
216
+ ## ❤️ Contributing
217
+
218
+ Issues and pull requests are welcome. Please keep changes focused, add tests for behavior changes, and run:
219
+
220
+ ```bash
221
+ npm test
222
+ ```
package/README_CN.md ADDED
@@ -0,0 +1,222 @@
1
+ <p align="right">
2
+ <a href="./README.md">English</a> | 中文
3
+ </p>
4
+
5
+ <div align="center">
6
+ <picture>
7
+ <source media="(prefers-color-scheme: dark)" srcset="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_log_2.svg" />
8
+ <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_logo_1.svg" width="400" alt="zvec logo" />
9
+ </picture>
10
+ </div>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/@zvec/zvec-grep"><img src="https://img.shields.io/npm/v/@zvec/zvec-grep.svg" alt="npm 版本"/></a>
14
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="许可证"/></a>
15
+ <img src="https://img.shields.io/badge/node-%3E%3D20-blue.svg" alt="Node.js >=20"/>
16
+ <img src="https://img.shields.io/badge/CLI-zg-2ea44f.svg" alt="zg CLI"/>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#quickstart">🚀 <strong>快速开始</strong></a> |
21
+ <a href="#features">💫 <strong>核心特性</strong></a> |
22
+ <a href="#installation">📦 <strong>安装</strong></a> |
23
+ <a href="#models">🧠 <strong>模型</strong></a> |
24
+ <a href="#library-api">🛠️ <strong>库 API</strong></a>
25
+ </p>
26
+
27
+ **zvec-grep** 是基于 Zvec 构建的、面向 agent 的代码库混合检索工具。它为仓库维护本地语义索引,融合向量检索与全文检索,并默认输出节省 token 的结果;当人在终端里阅读时,也可以切换到更完整的展示模式。
28
+
29
+ 命令非常短:
30
+
31
+ ```bash
32
+ zg "where query auto update happens"
33
+ ```
34
+
35
+ > [!IMPORTANT]
36
+ > **v0.1.0**
37
+ >
38
+ > - **混合代码检索**:可以用自然语言、精确关键词,或两者组合来搜索代码。
39
+ > - **明确的索引生命周期**:新仓库必须显式运行 `zg --init --embedding <model>`;agent 不会静默创建索引。
40
+ > - **自动刷新**:已有匿名索引会在普通查询前自动检查并增量更新。
41
+ > - **节省 Token 的输出**:agent 默认输出 `--preview none`;`--human` 默认展示完整源码 preview。
42
+ > - **无索引文本搜索**:`zg --rg` 提供托管的 ripgrep 搜索,不需要先初始化索引。
43
+
44
+ ## <a id="features"></a>💫 核心特性
45
+
46
+ - **语义 + 词法检索**:融合向量检索和全文检索,适合源码、文档、测试、脚本和配置。
47
+ - **仓库本地索引**:匿名索引存放在 `<repo>/.zvec-grep/`,索引状态跟随仓库。
48
+ - **Agent 友好输出**:默认按文件分组,并尽量减少源码 preview,降低上下文成本。
49
+ - **人类阅读模式**:加 `--human` 后更适合终端阅读,并默认展示完整 preview。
50
+ - **托管 ripgrep 通道**:`zg --rg` 支持常见 `rg` 参数,未初始化仓库也能使用。
51
+ - **显式模型选择**:第一次初始化必须指定模型,例如 `local/embeddinggemma-300m`、`local/qwen3-embedding-0.6b` 或 `qwen/text-embedding-v4`。
52
+ - **Schema 复用**:已有索引再次运行 `zg --init` 会复用保存的 embedding schema,除非你显式切换模型。
53
+ - **库 API**:Node.js 工具、agent 或 MCP server 可以直接使用 `createZvecGrep()`。
54
+
55
+ ## <a id="installation"></a>📦 安装
56
+
57
+ 从 npm 安装 CLI:
58
+
59
+ ```bash
60
+ npm install -g @zvec/zvec-grep
61
+ zg --version
62
+ ```
63
+
64
+ 也可以不全局安装,直接运行:
65
+
66
+ ```bash
67
+ npx @zvec/zvec-grep --help
68
+ ```
69
+
70
+ ### ✅ 运行要求
71
+
72
+ - Node.js 20 或更新版本
73
+ - macOS、Linux 或 Windows
74
+ - 使用索引检索时需要选择一个支持的 embedding 模型
75
+
76
+ `zg --rg` 不需要 embedding 模型,也不需要索引。
77
+
78
+ ## <a id="quickstart"></a>⚡ 快速开始
79
+
80
+ 初始化仓库,并显式指定 embedding 模型:
81
+
82
+ ```bash
83
+ zg --init \
84
+ --embedding local/embeddinggemma-300m \
85
+ --include "src/**" \
86
+ --include "docs/**" \
87
+ --include "test/**" \
88
+ --exclude "dist/**,node_modules/**,coverage/**"
89
+ ```
90
+
91
+ 查看索引状态:
92
+
93
+ ```bash
94
+ zg --info
95
+ ```
96
+
97
+ 用自然语言搜索:
98
+
99
+ ```bash
100
+ zg "where query auto update happens"
101
+ ```
102
+
103
+ 组合语义意图和精确锚点:
104
+
105
+ ```bash
106
+ zg "GPU fallback" --fts "usingCpuFallback" --include "src/**" --limit 5
107
+ ```
108
+
109
+ 不依赖索引,做穷尽文本搜索:
110
+
111
+ ```bash
112
+ zg --rg -F "ZVEC_GREP_HOME" src
113
+ ```
114
+
115
+ 切换到适合人看的输出:
116
+
117
+ ```bash
118
+ zg --human "root local index discovery" --limit 3
119
+ ```
120
+
121
+ ## <a id="models"></a>🧠 模型
122
+
123
+ 本地模型通过 `node-llama-cpp` 运行,适合把代码检索留在本机:
124
+
125
+ ```bash
126
+ zg --init --embedding local/embeddinggemma-300m
127
+ zg --init --embedding local/qwen3-embedding-0.6b
128
+ ```
129
+
130
+ 远程 Qwen embedding 适合希望使用托管 embedding 服务,或不想在本机配置模型的场景:
131
+
132
+ ```bash
133
+ zg --init \
134
+ --embedding qwen/text-embedding-v4 \
135
+ --api-key "$DASHSCOPE_API_KEY"
136
+ ```
137
+
138
+ 对于已有索引,`zg --init` 不传 `--embedding` 会复用索引里保存的 schema。只有在你明确想切换模型时,才使用 `--rebuild --embedding <model>`:
139
+
140
+ ```bash
141
+ zg --init --rebuild --embedding local/qwen3-embedding-0.6b
142
+ ```
143
+
144
+ ## 🔎 查询模式
145
+
146
+ 多个带引号的 query 会作为多个搜索组分别检索:
147
+
148
+ ```bash
149
+ zg "request validation" "error handling" --limit 5
150
+ ```
151
+
152
+ 尽早使用路径过滤,让结果保持聚焦:
153
+
154
+ ```bash
155
+ zg "cache invalidation" \
156
+ --include "src/**" \
157
+ --exclude "test/**,tests/**,fixtures/**,dist/**"
158
+ ```
159
+
160
+ 使用 `--preview` 控制索引结果的源码展示量:
161
+
162
+ ```bash
163
+ zg "plugin lifecycle" --preview none
164
+ zg "plugin lifecycle" --preview short --limit 5
165
+ zg "plugin lifecycle" --preview full --limit 2
166
+ ```
167
+
168
+ 查精确文本、符号、配置项或错误码时,使用 `--fts` 或 `--rg`:
169
+
170
+ ```bash
171
+ zg "authentication flow" --fts "AuthService" "ForbiddenError"
172
+ zg --rg -i -C 2 -g "*.ts" "needle text" src
173
+ ```
174
+
175
+ ## <a id="library-api"></a>🛠️ 库 API
176
+
177
+ ```ts
178
+ import { createZvecGrep } from "@zvec/zvec-grep";
179
+
180
+ const zvecGrep = await createZvecGrep({
181
+ root: process.cwd(),
182
+ });
183
+
184
+ const result = await zvecGrep.context({
185
+ query: "ranking implementation",
186
+ limit: 5,
187
+ });
188
+
189
+ for (const item of result.items) {
190
+ console.log(`${item.file.relativePath}:${item.range.startLine}`);
191
+ }
192
+
193
+ await zvecGrep.close();
194
+ ```
195
+
196
+ 显式进行无索引文本搜索:
197
+
198
+ ```ts
199
+ const result = await zvecGrep.context({
200
+ query: "ZVEC_GREP_HOME",
201
+ rg: true,
202
+ });
203
+ ```
204
+
205
+ ## 🤝 加入 Zvec 社区
206
+
207
+ <div align="center">
208
+
209
+ | 💬 钉钉群 | 📱 微信群 | 🎮 Discord | X (Twitter) |
210
+ | :---: | :---: | :---: | :---: |
211
+ | <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/dingding.png" width="150" alt="钉钉二维码"/> | <img src="https://zvec.oss-cn-hongkong.aliyuncs.com/qrcode/wechat.png?v=6" width="150" alt="微信二维码"/> | [![Discord](https://img.shields.io/badge/Discord-Join%20Server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rKddFBBu9z) | [![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ZvecAI)](<https://x.com/ZvecAI>) |
212
+ | 扫码加入 | 扫码加入 | 点击加入 | 点击关注 |
213
+
214
+ </div>
215
+
216
+ ## ❤️ 参与贡献
217
+
218
+ 欢迎提交 issue 和 pull request。请保持改动聚焦;如果改变行为,请补充测试,并运行:
219
+
220
+ ```bash
221
+ npm test
222
+ ```
@@ -0,0 +1,2 @@
1
+ import type { ParsedArgs } from "./types.js";
2
+ export declare function parseArgs(args: readonly string[]): ParsedArgs;