@zvec/zvec-grep 0.1.4 → 0.1.6

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 (356) hide show
  1. package/README.md +86 -162
  2. package/README_CN.md +80 -162
  3. package/dist/authorization/index.d.ts +7 -0
  4. package/dist/authorization/index.js +7 -0
  5. package/dist/authorization/index.js.map +1 -0
  6. package/dist/authorization/manager.d.ts +8 -0
  7. package/dist/authorization/manager.js +19 -0
  8. package/dist/authorization/manager.js.map +1 -0
  9. package/dist/authorization/operation.d.ts +7 -0
  10. package/dist/authorization/operation.js +50 -0
  11. package/dist/authorization/operation.js.map +1 -0
  12. package/dist/authorization/planner.d.ts +21 -0
  13. package/dist/authorization/planner.js +97 -0
  14. package/dist/authorization/planner.js.map +1 -0
  15. package/dist/authorization/prompt.d.ts +11 -0
  16. package/dist/authorization/prompt.js +62 -0
  17. package/dist/authorization/prompt.js.map +1 -0
  18. package/dist/authorization/store.d.ts +20 -0
  19. package/dist/authorization/store.js +251 -0
  20. package/dist/authorization/store.js.map +1 -0
  21. package/dist/authorization/target.d.ts +15 -0
  22. package/dist/authorization/target.js +49 -0
  23. package/dist/authorization/target.js.map +1 -0
  24. package/dist/authorization/types.d.ts +61 -0
  25. package/dist/authorization/types.js +2 -0
  26. package/dist/authorization/types.js.map +1 -0
  27. package/dist/cli/args.d.ts +3 -0
  28. package/dist/cli/args.js +749 -201
  29. package/dist/cli/args.js.map +1 -1
  30. package/dist/cli/auth.d.ts +21 -0
  31. package/dist/cli/auth.js +212 -0
  32. package/dist/cli/auth.js.map +1 -0
  33. package/dist/cli/commands.d.ts +3 -1
  34. package/dist/cli/commands.js +529 -180
  35. package/dist/cli/commands.js.map +1 -1
  36. package/dist/cli/errors.js +7 -6
  37. package/dist/cli/errors.js.map +1 -1
  38. package/dist/cli/format/context.d.ts +1 -0
  39. package/dist/cli/format/context.js +270 -70
  40. package/dist/cli/format/context.js.map +1 -1
  41. package/dist/cli/format/debug.js +14 -16
  42. package/dist/cli/format/debug.js.map +1 -1
  43. package/dist/cli/format/highlight.js.map +1 -1
  44. package/dist/cli/format/progress.d.ts +4 -0
  45. package/dist/cli/format/progress.js +222 -44
  46. package/dist/cli/format/progress.js.map +1 -1
  47. package/dist/cli/format/range.js.map +1 -1
  48. package/dist/cli/format/status.d.ts +77 -6
  49. package/dist/cli/format/status.js +343 -114
  50. package/dist/cli/format/status.js.map +1 -1
  51. package/dist/cli/help.d.ts +1 -1
  52. package/dist/cli/help.js +368 -84
  53. package/dist/cli/help.js.map +1 -1
  54. package/dist/cli/index.js +4 -4
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/cli/install.d.ts +4 -0
  57. package/dist/cli/install.js +845 -0
  58. package/dist/cli/install.js.map +1 -0
  59. package/dist/cli/managed-rg.d.ts +10 -0
  60. package/dist/cli/managed-rg.js +329 -0
  61. package/dist/cli/managed-rg.js.map +1 -0
  62. package/dist/cli/types.d.ts +40 -13
  63. package/dist/cli/types.js.map +1 -1
  64. package/dist/cli/version.js +3 -1
  65. package/dist/cli/version.js.map +1 -1
  66. package/dist/client/daemon-client.d.ts +19 -0
  67. package/dist/client/daemon-client.js +180 -0
  68. package/dist/client/daemon-client.js.map +1 -0
  69. package/dist/client/mode-router.d.ts +9 -0
  70. package/dist/client/mode-router.js +28 -0
  71. package/dist/client/mode-router.js.map +1 -0
  72. package/dist/client/search-policy.d.ts +11 -0
  73. package/dist/client/search-policy.js +15 -0
  74. package/dist/client/search-policy.js.map +1 -0
  75. package/dist/daemon/backend.d.ts +76 -0
  76. package/dist/daemon/backend.js +1049 -0
  77. package/dist/daemon/backend.js.map +1 -0
  78. package/dist/daemon/change-set.d.ts +25 -0
  79. package/dist/daemon/change-set.js +101 -0
  80. package/dist/daemon/change-set.js.map +1 -0
  81. package/dist/daemon/config.d.ts +24 -0
  82. package/dist/daemon/config.js +88 -0
  83. package/dist/daemon/config.js.map +1 -0
  84. package/dist/daemon/errors.d.ts +5 -0
  85. package/dist/daemon/errors.js +11 -0
  86. package/dist/daemon/errors.js.map +1 -0
  87. package/dist/daemon/http-server.d.ts +30 -0
  88. package/dist/daemon/http-server.js +287 -0
  89. package/dist/daemon/http-server.js.map +1 -0
  90. package/dist/daemon/index-coordinator.d.ts +23 -0
  91. package/dist/daemon/index-coordinator.js +68 -0
  92. package/dist/daemon/index-coordinator.js.map +1 -0
  93. package/dist/daemon/job-scheduler.d.ts +70 -0
  94. package/dist/daemon/job-scheduler.js +366 -0
  95. package/dist/daemon/job-scheduler.js.map +1 -0
  96. package/dist/daemon/logger.d.ts +9 -0
  97. package/dist/daemon/logger.js +53 -0
  98. package/dist/daemon/logger.js.map +1 -0
  99. package/dist/daemon/model-pool.d.ts +45 -0
  100. package/dist/daemon/model-pool.js +187 -0
  101. package/dist/daemon/model-pool.js.map +1 -0
  102. package/dist/daemon/root-lease.d.ts +14 -0
  103. package/dist/daemon/root-lease.js +188 -0
  104. package/dist/daemon/root-lease.js.map +1 -0
  105. package/dist/daemon/root-runtime.d.ts +78 -0
  106. package/dist/daemon/root-runtime.js +333 -0
  107. package/dist/daemon/root-runtime.js.map +1 -0
  108. package/dist/daemon/runtime-manager.d.ts +45 -0
  109. package/dist/daemon/runtime-manager.js +243 -0
  110. package/dist/daemon/runtime-manager.js.map +1 -0
  111. package/dist/daemon/runtime.d.ts +12 -0
  112. package/dist/daemon/runtime.js +102 -0
  113. package/dist/daemon/runtime.js.map +1 -0
  114. package/dist/daemon/server-controller.d.ts +39 -0
  115. package/dist/daemon/server-controller.js +203 -0
  116. package/dist/daemon/server-controller.js.map +1 -0
  117. package/dist/daemon/watch-manager.d.ts +50 -0
  118. package/dist/daemon/watch-manager.js +293 -0
  119. package/dist/daemon/watch-manager.js.map +1 -0
  120. package/dist/daemon/workspace-read-session-cache.d.ts +31 -0
  121. package/dist/daemon/workspace-read-session-cache.js +115 -0
  122. package/dist/daemon/workspace-read-session-cache.js.map +1 -0
  123. package/dist/engine/config.d.ts +50 -0
  124. package/dist/engine/config.js +321 -0
  125. package/dist/engine/config.js.map +1 -0
  126. package/dist/engine/{errors/index.d.ts → errors.d.ts} +6 -1
  127. package/dist/engine/{errors/details.js → errors.js} +17 -4
  128. package/dist/engine/errors.js.map +1 -0
  129. package/dist/engine/extraction/code/adapter.d.ts +1 -1
  130. package/dist/engine/extraction/code/adapter.js.map +1 -1
  131. package/dist/engine/extraction/code/extractor.d.ts +5 -11
  132. package/dist/engine/extraction/code/extractor.js +184 -109
  133. package/dist/engine/extraction/code/extractor.js.map +1 -1
  134. package/dist/engine/extraction/code/families/c-family.js +13 -7
  135. package/dist/engine/extraction/code/families/c-family.js.map +1 -1
  136. package/dist/engine/extraction/code/families/js-ts.d.ts +1 -1
  137. package/dist/engine/extraction/code/families/js-ts.js +24 -18
  138. package/dist/engine/extraction/code/families/js-ts.js.map +1 -1
  139. package/dist/engine/extraction/code/families/metadata.d.ts +1 -1
  140. package/dist/engine/extraction/code/families/metadata.js +11 -8
  141. package/dist/engine/extraction/code/families/metadata.js.map +1 -1
  142. package/dist/engine/extraction/code/families/name-field.js +5 -5
  143. package/dist/engine/extraction/code/families/name-field.js.map +1 -1
  144. package/dist/engine/extraction/code/languages/c.js +1 -4
  145. package/dist/engine/extraction/code/languages/c.js.map +1 -1
  146. package/dist/engine/extraction/code/languages/cpp.js.map +1 -1
  147. package/dist/engine/extraction/code/languages/go.js +1 -3
  148. package/dist/engine/extraction/code/languages/go.js.map +1 -1
  149. package/dist/engine/extraction/code/languages/java.js.map +1 -1
  150. package/dist/engine/extraction/code/languages/javascript.js +1 -3
  151. package/dist/engine/extraction/code/languages/javascript.js.map +1 -1
  152. package/dist/engine/extraction/code/languages/python.js +5 -6
  153. package/dist/engine/extraction/code/languages/python.js.map +1 -1
  154. package/dist/engine/extraction/code/languages/rust.js +1 -5
  155. package/dist/engine/extraction/code/languages/rust.js.map +1 -1
  156. package/dist/engine/extraction/code/languages/typescript.js.map +1 -1
  157. package/dist/engine/extraction/code/tree-sitter/grammar.js.map +1 -0
  158. package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.js +2 -1
  159. package/dist/engine/extraction/code/tree-sitter/nodes.js.map +1 -0
  160. package/dist/engine/extraction/code/tree-sitter/parser.js.map +1 -0
  161. package/dist/engine/extraction/ids.js.map +1 -1
  162. package/dist/engine/extraction/image/extractor.d.ts +5 -0
  163. package/dist/engine/extraction/image/extractor.js +35 -0
  164. package/dist/engine/extraction/image/extractor.js.map +1 -0
  165. package/dist/engine/extraction/index.d.ts +3 -44
  166. package/dist/engine/extraction/index.js +1 -280
  167. package/dist/engine/extraction/index.js.map +1 -1
  168. package/dist/engine/extraction/markdown/extractor.d.ts +5 -11
  169. package/dist/engine/extraction/markdown/extractor.js +37 -16
  170. package/dist/engine/extraction/markdown/extractor.js.map +1 -1
  171. package/dist/engine/extraction/runtime.d.ts +4 -0
  172. package/dist/engine/extraction/runtime.js +26 -0
  173. package/dist/engine/extraction/runtime.js.map +1 -0
  174. package/dist/engine/extraction/source.d.ts +18 -0
  175. package/dist/engine/extraction/source.js +22 -0
  176. package/dist/engine/extraction/source.js.map +1 -0
  177. package/dist/engine/extraction/text/extractor.d.ts +7 -0
  178. package/dist/engine/extraction/text/extractor.js +168 -0
  179. package/dist/engine/extraction/text/extractor.js.map +1 -0
  180. package/dist/engine/extraction/types.d.ts +4 -0
  181. package/dist/engine/{models → extraction}/types.js.map +1 -1
  182. package/dist/engine/{files/file-type.d.ts → file-type.d.ts} +1 -1
  183. package/dist/engine/file-type.js.map +1 -0
  184. package/dist/engine/index-status.d.ts +9 -0
  185. package/dist/engine/index-status.js +38 -0
  186. package/dist/engine/index-status.js.map +1 -0
  187. package/dist/engine/manifest.d.ts +12 -0
  188. package/dist/engine/manifest.js +120 -0
  189. package/dist/engine/manifest.js.map +1 -0
  190. package/dist/engine/models/{providers/llama-cpp/embedding.d.ts → backends/llama-cpp.d.ts} +25 -20
  191. package/dist/engine/models/{providers/llama-cpp/embedding.js → backends/llama-cpp.js} +165 -113
  192. package/dist/engine/models/backends/llama-cpp.js.map +1 -0
  193. package/dist/engine/models/backends/model2vec.d.ts +57 -0
  194. package/dist/engine/models/backends/model2vec.js +332 -0
  195. package/dist/engine/models/backends/model2vec.js.map +1 -0
  196. package/dist/engine/models/backends/qwen.d.ts +44 -0
  197. package/dist/engine/models/{providers/qwen/embedding.js → backends/qwen.js} +168 -102
  198. package/dist/engine/models/backends/qwen.js.map +1 -0
  199. package/dist/engine/models/backends/transformers-js.d.ts +87 -0
  200. package/dist/engine/models/backends/transformers-js.js +316 -0
  201. package/dist/engine/models/backends/transformers-js.js.map +1 -0
  202. package/dist/engine/models/catalog.d.ts +188 -23
  203. package/dist/engine/models/catalog.js +172 -41
  204. package/dist/engine/models/catalog.js.map +1 -1
  205. package/dist/engine/models/download-progress.d.ts +15 -0
  206. package/dist/engine/models/download-progress.js +48 -0
  207. package/dist/engine/models/download-progress.js.map +1 -0
  208. package/dist/engine/models/embeddings.d.ts +58 -18
  209. package/dist/engine/models/embeddings.js +53 -29
  210. package/dist/engine/models/embeddings.js.map +1 -1
  211. package/dist/engine/models/factory.d.ts +2 -5
  212. package/dist/engine/models/factory.js +41 -56
  213. package/dist/engine/models/factory.js.map +1 -1
  214. package/dist/engine/models/index.d.ts +4 -6
  215. package/dist/engine/models/index.js +4 -4
  216. package/dist/engine/models/index.js.map +1 -1
  217. package/dist/engine/models/ranking.d.ts +7 -3
  218. package/dist/engine/models/resolution.d.ts +8 -0
  219. package/dist/engine/models/resolution.js +22 -0
  220. package/dist/engine/models/resolution.js.map +1 -0
  221. package/dist/engine/pipeline/indexing/index.d.ts +9 -7
  222. package/dist/engine/pipeline/indexing/index.js +399 -147
  223. package/dist/engine/pipeline/indexing/index.js.map +1 -1
  224. package/dist/engine/pipeline/indexing/root-paths.js +16 -19
  225. package/dist/engine/pipeline/indexing/root-paths.js.map +1 -1
  226. package/dist/engine/pipeline/indexing/scanner/index.d.ts +6 -1
  227. package/dist/engine/pipeline/indexing/scanner/index.js +318 -66
  228. package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
  229. package/dist/engine/pipeline/search/index.d.ts +6 -6
  230. package/dist/engine/pipeline/search/index.js +76 -34
  231. package/dist/engine/pipeline/search/index.js.map +1 -1
  232. package/dist/engine/service/index.d.ts +3 -2
  233. package/dist/engine/service/index.js +1 -1
  234. package/dist/engine/service/index.js.map +1 -1
  235. package/dist/engine/service/lexical.d.ts +14 -15
  236. package/dist/engine/service/lexical.js +78 -119
  237. package/dist/engine/service/lexical.js.map +1 -1
  238. package/dist/engine/service/root.d.ts +13 -12
  239. package/dist/engine/service/root.js +35 -24
  240. package/dist/engine/service/root.js.map +1 -1
  241. package/dist/engine/service/structure-enrichment.js +29 -25
  242. package/dist/engine/service/structure-enrichment.js.map +1 -1
  243. package/dist/engine/service/types.d.ts +61 -35
  244. package/dist/engine/service/workspace-index.d.ts +24 -0
  245. package/dist/engine/service/workspace-index.js +151 -0
  246. package/dist/engine/service/workspace-index.js.map +1 -0
  247. package/dist/engine/service/zvec-grep.d.ts +12 -1
  248. package/dist/engine/service/zvec-grep.js +878 -544
  249. package/dist/engine/service/zvec-grep.js.map +1 -1
  250. package/dist/engine/storage/index.d.ts +8 -4
  251. package/dist/engine/storage/index.js +1 -1
  252. package/dist/engine/storage/index.js.map +1 -1
  253. package/dist/engine/storage/zvec.d.ts +10 -33
  254. package/dist/engine/storage/zvec.js +110 -49
  255. package/dist/engine/storage/zvec.js.map +1 -1
  256. package/dist/engine/types.d.ts +29 -23
  257. package/dist/engine/types.js +1 -1
  258. package/dist/engine/types.js.map +1 -1
  259. package/dist/engine/utils/daemon-lease.d.ts +17 -0
  260. package/dist/engine/utils/daemon-lease.js +175 -0
  261. package/dist/engine/utils/daemon-lease.js.map +1 -0
  262. package/dist/engine/utils/file-selection.d.ts +10 -0
  263. package/dist/engine/utils/file-selection.js +157 -0
  264. package/dist/engine/utils/file-selection.js.map +1 -0
  265. package/dist/engine/utils/glob.d.ts +3 -0
  266. package/dist/engine/utils/glob.js +116 -18
  267. package/dist/engine/utils/glob.js.map +1 -1
  268. package/dist/engine/utils/hash.js.map +1 -1
  269. package/dist/engine/utils/json.d.ts +6 -2
  270. package/dist/engine/utils/json.js +50 -12
  271. package/dist/engine/utils/json.js.map +1 -1
  272. package/dist/engine/utils/lock.js +7 -7
  273. package/dist/engine/utils/lock.js.map +1 -1
  274. package/dist/engine/utils/path.js +2 -2
  275. package/dist/engine/utils/path.js.map +1 -1
  276. package/dist/engine/utils/timing.js.map +1 -1
  277. package/dist/index-progress.d.ts +10 -0
  278. package/dist/index-progress.js +159 -0
  279. package/dist/index-progress.js.map +1 -0
  280. package/dist/index.d.ts +6 -6
  281. package/dist/index.js +3 -3
  282. package/dist/index.js.map +1 -1
  283. package/dist/mcp/http-transport.d.ts +27 -0
  284. package/dist/mcp/http-transport.js +182 -0
  285. package/dist/mcp/http-transport.js.map +1 -0
  286. package/dist/mcp/input-normalization.d.ts +38 -0
  287. package/dist/mcp/input-normalization.js +95 -0
  288. package/dist/mcp/input-normalization.js.map +1 -0
  289. package/dist/mcp/progress-heartbeat.d.ts +17 -0
  290. package/dist/mcp/progress-heartbeat.js +46 -0
  291. package/dist/mcp/progress-heartbeat.js.map +1 -0
  292. package/dist/mcp/request-metadata.d.ts +2 -0
  293. package/dist/mcp/request-metadata.js +11 -0
  294. package/dist/mcp/request-metadata.js.map +1 -0
  295. package/dist/mcp/request-state.d.ts +40 -0
  296. package/dist/mcp/request-state.js +210 -0
  297. package/dist/mcp/request-state.js.map +1 -0
  298. package/dist/mcp/result-format.d.ts +13 -0
  299. package/dist/mcp/result-format.js +75 -0
  300. package/dist/mcp/result-format.js.map +1 -0
  301. package/dist/mcp/schemas.d.ts +430 -0
  302. package/dist/mcp/schemas.js +447 -0
  303. package/dist/mcp/schemas.js.map +1 -0
  304. package/dist/mcp/tools.d.ts +150 -0
  305. package/dist/mcp/tools.js +448 -0
  306. package/dist/mcp/tools.js.map +1 -0
  307. package/dist/mcp/toolset.d.ts +5 -0
  308. package/dist/mcp/toolset.js +12 -0
  309. package/dist/mcp/toolset.js.map +1 -0
  310. package/dist/observability/trace-context.d.ts +11 -0
  311. package/dist/observability/trace-context.js +138 -0
  312. package/dist/observability/trace-context.js.map +1 -0
  313. package/docs/01-agents.md +111 -0
  314. package/docs/02-cli.md +229 -0
  315. package/docs/03-mcp.md +167 -0
  316. package/docs/04-pipeline.md +218 -0
  317. package/docs/05-architecture.md +86 -0
  318. package/docs/06-server.md +210 -0
  319. package/docs/07-embedding.md +179 -0
  320. package/docs/08-roadmap.md +85 -0
  321. package/docs/README.md +53 -0
  322. package/package.json +43 -7
  323. package/skills/zvec-grep/SKILL.md +43 -123
  324. package/skills/zvec-grep/agents/openai.yaml +2 -2
  325. package/skills/zvec-grep/references/cli-fallback.md +85 -0
  326. package/dist/engine/collection/index.d.ts +0 -55
  327. package/dist/engine/collection/index.js +0 -710
  328. package/dist/engine/collection/index.js.map +0 -1
  329. package/dist/engine/errors/details.d.ts +0 -6
  330. package/dist/engine/errors/details.js.map +0 -1
  331. package/dist/engine/errors/index.js +0 -16
  332. package/dist/engine/errors/index.js.map +0 -1
  333. package/dist/engine/extraction/tree-sitter/grammar.js.map +0 -1
  334. package/dist/engine/extraction/tree-sitter/nodes.js.map +0 -1
  335. package/dist/engine/extraction/tree-sitter/parser.js.map +0 -1
  336. package/dist/engine/files/file-type.js.map +0 -1
  337. package/dist/engine/models/providers/index.d.ts +0 -2
  338. package/dist/engine/models/providers/index.js +0 -3
  339. package/dist/engine/models/providers/index.js.map +0 -1
  340. package/dist/engine/models/providers/llama-cpp/embedding.js.map +0 -1
  341. package/dist/engine/models/providers/llama-cpp/index.d.ts +0 -1
  342. package/dist/engine/models/providers/llama-cpp/index.js +0 -2
  343. package/dist/engine/models/providers/llama-cpp/index.js.map +0 -1
  344. package/dist/engine/models/providers/qwen/embedding.d.ts +0 -42
  345. package/dist/engine/models/providers/qwen/embedding.js.map +0 -1
  346. package/dist/engine/models/providers/qwen/index.d.ts +0 -1
  347. package/dist/engine/models/providers/qwen/index.js +0 -2
  348. package/dist/engine/models/providers/qwen/index.js.map +0 -1
  349. package/dist/engine/models/types.d.ts +0 -30
  350. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.d.ts +0 -0
  351. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.js +0 -0
  352. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.d.ts +0 -0
  353. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.d.ts +0 -0
  354. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.js +0 -0
  355. /package/dist/engine/{models → extraction}/types.js +0 -0
  356. /package/dist/engine/{files/file-type.js → file-type.js} +0 -0
@@ -0,0 +1,85 @@
1
+ # Roadmap
2
+
3
+ [Documentation](./README.md) · [Agents](./01-agents.md) ·
4
+ [CLI](./02-cli.md) · [MCP](./03-mcp.md) · [Pipeline](./04-pipeline.md) ·
5
+ [Architecture](./05-architecture.md) · [Server](./06-server.md) ·
6
+ [Embedding](./07-embedding.md) · [Roadmap](./08-roadmap.md)
7
+
8
+ zvec-grep is under active development. The destination is one dependable,
9
+ local-first search layer that people and agents can use without choosing among
10
+ separate retrieval tools. This roadmap describes direction, not promised dates;
11
+ priorities may change as we learn from real workloads.
12
+
13
+ ## Now — make the public preview dependable
14
+
15
+ - Make installation, updates, and removal reliable across current platforms and
16
+ agent integrations.
17
+ - Harden incremental indexing, freshness, Server recovery, and concurrent
18
+ workspace access.
19
+ - Establish reproducible search-quality, performance, and agent-context
20
+ evaluation.
21
+ - Stabilize the CLI, MCP contracts, configuration, diagnostics, and index
22
+ compatibility policy before a stable release.
23
+
24
+ ## Product direction
25
+
26
+ The following four directions are part of the product vision, not optional
27
+ experiments. Their sequencing may change, but each is required for zg to become
28
+ the search layer we want it to be.
29
+
30
+ ### 1. Search more data formats, natively
31
+
32
+ - Make PDF, PowerPoint (`.ppt` and `.pptx`), HTML, images, and other multimodal
33
+ documents first-class searchable inputs.
34
+ - Add format-aware extraction that preserves useful structure, layout, metadata,
35
+ and relationships instead of flattening every file into plain text.
36
+ - Combine text extraction, OCR, vision-language understanding, and multimodal
37
+ Embedding where each format benefits from them.
38
+ - Use format- and content-aware retrieval so zg can choose a smarter strategy
39
+ for each query and source.
40
+
41
+ ### 2. Strengthen retrieval
42
+
43
+ - Add knowledge-graph construction and graph retrieval to complement BM25,
44
+ vector search, and managed ripgrep.
45
+ - Expand multi-route hybrid retrieval across lexical, vector, graph, structural,
46
+ and metadata signals.
47
+ - Improve query planning so people and agents can express intent without
48
+ manually choosing retrieval routes.
49
+ - Improve fusion, reranking, evaluation, and explainability while keeping the
50
+ returned context compact.
51
+
52
+ ### 3. Make zg more out of the box
53
+
54
+ - Provide a local GUI for search, workspace management, indexing, model setup,
55
+ permissions, and diagnostics.
56
+ - Support more installation paths beyond npm, including platform-native package
57
+ managers and installers where appropriate.
58
+ - Make first-run setup, Agent discovery, model selection, updates, and recovery
59
+ increasingly automatic with useful defaults.
60
+ - Preserve CLI and configuration control for advanced users while removing it
61
+ from the critical path for everyone else.
62
+
63
+ ### 4. Reach every platform, from PC to mobile
64
+
65
+ - Deliver a consistent experience across macOS, Windows, and Linux desktops.
66
+ - Extend the local search layer to iOS and Android instead of treating mobile as
67
+ a remote client to a required cloud service.
68
+ - Adapt indexing, storage, and model execution to the memory, power, and lifecycle
69
+ constraints of mobile devices.
70
+ - Keep the same local-first trust and permission model across desktop and mobile.
71
+
72
+ ## Guardrails
73
+
74
+ - Local-first remains the default; remote content transfer always requires
75
+ explicit authorization.
76
+ - zg should hide retrieval-tool choice from users without hiding useful control.
77
+ - Better recall must not come at the cost of noisy, oversized agent context.
78
+ - A hosted service must never be required for the core local workflow.
79
+
80
+ ## Help shape the roadmap
81
+
82
+ Priorities should come from real use. Open a
83
+ [GitHub issue](https://github.com/zvec-ai/zvec-grep/issues) to describe a
84
+ workflow, limitation, or result that matters to you. Contributions are welcome;
85
+ see the [Contributing Guide](../CONTRIBUTING.md).
package/docs/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # zvec-grep documentation
2
+
3
+ **zg** is one local-first search layer for people and agents. These guides go
4
+ beyond the short path in the project [README](../README.md) and explain how to
5
+ connect an agent, shape an index, search it, and control the underlying
6
+ interfaces.
7
+
8
+ > [!IMPORTANT]
9
+ > zvec-grep is a work in progress. Commands and configuration may change before
10
+ > the first stable release.
11
+
12
+ ## Start here
13
+
14
+ | I want to… | Read |
15
+ | --- | --- |
16
+ | Connect Codex, Claude Code, Cursor, or OpenCode | [Agent integrations](./01-agents.md) |
17
+ | Use zg directly from a terminal | [CLI guide](./02-cli.md) |
18
+ | Understand the tools exposed to an agent | [MCP guide](./03-mcp.md) |
19
+ | Understand indexing, updates, and search routes | [Retrieval pipeline](./04-pipeline.md) |
20
+ | See how the components and trust boundaries fit together | [Architecture](./05-architecture.md) |
21
+ | Choose between Auto, Server, and Direct execution | [Server and execution modes](./06-server.md) |
22
+ | Choose and configure an Embedding model | [Embedding models](./07-embedding.md) |
23
+ | See what is stable now and what comes next | [Roadmap](./08-roadmap.md) |
24
+
25
+ ## Recommended paths
26
+
27
+ If you primarily use an agent, start with [Agent integrations](./01-agents.md),
28
+ then read the [MCP guide](./03-mcp.md) and
29
+ [Retrieval pipeline](./04-pipeline.md). The [Server guide](./06-server.md)
30
+ explains the daemon that connects them.
31
+
32
+ If you primarily use the terminal, start with the [CLI guide](./02-cli.md), then
33
+ read the [Retrieval pipeline](./04-pipeline.md). Use the
34
+ [Embedding guide](./07-embedding.md) when creating a new index. The default
35
+ `auto` execution mode is explained in
36
+ [Server and execution modes](./06-server.md).
37
+
38
+ For the whole-system mental model and trust boundaries, read
39
+ [Architecture](./05-architecture.md).
40
+
41
+ The [Roadmap](./08-roadmap.md) tracks the path from work in progress to a stable
42
+ release.
43
+
44
+ The CLI remains the source of truth for flags in the installed version:
45
+
46
+ ```bash
47
+ zg help
48
+ zg help query
49
+ zg help index
50
+ ```
51
+
52
+ For development setup and pull request conventions, see
53
+ [CONTRIBUTING.md](../CONTRIBUTING.md).
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@zvec/zvec-grep",
3
- "version": "0.1.4",
4
- "description": "Agent-friendly hybrid grep with indexed context and lexical fallback.",
3
+ "version": "0.1.6",
4
+ "description": "Agent-friendly hybrid code search with indexed context and managed ripgrep.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/zvec-ai/zvec-grep.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/zvec-ai/zvec-grep/issues"
13
+ },
14
+ "homepage": "https://github.com/zvec-ai/zvec-grep#readme",
7
15
  "publishConfig": {
8
16
  "access": "public"
9
17
  },
10
18
  "engines": {
11
- "node": ">=20"
19
+ "node": ">=22"
12
20
  },
13
21
  "exports": {
14
22
  ".": {
@@ -23,23 +31,51 @@
23
31
  "README.md",
24
32
  "README_CN.md",
25
33
  "LICENSE",
34
+ "docs",
26
35
  "dist",
27
36
  "skills/zvec-grep"
28
37
  ],
29
38
  "scripts": {
30
39
  "build": "tsc -p tsconfig.json",
40
+ "check": "npm run lint && npm run format:check && npm run typecheck && npm run test:coverage && npm run test:package",
41
+ "format:check": "prettier --check .",
42
+ "lint": "eslint .",
43
+ "prepack": "npm run build",
44
+ "test:coverage": "npm run build && c8 --all --include=dist/**/*.js --check-coverage --lines=80 --statements=80 --functions=80 --branches=80 npm run test:all",
45
+ "test:all": "npm run test:run:root && npm run test:run:unit && npm run test:run:integration && npm run test:run:e2e",
46
+ "test:e2e": "npm run build && npm run test:run:e2e",
47
+ "test:integration": "npm run build && npm run test:run:root && npm run test:run:integration",
48
+ "test:package": "npm run build && node --test --test-concurrency=1 test/package/*.test.mjs",
49
+ "test:run:e2e": "node --test --test-concurrency=1 test/e2e/*.test.mjs",
50
+ "test:run:integration": "node --test --test-concurrency=1 test/integration/*.test.mjs",
51
+ "test:run:root": "node --test --test-concurrency=1 test/*.test.mjs",
52
+ "test:run:unit": "node --test --test-concurrency=1 test/unit/*.test.mjs test/unit/extraction/*.test.mjs test/unit/models/*.test.mjs",
53
+ "test:unit": "npm run build && npm run test:run:unit",
31
54
  "typecheck": "tsc -p tsconfig.json --noEmit",
32
- "test": "npm run build && node --test test/*.test.mjs"
55
+ "test": "npm run build && npm run test:all"
33
56
  },
34
57
  "devDependencies": {
35
- "@types/node": "^25.9.4",
36
- "typescript": "^5.9.3"
58
+ "@eslint/js": "^10.0.1",
59
+ "@modelcontextprotocol/conformance": "0.1.16",
60
+ "@types/node": "^22.20.1",
61
+ "c8": "^11.0.0",
62
+ "eslint": "^10.7.0",
63
+ "globals": "^17.7.0",
64
+ "prettier": "^3.9.5",
65
+ "typescript": "^5.9.3",
66
+ "typescript-eslint": "^8.64.0"
37
67
  },
38
68
  "dependencies": {
69
+ "@huggingface/transformers": "^3.8.1",
70
+ "@modelcontextprotocol/client": "2.0.0",
71
+ "@modelcontextprotocol/core": "2.0.0",
72
+ "@modelcontextprotocol/node": "2.0.0",
73
+ "@modelcontextprotocol/server": "2.0.0",
39
74
  "@vscode/ripgrep": "^1.18.0",
40
75
  "@zvec/zvec": "^0.5.0",
41
76
  "tree-sitter-wasms": "^0.1.13",
42
- "web-tree-sitter": "^0.20.8"
77
+ "web-tree-sitter": "^0.20.8",
78
+ "zod": "4.2.0"
43
79
  },
44
80
  "optionalDependencies": {
45
81
  "node-llama-cpp": "3.18.1"
@@ -1,141 +1,61 @@
1
1
  ---
2
2
  name: zvec-grep
3
- description: Use zvec-grep instead of grep or rg: check the index state once per repository investigation when needed, use existing indexed context when available, and use explicit zg --rg for lexical search when no index exists unless the user asks to build an index.
3
+ description: Repository code search and indexing with zvec-grep. Use when exploring a codebase, locating symbols, references, or exact text, creating or inspecting a repository index, diagnosing the daemon, or whenever repository investigation would otherwise use grep, rg, or broad file reads.
4
4
  ---
5
5
 
6
6
  # zvec-grep
7
7
 
8
- Use zvec-grep through the `zg` command for repository search instead of `grep`, `rg`, or broad manual file scans. zvec-grep provides higher-quality results by combining indexed semantic context with lexical matching, while `zg --rg` provides an explicit no-index lexical search route.
8
+ ## Select the transport
9
9
 
10
- At the start of a repository investigation, check the current repository's anonymous index status once:
10
+ Use zvec-grep indexed search for conceptual repository investigation. Use native
11
+ `grep` or `rg` for exact lexical searches unless the optional managed-rg MCP tool
12
+ is explicitly available.
11
13
 
12
- ```bash
13
- zg --status
14
- ```
14
+ Use the public native HTTP MCP search tools as the primary interface when the matching `zvec_grep_*` tool is present. Call them directly; do not run `zg`, probe the daemon through shell, or choose CLI for convenience.
15
15
 
16
- Do not run `zg --status` before every search. Reuse the initial status for subsequent `zg` queries in the same root. Check again only when switching roots or collections, after an index/rebuild, or when a query reports an index problem that you need to diagnose.
16
+ Use CLI fallback only when one of these conditions is true:
17
17
 
18
- If the index is missing, do not build it automatically and do not run a default `zg "<query>"` search. Use `zg --rg` for explicit exhaustive literal/regex search, and mention `zg --index` when the user wants persistent indexed semantic search. Indexing creates repository-local state, may load local models or call remote embedding providers, and should be a user-owned action.
18
+ - The task requires index lifecycle or daemon diagnostics, which are intentionally
19
+ kept out of the default agent MCP toolset.
20
+ - An available MCP search tool cannot perform the required operation.
21
+ - MCP initialization, authentication, connection, or the required search call has
22
+ failed.
23
+ - The repository has no index, the user has not authorized indexing, and an explicit no-index lexical search is needed.
19
24
 
20
- When indexing or rebuilding, choose useful repo paths instead of indexing everything. Prefer source, tests, docs, config, and scripts. zvec-grep skips dependency, third-party, generated, build, cache, hidden, nested-git, `.gitignore`d, and over-1MB files by default; use `--include` and `--exclude` to further keep the index focused:
25
+ Do not retry a submitted indexing write through another transport after a connection interruption.
21
26
 
22
- ```bash
23
- zg --index --embedding local/embeddinggemma-300m --include "src/**" --include "docs/**" --include "test/**" --exclude "dist/**,node_modules/**,coverage/**,.zvec-grep/**"
24
- zg --index --rebuild --embedding local/embeddinggemma-300m --include "src/**" --exclude "dist/**,node_modules/**,coverage/**,.zvec-grep/**"
25
- ```
27
+ ## Use the MCP workflow
26
28
 
27
- If `zg --status` reports incompatible settings, ask before rebuilding. Existing anonymous indexes are checked and incrementally refreshed by query commands by default; use `--no-auto-update` only when diagnosing stale-index behavior. Rebuild only when the embedding schema or index version requires it:
29
+ Pass the repository's daemon-visible absolute path as `root` on every repository call.
28
30
 
29
- ```bash
30
- zg --index --rebuild --embedding local/embeddinggemma-300m
31
- ```
31
+ 1. Use native `grep` or `rg` when an exact keyword, text, symbol, filename,
32
+ path, configuration key, error message, source fragment, literal, or regex
33
+ anchor is known and locating it is sufficient to answer the question.
34
+ 2. Call `zvec_grep_search` when the answer requires conceptual discovery,
35
+ architecture, lifecycle, data or control flow, comparison, design rationale,
36
+ or performance analysis. Search defaults to `freshness: "eventual"`; use
37
+ `freshness: "wait_for_fresh"` only when the result must include all pending
38
+ changes. Use hybrid `queries` for concepts plus known lexical constraints,
39
+ `fts` for indexed lexical-only intent, and `vector` for semantic-only intent.
40
+ 3. When exact symbols are present but the answer spans multiple components,
41
+ files, stages, or implementations, call `zvec_grep_search` first with the
42
+ concept and known symbols, then use native `grep` or `rg` for focused follow-up.
43
+ 4. Read the indexed search response's `freshness` and `indexing` fields. Use
44
+ `possibly_stale` results immediately when they are sufficient; do not call
45
+ status merely because a background update is active.
46
+ 5. Apply focused path and file-type filters early. Exclude dependencies,
47
+ generated output, caches, build artifacts, fixtures, and logs unless the
48
+ task concerns them.
32
49
 
33
- After an anonymous index exists, start with high-quality semantic context:
50
+ The default public MCP endpoint intentionally exposes only indexed search. If the
51
+ index is missing, explain that indexed search requires an index and ask before
52
+ creating one. After authorization, use the CLI lifecycle workflow; never silently
53
+ create, rebuild, or drop an index. The optional full MCP toolset exposes
54
+ `zvec_grep_rg`; the CLI `zg query --rg` route remains available for explicit
55
+ managed-ripgrep fallback.
34
56
 
35
- ```bash
36
- zg "<query>"
37
- ```
57
+ Use multiple queries when comparing related concepts.
38
58
 
39
- Prefer the default indexed/hybrid search for exploration. Agent output uses `--preview none` by default to keep results token-efficient; `--human` uses `--preview full` by default for terminal reading. Use `--limit` to control candidate width, `--preview short` for a small deterministic source window, and `--preview full` after narrowing to a few results.
59
+ ## Use CLI fallback
40
60
 
41
- Use filters early. For source-code investigations, start with implementation paths and exclude tests, fixtures, generated output, dependencies, and build artifacts unless the task is specifically about those areas. Good filters keep candidate sets smaller and reduce token use:
42
-
43
- ```bash
44
- zg "plugin loading lifecycle" --include "src/**" --exclude "test/**,tests/**,**/*.test.*,**/*.spec.*,fixtures/**,dist/**"
45
- zg "query planning" --include "src/**,packages/*/src/**" --exclude "test/**,tests/**,fixtures/**,node_modules/**,dist/**"
46
- ```
47
-
48
- Indexed agent results use `--preview none` by default: essential metadata plus one representative source line when source is available. Human results use `--preview full` by default. Use `--preview short` for essential metadata plus a small deterministic source window, or `--preview full` after narrowing to a few results. `--preview` is for indexed/semantic results; with `--rg`, use ripgrep context flags such as `-A`, `-B`, or `-C` instead.
49
-
50
- ```bash
51
- zg "plugin loading" --limit 30 --preview none
52
- zg "plugin loading" --limit 10 --preview short
53
- zg "plugin loading" --limit 3 --preview full
54
- ```
55
-
56
- Use multiple quoted queries when you are exploring related ideas or comparing several names/concepts. Each query gets its own search group, and `--limit` applies per query/group:
57
-
58
- ```bash
59
- zg "request validation" "error handling"
60
- zg "authentication flow" "session refresh" "permission checks" --limit 5
61
- ```
62
-
63
- Use `zg --rg` only when you need exhaustive literal/regex search, exact verification, or ripgrep-specific flags. For exploratory code understanding, prefer default `zg` indexed search first:
64
-
65
- ```bash
66
- zg --rg "SymbolName|LogMessage"
67
- zg --rg -F "ExactSymbolOrText" src
68
- zg --rg -i -C 2 -g "*.ts" -g "!dist/**" "needle text" src
69
- ```
70
-
71
- Do not call `grep` or `rg` directly for repository search. If exhaustive regex or literal matching is required, use `zg --rg`; otherwise keep using default `zg` indexed search to avoid noisy, token-heavy match lists.
72
-
73
- Check the local anonymous index explicitly only when starting a repository investigation or diagnosing index state. Build it only when the user asks for persistent indexed semantic search:
74
-
75
- ```bash
76
- zg --status
77
- zg --index --embedding local/embeddinggemma-300m
78
- zg --index --rebuild --embedding local/embeddinggemma-300m
79
- ```
80
-
81
- For a new index, always pass `--embedding <model>` or set `ZVEC_GREP_EMBEDDING`; `zg --index` does not choose a model silently. For an existing index, rerunning `zg --index` without `--embedding` reuses the collection's stored embedding schema. Use `--embedding <model>` when intentionally choosing or changing models. Local models use `local/model`, such as `local/embeddinggemma-300m` and `local/qwen3-embedding-0.6b`. Remote models use `provider/model`, such as `qwen/text-embedding-v4`.
82
-
83
- ```bash
84
- zg --index --embedding local/qwen3-embedding-0.6b
85
- zg --index --embedding qwen/text-embedding-v4 --api-key "$DASHSCOPE_API_KEY"
86
- ```
87
-
88
- Use explicit routes only when the intent is clear:
89
-
90
- ```bash
91
- zg --fts "ExactSymbolOrToken"
92
- zg --vector "natural language description of the code you need"
93
- zg --fts "AuthService" "validateRequest" --vector "where incoming requests are authorized"
94
- ```
95
-
96
- Combine default hybrid queries with `--fts` when you want broad semantic/lexical recall plus exact anchors such as symbols, flags, error codes, or log text. Put the default hybrid queries first, then add one or more `--fts` terms:
97
-
98
- ```bash
99
- zg "authentication flow" --fts "AuthService" --include "src/**"
100
- zg "cache invalidation" "stale data handling" --fts "CACHE_TTL" "invalidateCache" --limit 5
101
- zg "request routing behavior" --fts "routeRequest" "RouteOptions" --include "src/**"
102
- ```
103
-
104
- Use query filters to narrow noisy searches before reading results. Prefer adding `--include` and `--exclude` to the first query when you already know the relevant area:
105
-
106
- ```bash
107
- zg "error handling" --include "src/**" --exclude "dist/**,node_modules/**"
108
- zg "database migration" --include "src/**" --exclude "**/*.test.*"
109
- zg "recent API changes" --modified-after 2026-06-01 --modified-before 2026-06-25
110
- zg "create user" --symbol-type function --prefer-symbol
111
- zg "service lifecycle" "resource cleanup" --symbol-type class --symbol-type function --limit 5
112
- ```
113
-
114
- Filter notes:
115
-
116
- - Quote glob filters so the shell does not expand them.
117
- - `--include` and `--exclude` accept comma-separated globs and can be repeated.
118
- - Dependency, third-party, generated, build, cache, nested-git, `.gitignore`d, and over-1MB files are skipped during indexing by default. Hidden dot paths are skipped by default; explicitly include useful hidden paths such as `.github/**`, `.codex/**`, or `.agents/**` with `--include` when needed. `.git/**` and `.zvec-grep/**` remain excluded.
119
- - `--modified-after` and `--modified-before` accept epoch milliseconds, `YYYY-MM-DD`, or other parseable date strings.
120
- - `--symbol-type` can be repeated; supported values are `module`, `class`, `interface`, `function`, `value`, and `alias`.
121
- - `--prefer-symbol` is useful when a query names a symbol and you want exact indexed symbol hits ranked first.
122
- - `--rg` is for exhaustive ripgrep search; do not combine it with indexed symbol options such as `--symbol-type` or `--prefer-symbol`. It uses rg regex syntax by default, so use `-F`/`--fixed-strings` for literal text, and use `-e`/`--regexp` when the pattern begins with `-`. It accepts common agent rg flags: `-n`, `-H`, `-F`, `-i`, `-w`, `-A`, `-B`, `-C`, `-e`/`--regexp`, `-g`/`--glob`, `--hidden`, `-t`/`--type`, `-T`/`--type-not`, `--max-depth`, `--ignore-file`, `--no-ignore`, `--smart-case`, and `--pcre2`. In `--rg`, `--limit` is a global match limit.
123
-
124
- Combine multiple queries, explicit routes, and filters for focused context:
125
-
126
- ```bash
127
- zg "authorization failure" "permission checks" \
128
- --fts "ForbiddenError" "hasPermission" \
129
- --include "src/**" \
130
- --exclude "dist/**,**/*.test.*" \
131
- --symbol-type function \
132
- --limit 5
133
- ```
134
-
135
- Read output as:
136
-
137
- - `path:start-end` is the returned entity.
138
- - `outline:` is generated structure or call summary.
139
- - `matched:` is the matching excerpt range inside the entity or `--rg` context block.
140
- - `source:` is original file text for indexed results. `--rg` results omit the `source:` label and print numbered matching lines directly under `path:start-end`.
141
- - `--preview none` omits `outline:`, `matched:`, and `source:` blocks but keeps metadata and one representative numbered source line when source is available.
61
+ Read [references/cli-fallback.md](references/cli-fallback.md) only after a fallback condition above is satisfied. Leave CLI mode unset for status, fallback search, and authorized indexing commands so the default Auto mode can select Server or Direct; do not probe forced Server mode and then retry forced Direct mode. Keep the selected transport consistent for the investigation unless its availability changes.
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "zvec-grep"
3
- short_description: "Agent-friendly indexed repository search"
4
- default_prompt: "Use zvec-grep through the zg command instead of grep or rg: check zg --status once at the start of a repository investigation when needed, then reuse that status for later searches in the same root; when indexing or rebuilding the local index, use --include and --exclude to index useful source/docs/tests/config/scripts and exclude generated, dependency, cache, build, log, and .zvec-grep garbage; prefer default zg indexed/hybrid queries for high-quality, token-efficient context; use --preview none for broad candidate scans and --preview full only after narrowing; use filters early, especially --include implementation paths and --exclude tests/fixtures/generated output when the task is about source code; use multiple quoted queries for related concepts; combine default hybrid queries with --fts exact anchors for symbols/flags/errors; narrow noisy searches with --include/--exclude/--modified-after/--modified-before/--symbol-type/--prefer-symbol; and use zg --rg only for exhaustive literal/regex verification with common rg flags such as -F, -i, -w, -A/-B/-C, -e/--regexp, -g/--glob, --hidden, --type, --type-not, --no-ignore, --smart-case, and --pcre2; use -e/--regexp when an rg pattern begins with -."
3
+ short_description: "Repository search with explicit index lifecycle"
4
+ default_prompt: "Use $zvec-grep to investigate this repository before raw grep or rg. Prefer the public MCP search tools, and use the zg CLI only for authorized index lifecycle or daemon diagnostics."
@@ -0,0 +1,85 @@
1
+ # CLI fallback
2
+
3
+ Use these commands only when the native MCP tools are unavailable or when an explicit no-index lexical search is required.
4
+
5
+ ## Choose the route
6
+
7
+ Leave `--mode` unset for ordinary status and query commands. The default Auto mode uses the daemon when reachable and Direct mode otherwise:
8
+
9
+ ```bash
10
+ zg status
11
+ zg query "authentication flow" --fts "AuthService" -g "src/**" -g "!tests/**" -g "!dist/**"
12
+ ```
13
+
14
+ Do not probe with `--mode server` and then retry with `--mode direct`. Use an explicit mode only when diagnosing routing or when the user requests one. Do not force Direct writes while a daemon lease is active.
15
+
16
+ ## Check index state
17
+
18
+ Check status once per repository investigation and reuse it:
19
+
20
+ ```bash
21
+ zg status
22
+ ```
23
+
24
+ If the index is missing, do not build it automatically. Mention `zg index` and wait for the user to authorize persistent indexing.
25
+
26
+ ## Search an existing index
27
+
28
+ Start with indexed hybrid search, then add exact or semantic routes as needed:
29
+
30
+ ```bash
31
+ zg query "request validation" "error handling" -g "src/**" -g "!tests/**" -g "!dist/**" --limit 10 --preview short
32
+ zg query "authentication flow" --fts "AuthService" --fts "ForbiddenError" -g "src/**"
33
+ zg query --vector "where incoming requests are authorized" -g "src/**"
34
+ zg query "changes that must be indexed before search" --refresh wait
35
+ ```
36
+
37
+ When Auto selects Server, queries return the current index and refresh stale data in the background by default. Direct queries do not refresh by default. Add `--refresh wait` when the query must wait for pending index changes, or `--refresh off` to disable refresh explicitly. Use `--preview none` for broad candidate scans, `--preview short` for a small deterministic window, and `--preview full` only after narrowing.
38
+
39
+ ## Recover from a Direct model failure
40
+
41
+ Direct mode already attempts CPU fallback when local GPU initialization fails. Do not repeat the query with an explicit CPU override.
42
+
43
+ If the local model or embedding context remains unavailable and exact anchors are available, remove positional hybrid and vector queries and search those anchors through the existing indexed FTS route. Indexed FTS does not require an embedding model:
44
+
45
+ ```bash
46
+ zg query --fts "AuthService" --fts "ForbiddenError" -g "src/**" --limit 20 --preview short
47
+ ```
48
+
49
+ Do not switch to managed ripgrep merely because semantic search is unavailable. Use it only when the task requires exhaustive literal or regex matching, or when no index exists and the user has not authorized creating one.
50
+
51
+ ## Search exhaustively with managed ripgrep
52
+
53
+ Use managed ripgrep only for exhaustive literal or regex matching; it does not require an index:
54
+
55
+ ```bash
56
+ zg query --rg "SymbolName|LogMessage"
57
+ zg query --rg -F "ExactSymbolOrText" src
58
+ zg query --rg -i -C 2 -g "*.ts" -g "!dist/**" "needle text" src
59
+ ```
60
+
61
+ Managed ripgrep always runs locally. It remains available while the daemon is running or an index writer is active; do not stop the daemon or switch client mode before using it.
62
+
63
+ Use `-e` or `--regexp` when the pattern begins with `-`. Common ripgrep flags include `-n`, `-H`, `-F`, `-i`, `-w`, `-A`, `-B`, `-C`, `-g`, `--hidden`, `--type`, `--type-not`, `--no-ignore`, `--smart-case`, and `--pcre2`.
64
+
65
+ ## Index only with authorization
66
+
67
+ When a server default model is known, let Auto submit the index without repeating the model:
68
+
69
+ ```bash
70
+ zg index
71
+ ```
72
+
73
+ Otherwise, use the embedding model selected by the user:
74
+
75
+ ```bash
76
+ zg index --embedding local/embeddinggemma-300m
77
+ ```
78
+
79
+ Use focused path filters for a new index:
80
+
81
+ ```bash
82
+ zg index --embedding local/embeddinggemma-300m -g "src/**" -g "docs/**" -g "test/**" -g "!dist/**" -g "!node_modules/**" -g "!coverage/**"
83
+ ```
84
+
85
+ Rebuild only when an incompatible embedding schema or index version requires it. Existing indexes reuse their stored embedding schema unless the user intentionally changes it.
@@ -1,55 +0,0 @@
1
- import type { EmbeddingModel } from "../models/embeddings.js";
2
- import type { StoredEntity } from "../storage/index.js";
3
- import type { CollectionEmbeddingSchema, CollectionIndexStatus, CollectionInfo, EntitySearchDiagnosis, FileDiagnosis, FileInfo, IndexOptions, IndexResult, RootPath, SearchPlan, SearchPlanResult } from "../types.js";
4
- export declare class Collection {
5
- readonly info: CollectionInfo;
6
- private readonly embeddingModel?;
7
- private readonly readOnly;
8
- private readonly fileStorePath;
9
- private readonly storage;
10
- private readonly embedding;
11
- constructor(info: CollectionInfo, embeddingModel?: EmbeddingModel | undefined, readOnly?: boolean, fileStorePath?: string);
12
- get id(): string;
13
- get name(): string;
14
- index(options?: IndexOptions): Promise<IndexResult>;
15
- status(): Promise<CollectionIndexStatus>;
16
- searchPlan(plan: SearchPlan): Promise<SearchPlanResult>;
17
- diagnoseFile(absolutePath: string): FileDiagnosis;
18
- diagnoseEntitySearch(query: string, entityId: string): Promise<EntitySearchDiagnosis>;
19
- diagnoseFileSearch(query: string, absolutePath: string): Promise<EntitySearchDiagnosis | null>;
20
- getFile(absolutePath: string): FileInfo | null;
21
- listEntitiesByFile(fileId: string, options?: {
22
- limit?: number;
23
- offset?: number;
24
- }): StoredEntity[];
25
- getEntity(entityId: string): StoredEntity | null;
26
- close(): void;
27
- private validateIndexVersion;
28
- private validateEmbeddingSchema;
29
- private requireEmbeddingModel;
30
- }
31
- export declare function isCollectionIndexed(info: CollectionInfo | null | undefined): info is CollectionInfo & {
32
- embedding: CollectionEmbeddingSchema;
33
- indexVersion: number;
34
- };
35
- export declare class CollectionRegistry {
36
- readonly home: string;
37
- private readonly embeddingModel?;
38
- private readonly readOnly;
39
- private readonly meta;
40
- private readonly collections;
41
- constructor(home?: string, embeddingModel?: EmbeddingModel | undefined, readOnly?: boolean);
42
- list(): CollectionInfo[];
43
- get(name: string): CollectionInfo | null;
44
- has(name: string): boolean;
45
- remove(name: string): boolean;
46
- rename(name: string, nextName: string): CollectionInfo | null;
47
- status(name: string): Promise<CollectionIndexStatus | null>;
48
- create(name: string, rootPaths: readonly (string | RootPath)[], path?: string): CollectionInfo;
49
- prepareIndex(name: string, rootPaths: readonly (string | RootPath)[], path?: string): CollectionInfo;
50
- disableIndex(name: string, rootPaths: readonly (string | RootPath)[], path?: string): CollectionInfo;
51
- updateRootPaths(name: string, rootPaths: readonly (string | RootPath)[]): CollectionInfo | null;
52
- open(name: string): Collection;
53
- close(): void;
54
- }
55
- export declare function defaultCollectionName(path: string): string;