@zvec/zvec-grep 0.1.5 → 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.
- package/README.md +88 -249
- package/README_CN.md +82 -246
- package/dist/authorization/index.d.ts +7 -0
- package/dist/authorization/index.js +7 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/manager.d.ts +8 -0
- package/dist/authorization/manager.js +19 -0
- package/dist/authorization/manager.js.map +1 -0
- package/dist/authorization/operation.d.ts +7 -0
- package/dist/authorization/operation.js +50 -0
- package/dist/authorization/operation.js.map +1 -0
- package/dist/authorization/planner.d.ts +21 -0
- package/dist/authorization/planner.js +97 -0
- package/dist/authorization/planner.js.map +1 -0
- package/dist/authorization/prompt.d.ts +11 -0
- package/dist/authorization/prompt.js +62 -0
- package/dist/authorization/prompt.js.map +1 -0
- package/dist/authorization/store.d.ts +20 -0
- package/dist/authorization/store.js +251 -0
- package/dist/authorization/store.js.map +1 -0
- package/dist/authorization/target.d.ts +15 -0
- package/dist/authorization/target.js +49 -0
- package/dist/authorization/target.js.map +1 -0
- package/dist/authorization/types.d.ts +61 -0
- package/dist/authorization/types.js +2 -0
- package/dist/authorization/types.js.map +1 -0
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.js +304 -54
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth.d.ts +21 -0
- package/dist/cli/auth.js +212 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/commands.js +433 -618
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/errors.js +2 -2
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/format/context.d.ts +1 -0
- package/dist/cli/format/context.js +241 -45
- package/dist/cli/format/context.js.map +1 -1
- package/dist/cli/format/debug.js +2 -2
- package/dist/cli/format/debug.js.map +1 -1
- package/dist/cli/format/progress.d.ts +4 -0
- package/dist/cli/format/progress.js +219 -46
- package/dist/cli/format/progress.js.map +1 -1
- package/dist/cli/format/status.d.ts +77 -6
- package/dist/cli/format/status.js +302 -106
- package/dist/cli/format/status.js.map +1 -1
- package/dist/cli/help.js +258 -59
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/cli/install.d.ts +4 -0
- package/dist/cli/install.js +845 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/managed-rg.d.ts +10 -0
- package/dist/cli/managed-rg.js +329 -0
- package/dist/cli/managed-rg.js.map +1 -0
- package/dist/cli/types.d.ts +20 -6
- package/dist/cli/types.js.map +1 -1
- package/dist/client/daemon-client.d.ts +19 -0
- package/dist/client/daemon-client.js +180 -0
- package/dist/client/daemon-client.js.map +1 -0
- package/dist/client/mode-router.d.ts +9 -0
- package/dist/client/mode-router.js +28 -0
- package/dist/client/mode-router.js.map +1 -0
- package/dist/client/search-policy.d.ts +11 -0
- package/dist/client/search-policy.js +15 -0
- package/dist/client/search-policy.js.map +1 -0
- package/dist/daemon/backend.d.ts +76 -0
- package/dist/daemon/backend.js +1049 -0
- package/dist/daemon/backend.js.map +1 -0
- package/dist/daemon/change-set.d.ts +25 -0
- package/dist/daemon/change-set.js +101 -0
- package/dist/daemon/change-set.js.map +1 -0
- package/dist/daemon/config.d.ts +24 -0
- package/dist/daemon/config.js +88 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/errors.d.ts +5 -0
- package/dist/daemon/errors.js +11 -0
- package/dist/daemon/errors.js.map +1 -0
- package/dist/daemon/http-server.d.ts +30 -0
- package/dist/daemon/http-server.js +287 -0
- package/dist/daemon/http-server.js.map +1 -0
- package/dist/daemon/index-coordinator.d.ts +23 -0
- package/dist/daemon/index-coordinator.js +68 -0
- package/dist/daemon/index-coordinator.js.map +1 -0
- package/dist/daemon/job-scheduler.d.ts +70 -0
- package/dist/daemon/job-scheduler.js +366 -0
- package/dist/daemon/job-scheduler.js.map +1 -0
- package/dist/daemon/logger.d.ts +9 -0
- package/dist/daemon/logger.js +53 -0
- package/dist/daemon/logger.js.map +1 -0
- package/dist/daemon/model-pool.d.ts +45 -0
- package/dist/daemon/model-pool.js +187 -0
- package/dist/daemon/model-pool.js.map +1 -0
- package/dist/daemon/root-lease.d.ts +14 -0
- package/dist/daemon/root-lease.js +188 -0
- package/dist/daemon/root-lease.js.map +1 -0
- package/dist/daemon/root-runtime.d.ts +78 -0
- package/dist/daemon/root-runtime.js +333 -0
- package/dist/daemon/root-runtime.js.map +1 -0
- package/dist/daemon/runtime-manager.d.ts +45 -0
- package/dist/daemon/runtime-manager.js +243 -0
- package/dist/daemon/runtime-manager.js.map +1 -0
- package/dist/daemon/runtime.d.ts +12 -0
- package/dist/daemon/runtime.js +102 -0
- package/dist/daemon/runtime.js.map +1 -0
- package/dist/daemon/server-controller.d.ts +39 -0
- package/dist/daemon/server-controller.js +203 -0
- package/dist/daemon/server-controller.js.map +1 -0
- package/dist/daemon/watch-manager.d.ts +50 -0
- package/dist/daemon/watch-manager.js +293 -0
- package/dist/daemon/watch-manager.js.map +1 -0
- package/dist/daemon/workspace-read-session-cache.d.ts +31 -0
- package/dist/daemon/workspace-read-session-cache.js +115 -0
- package/dist/daemon/workspace-read-session-cache.js.map +1 -0
- package/dist/engine/config.d.ts +30 -8
- package/dist/engine/config.js +171 -45
- package/dist/engine/config.js.map +1 -1
- package/dist/engine/{errors/index.d.ts → errors.d.ts} +6 -1
- package/dist/engine/{errors/details.js → errors.js} +17 -4
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/extraction/code/adapter.d.ts +1 -1
- package/dist/engine/extraction/code/extractor.d.ts +5 -11
- package/dist/engine/extraction/code/extractor.js +105 -44
- package/dist/engine/extraction/code/extractor.js.map +1 -1
- package/dist/engine/extraction/code/families/c-family.js +1 -1
- package/dist/engine/extraction/code/families/c-family.js.map +1 -1
- package/dist/engine/extraction/code/families/js-ts.d.ts +1 -1
- package/dist/engine/extraction/code/families/metadata.d.ts +1 -1
- package/dist/engine/extraction/code/tree-sitter/grammar.js.map +1 -0
- package/dist/engine/extraction/code/tree-sitter/nodes.js.map +1 -0
- package/dist/engine/extraction/code/tree-sitter/parser.js.map +1 -0
- package/dist/engine/extraction/image/extractor.d.ts +5 -0
- package/dist/engine/extraction/image/extractor.js +35 -0
- package/dist/engine/extraction/image/extractor.js.map +1 -0
- package/dist/engine/extraction/index.d.ts +3 -44
- package/dist/engine/extraction/index.js +1 -280
- package/dist/engine/extraction/index.js.map +1 -1
- package/dist/engine/extraction/markdown/extractor.d.ts +5 -11
- package/dist/engine/extraction/markdown/extractor.js +35 -16
- package/dist/engine/extraction/markdown/extractor.js.map +1 -1
- package/dist/engine/extraction/runtime.d.ts +4 -0
- package/dist/engine/extraction/runtime.js +26 -0
- package/dist/engine/extraction/runtime.js.map +1 -0
- package/dist/engine/extraction/source.d.ts +18 -0
- package/dist/engine/extraction/source.js +22 -0
- package/dist/engine/extraction/source.js.map +1 -0
- package/dist/engine/extraction/text/extractor.d.ts +7 -0
- package/dist/engine/extraction/text/extractor.js +168 -0
- package/dist/engine/extraction/text/extractor.js.map +1 -0
- package/dist/engine/extraction/types.d.ts +4 -0
- package/dist/engine/{models → extraction}/types.js.map +1 -1
- package/dist/engine/{files/file-type.d.ts → file-type.d.ts} +1 -1
- package/dist/engine/file-type.js.map +1 -0
- package/dist/engine/index-status.d.ts +9 -0
- package/dist/engine/index-status.js +38 -0
- package/dist/engine/index-status.js.map +1 -0
- package/dist/engine/manifest.d.ts +12 -0
- package/dist/engine/manifest.js +120 -0
- package/dist/engine/manifest.js.map +1 -0
- package/dist/engine/models/{providers/llama-cpp/embedding.d.ts → backends/llama-cpp.d.ts} +25 -20
- package/dist/engine/models/{providers/llama-cpp/embedding.js → backends/llama-cpp.js} +127 -106
- package/dist/engine/models/backends/llama-cpp.js.map +1 -0
- package/dist/engine/models/backends/model2vec.d.ts +57 -0
- package/dist/engine/models/backends/model2vec.js +332 -0
- package/dist/engine/models/backends/model2vec.js.map +1 -0
- package/dist/engine/models/backends/qwen.d.ts +44 -0
- package/dist/engine/models/{providers/qwen/embedding.js → backends/qwen.js} +155 -94
- package/dist/engine/models/backends/qwen.js.map +1 -0
- package/dist/engine/models/backends/transformers-js.d.ts +87 -0
- package/dist/engine/models/backends/transformers-js.js +316 -0
- package/dist/engine/models/backends/transformers-js.js.map +1 -0
- package/dist/engine/models/catalog.d.ts +188 -23
- package/dist/engine/models/catalog.js +172 -25
- package/dist/engine/models/catalog.js.map +1 -1
- package/dist/engine/models/download-progress.d.ts +15 -0
- package/dist/engine/models/download-progress.js +48 -0
- package/dist/engine/models/download-progress.js.map +1 -0
- package/dist/engine/models/embeddings.d.ts +58 -18
- package/dist/engine/models/embeddings.js +52 -28
- package/dist/engine/models/embeddings.js.map +1 -1
- package/dist/engine/models/factory.d.ts +2 -5
- package/dist/engine/models/factory.js +41 -56
- package/dist/engine/models/factory.js.map +1 -1
- package/dist/engine/models/index.d.ts +4 -6
- package/dist/engine/models/index.js +4 -4
- package/dist/engine/models/index.js.map +1 -1
- package/dist/engine/models/ranking.d.ts +7 -3
- package/dist/engine/models/resolution.d.ts +8 -0
- package/dist/engine/models/resolution.js +22 -0
- package/dist/engine/models/resolution.js.map +1 -0
- package/dist/engine/pipeline/indexing/index.d.ts +9 -7
- package/dist/engine/pipeline/indexing/index.js +360 -121
- package/dist/engine/pipeline/indexing/index.js.map +1 -1
- package/dist/engine/pipeline/indexing/root-paths.js +6 -6
- package/dist/engine/pipeline/indexing/root-paths.js.map +1 -1
- package/dist/engine/pipeline/indexing/scanner/index.d.ts +6 -1
- package/dist/engine/pipeline/indexing/scanner/index.js +233 -29
- package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
- package/dist/engine/pipeline/search/index.d.ts +6 -6
- package/dist/engine/pipeline/search/index.js +8 -10
- package/dist/engine/pipeline/search/index.js.map +1 -1
- package/dist/engine/service/index.d.ts +3 -2
- package/dist/engine/service/index.js +1 -1
- package/dist/engine/service/index.js.map +1 -1
- package/dist/engine/service/root.d.ts +13 -12
- package/dist/engine/service/root.js +35 -24
- package/dist/engine/service/root.js.map +1 -1
- package/dist/engine/service/structure-enrichment.js +12 -14
- package/dist/engine/service/structure-enrichment.js.map +1 -1
- package/dist/engine/service/types.d.ts +32 -37
- package/dist/engine/service/workspace-index.d.ts +24 -0
- package/dist/engine/service/workspace-index.js +151 -0
- package/dist/engine/service/workspace-index.js.map +1 -0
- package/dist/engine/service/zvec-grep.d.ts +12 -1
- package/dist/engine/service/zvec-grep.js +677 -486
- package/dist/engine/service/zvec-grep.js.map +1 -1
- package/dist/engine/storage/index.d.ts +8 -4
- package/dist/engine/storage/index.js +1 -1
- package/dist/engine/storage/index.js.map +1 -1
- package/dist/engine/storage/zvec.d.ts +10 -33
- package/dist/engine/storage/zvec.js +95 -38
- package/dist/engine/storage/zvec.js.map +1 -1
- package/dist/engine/types.d.ts +15 -23
- package/dist/engine/types.js +1 -1
- package/dist/engine/types.js.map +1 -1
- package/dist/engine/utils/daemon-lease.d.ts +17 -0
- package/dist/engine/utils/daemon-lease.js +175 -0
- package/dist/engine/utils/daemon-lease.js.map +1 -0
- package/dist/engine/utils/file-selection.js +38 -1
- package/dist/engine/utils/file-selection.js.map +1 -1
- package/dist/engine/utils/lock.js +1 -1
- package/dist/engine/utils/lock.js.map +1 -1
- package/dist/index-progress.d.ts +10 -0
- package/dist/index-progress.js +159 -0
- package/dist/index-progress.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/http-transport.d.ts +27 -0
- package/dist/mcp/http-transport.js +182 -0
- package/dist/mcp/http-transport.js.map +1 -0
- package/dist/mcp/input-normalization.d.ts +38 -0
- package/dist/mcp/input-normalization.js +95 -0
- package/dist/mcp/input-normalization.js.map +1 -0
- package/dist/mcp/progress-heartbeat.d.ts +17 -0
- package/dist/mcp/progress-heartbeat.js +46 -0
- package/dist/mcp/progress-heartbeat.js.map +1 -0
- package/dist/mcp/request-metadata.d.ts +2 -0
- package/dist/mcp/request-metadata.js +11 -0
- package/dist/mcp/request-metadata.js.map +1 -0
- package/dist/mcp/request-state.d.ts +40 -0
- package/dist/mcp/request-state.js +210 -0
- package/dist/mcp/request-state.js.map +1 -0
- package/dist/mcp/result-format.d.ts +13 -0
- package/dist/mcp/result-format.js +75 -0
- package/dist/mcp/result-format.js.map +1 -0
- package/dist/mcp/schemas.d.ts +430 -0
- package/dist/mcp/schemas.js +447 -0
- package/dist/mcp/schemas.js.map +1 -0
- package/dist/mcp/tools.d.ts +150 -0
- package/dist/mcp/tools.js +448 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/toolset.d.ts +5 -0
- package/dist/mcp/toolset.js +12 -0
- package/dist/mcp/toolset.js.map +1 -0
- package/dist/observability/trace-context.d.ts +11 -0
- package/dist/observability/trace-context.js +138 -0
- package/dist/observability/trace-context.js.map +1 -0
- package/docs/01-agents.md +111 -0
- package/docs/02-cli.md +229 -0
- package/docs/03-mcp.md +167 -0
- package/docs/04-pipeline.md +218 -0
- package/docs/05-architecture.md +86 -0
- package/docs/06-server.md +210 -0
- package/docs/07-embedding.md +179 -0
- package/docs/08-roadmap.md +85 -0
- package/docs/README.md +53 -0
- package/package.json +17 -8
- package/skills/zvec-grep/SKILL.md +43 -133
- package/skills/zvec-grep/agents/openai.yaml +2 -2
- package/skills/zvec-grep/references/cli-fallback.md +85 -0
- package/dist/cli/mcp.d.ts +0 -2
- package/dist/cli/mcp.js +0 -354
- package/dist/cli/mcp.js.map +0 -1
- package/dist/engine/collection/index.d.ts +0 -55
- package/dist/engine/collection/index.js +0 -710
- package/dist/engine/collection/index.js.map +0 -1
- package/dist/engine/errors/details.d.ts +0 -6
- package/dist/engine/errors/details.js.map +0 -1
- package/dist/engine/errors/index.js +0 -16
- package/dist/engine/errors/index.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/grammar.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/nodes.js.map +0 -1
- package/dist/engine/extraction/tree-sitter/parser.js.map +0 -1
- package/dist/engine/files/file-type.js.map +0 -1
- package/dist/engine/models/providers/index.d.ts +0 -2
- package/dist/engine/models/providers/index.js +0 -3
- package/dist/engine/models/providers/index.js.map +0 -1
- package/dist/engine/models/providers/llama-cpp/embedding.js.map +0 -1
- package/dist/engine/models/providers/llama-cpp/index.d.ts +0 -1
- package/dist/engine/models/providers/llama-cpp/index.js +0 -2
- package/dist/engine/models/providers/llama-cpp/index.js.map +0 -1
- package/dist/engine/models/providers/qwen/embedding.d.ts +0 -42
- package/dist/engine/models/providers/qwen/embedding.js.map +0 -1
- package/dist/engine/models/providers/qwen/index.d.ts +0 -1
- package/dist/engine/models/providers/qwen/index.js +0 -2
- package/dist/engine/models/providers/qwen/index.js.map +0 -1
- package/dist/engine/models/types.d.ts +0 -30
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.js +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.js +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.d.ts +0 -0
- /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.js +0 -0
- /package/dist/engine/{models → extraction}/types.js +0 -0
- /package/dist/engine/{files/file-type.js → file-type.js} +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Retrieval pipeline
|
|
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
|
+
zg provides one search layer across semantic discovery, ranked lexical search,
|
|
9
|
+
and exhaustive ripgrep. The normal flow is:
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
workspace → file discovery → local index → query routes → compact results
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The index combines lexical and vector retrieval. Managed ripgrep follows the
|
|
16
|
+
same workspace and output conventions but can run without an index.
|
|
17
|
+
|
|
18
|
+
## 1. Choose the workspace scope
|
|
19
|
+
|
|
20
|
+
Run indexing from the repository root, or pass it explicitly:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd your-repository
|
|
24
|
+
zg index --embedding local/potion-code-16m-v2
|
|
25
|
+
|
|
26
|
+
# Equivalent with an explicit root
|
|
27
|
+
zg index /absolute/path/to/your-repository \
|
|
28
|
+
--embedding local/potion-code-16m-v2
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The workspace index is stored under `<root>/.zvec-grep/`. `.git` and
|
|
32
|
+
`.zvec-grep` are always excluded. Common dependency, build, generated, cache,
|
|
33
|
+
and log directories are excluded by default, as are files ignored by the
|
|
34
|
+
repository's ignore rules.
|
|
35
|
+
|
|
36
|
+
The main workspace files are `manifest.json`, `files.zvec`, and `index.zvec`.
|
|
37
|
+
The manifest stores index metadata and the workspace Embedding runtime settings,
|
|
38
|
+
including an API key when one was explicitly persisted for that workspace.
|
|
39
|
+
|
|
40
|
+
Scope large repositories early:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
zg index \
|
|
44
|
+
--embedding local/potion-code-16m-v2 \
|
|
45
|
+
-g "src/**" \
|
|
46
|
+
-g "docs/**" \
|
|
47
|
+
-g "!dist/**" \
|
|
48
|
+
-t ts
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Useful discovery controls include:
|
|
52
|
+
|
|
53
|
+
| Option | Effect |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `-g, --glob <glob>` | Add an ordered include or `!` exclude rule |
|
|
56
|
+
| `--iglob <glob>` | Add a case-insensitive glob rule |
|
|
57
|
+
| `-t, --type <type>` | Include a ripgrep file type |
|
|
58
|
+
| `-T, --type-not <type>` | Exclude a ripgrep file type |
|
|
59
|
+
| `--hidden` | Include hidden paths except `.git` and `.zvec-grep` |
|
|
60
|
+
| `--no-ignore` | Stop applying ignore files |
|
|
61
|
+
| `--ignore-file <path>` | Add an ignore file |
|
|
62
|
+
| `--max-depth <n>` | Limit recursive depth |
|
|
63
|
+
| `--max-filesize <size>` | Limit file size, for example `500K` or `2M` |
|
|
64
|
+
| `-L, --follow` | Follow symbolic links safely |
|
|
65
|
+
|
|
66
|
+
File-type filters narrow the result after glob rules. For example,
|
|
67
|
+
`-g "docs/**" -t ts` selects TypeScript files inside `docs`, not every file in
|
|
68
|
+
that directory.
|
|
69
|
+
|
|
70
|
+
### Supported formats and extraction
|
|
71
|
+
|
|
72
|
+
The scanner assigns each admitted file to one extraction path. Structure-aware
|
|
73
|
+
extractors preserve useful code symbols or Markdown sections. When structure is
|
|
74
|
+
not available, zg falls back to plain-text chunks so the file can still
|
|
75
|
+
participate in indexed search.
|
|
76
|
+
|
|
77
|
+
| Files | Formats | Extractor | Indexed representation |
|
|
78
|
+
| --- | --- | --- | --- |
|
|
79
|
+
| Structure-aware code | C/C++ (`.c`, `.cc`, `.cpp`, `.cxx`, `.h`, `.hpp`), Go, Java, JavaScript/JSX, TypeScript/TSX, Python, Rust | `CodeExtractor` | Symbols, signatures, breadcrumbs, and surrounding source |
|
|
80
|
+
| Component scripts | `.vue`, `.svelte` | `CodeExtractor` | JavaScript or TypeScript `<script>` blocks; plain-text fallback when no structure is found |
|
|
81
|
+
| Other recognized code | Ruby, PHP, Swift, Kotlin, C#, Scala, shell, SQL, CSS/SCSS/Less, `Dockerfile`, `Makefile` | `CodeExtractor` | Plain-text chunks until a structural grammar is available |
|
|
82
|
+
| Markdown | `.md`, `.mdx` | `MarkdownExtractor` | Heading sections and breadcrumbs; plain-text fallback for documents without headings |
|
|
83
|
+
| Text documents | `.txt`, `.rst`, `.html`, `.htm`, `.xml` | `TextExtractor` | Plain-text chunks |
|
|
84
|
+
| Text data | `.csv`, `.json`, `.jsonc`, `.toml`, `.yaml`, `.yml` | `TextExtractor` | Plain-text chunks |
|
|
85
|
+
| Other non-binary files | Unrecognized extensions that pass binary detection | `TextExtractor` | Plain-text chunks |
|
|
86
|
+
| Raster images | `.gif`, `.jpeg`, `.jpg`, `.png`, `.webp` | `ImageExtractor` | Image content when explicitly included and the selected Embedding model accepts images |
|
|
87
|
+
|
|
88
|
+
Raster images are excluded by the default discovery rules and must be selected
|
|
89
|
+
explicitly. A text-only Embedding model cannot add image fragments to its
|
|
90
|
+
vector index.
|
|
91
|
+
|
|
92
|
+
The following binary formats are currently skipped before extraction:
|
|
93
|
+
|
|
94
|
+
- documents: `.pdf`, `.doc`, `.docx`, `.ppt`, `.pptx`, `.xls`, `.xlsx`;
|
|
95
|
+
- archives: `.zip`, `.tar`, `.gz`, `.bz2`, `.xz`, `.7z`, `.rar`;
|
|
96
|
+
- executables and compiled artifacts: `.exe`, `.dll`, `.dylib`, `.so`, `.a`,
|
|
97
|
+
`.o`, `.obj`, `.wasm`, `.class`, `.jar`;
|
|
98
|
+
- media and databases: `.mp3`, `.mp4`, `.mov`, `.avi`, `.mkv`, `.db`,
|
|
99
|
+
`.sqlite`.
|
|
100
|
+
|
|
101
|
+
Empty files, files above the configured size limit, and files detected as
|
|
102
|
+
binary are also skipped. Skipped files do not become extraction failures and
|
|
103
|
+
are not included in the current `filesScanned` count, so the index summary does
|
|
104
|
+
not list each skipped path or reason.
|
|
105
|
+
|
|
106
|
+
<a id="indexing"></a>
|
|
107
|
+
|
|
108
|
+
## 2. Build and maintain the index
|
|
109
|
+
|
|
110
|
+
A new index resolves its model from explicit `--embedding`,
|
|
111
|
+
`ZVEC_GREP_EMBEDDING`, then the configured default. Existing indexes reuse their
|
|
112
|
+
stored model and file-selection settings:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# First build
|
|
116
|
+
zg index --embedding local/potion-code-16m-v2
|
|
117
|
+
|
|
118
|
+
# Incremental update with the stored schema
|
|
119
|
+
zg index
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Use `zg status` to see the root, selected model, file counts, failures,
|
|
123
|
+
truncation, and the suggested next action:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
zg status
|
|
127
|
+
zg status --check-ready
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Changing the Embedding model or an incompatible endpoint requires an explicit
|
|
131
|
+
rebuild:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
zg index --rebuild --embedding local/jina-embeddings-v2-base-code
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Use `--reset-paths` when the existing file-selection settings should be
|
|
138
|
+
replaced rather than reused. Deleting an index is explicit and destructive:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
zg index --drop --yes
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
See [Embedding models](./07-embedding.md) before choosing or changing a model.
|
|
145
|
+
|
|
146
|
+
<a id="querying"></a>
|
|
147
|
+
|
|
148
|
+
## 3. Query through one search layer
|
|
149
|
+
|
|
150
|
+
The shortest query uses hybrid ranked retrieval:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
zg query "where theme preferences are restored"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Choose an explicit route only when you need more control:
|
|
157
|
+
|
|
158
|
+
| Route | Use it for | Coverage |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| Positional query or `--hybrid` | Intent plus useful lexical anchors | Ranked sample |
|
|
161
|
+
| `--fts` | Exact terms ranked through the index | Ranked sample |
|
|
162
|
+
| `--vector` | Conceptual similarity without lexical ranking | Ranked sample |
|
|
163
|
+
| `--rg` | Exhaustive literal or regex matching | Exhaustive unless explicitly bounded |
|
|
164
|
+
|
|
165
|
+
Examples:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Ranked lexical search
|
|
169
|
+
zg query --fts "AuthService"
|
|
170
|
+
|
|
171
|
+
# Explicit semantic search
|
|
172
|
+
zg query --vector "where credentials are validated"
|
|
173
|
+
|
|
174
|
+
# Combine and fuse several query groups
|
|
175
|
+
zg query \
|
|
176
|
+
--hybrid "authentication flow" \
|
|
177
|
+
--fts "ForbiddenError" \
|
|
178
|
+
--fuse \
|
|
179
|
+
--limit 10
|
|
180
|
+
|
|
181
|
+
# No index required
|
|
182
|
+
zg query --rg -n -F "AuthService" -g "*.ts" src
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Multiple positional queries remain separate groups unless `--fuse` is set.
|
|
186
|
+
Use `-g`, `--iglob`, `-t`, and `-T` on indexed queries to narrow results. Managed
|
|
187
|
+
rg also accepts common ripgrep matching, context, engine, encoding, discovery,
|
|
188
|
+
glob, and type options.
|
|
189
|
+
|
|
190
|
+
zg owns the managed-rg result format, so output-changing options such as
|
|
191
|
+
`--json`, `--count`, `--files`, `-l`, `-o`, `--replace`, and `--vimgrep` are
|
|
192
|
+
rejected. Use `-A`, `-B`, or `-C` to add context.
|
|
193
|
+
|
|
194
|
+
## Freshness
|
|
195
|
+
|
|
196
|
+
Indexed results report `fresh` or `possibly_stale`. A possibly stale result can
|
|
197
|
+
remain immediately useful while an update is pending. See
|
|
198
|
+
[Server and execution modes](./06-server.md#refresh-behavior) for the interaction
|
|
199
|
+
between `auto`, `server`, `direct`, and `--refresh`.
|
|
200
|
+
|
|
201
|
+
## Output for agents and people
|
|
202
|
+
|
|
203
|
+
Default CLI output is compact and grouped by file. Indexed source previews are
|
|
204
|
+
omitted unless requested, reducing context passed to an agent:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
zg query "plugin lifecycle" --preview short --limit 5
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For terminal reading, `--human` enables richer presentation and defaults to a
|
|
211
|
+
full preview:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
zg query --human "plugin lifecycle" --limit 5
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Use `--debug` for query diagnostics and `--trace` for per-hit indexed search
|
|
218
|
+
trace information.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Architecture
|
|
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
|
+
zg presents one search layer to people and agents while keeping execution,
|
|
9
|
+
retrieval, and storage local by default.
|
|
10
|
+
|
|
11
|
+
## System at a glance
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
flowchart LR
|
|
15
|
+
Human["Human or script"] --> CLI["zg CLI"]
|
|
16
|
+
Agent["Agent"] --> MCP["MCP client"]
|
|
17
|
+
|
|
18
|
+
CLI --> Router{"auto / server / direct"}
|
|
19
|
+
MCP --> Server["Local Server"]
|
|
20
|
+
Router --> Server
|
|
21
|
+
Router --> Direct["Direct runtime"]
|
|
22
|
+
|
|
23
|
+
Server --> Engine["zvec-grep engine"]
|
|
24
|
+
Direct --> Engine
|
|
25
|
+
|
|
26
|
+
Engine --> Indexed["Indexed search<br/>BM25 + vector + RRF"]
|
|
27
|
+
Engine --> RG["Managed ripgrep<br/>exact text + regex"]
|
|
28
|
+
Engine --> Indexing["Indexing<br/>scan + extract + embed"]
|
|
29
|
+
|
|
30
|
+
Files[("Workspace files")] --> RG
|
|
31
|
+
Files --> Indexing
|
|
32
|
+
Indexing --> Index[("Workspace index<br/>.zvec-grep/")]
|
|
33
|
+
Index --> Indexed
|
|
34
|
+
|
|
35
|
+
Indexed --> Results["Compact results"]
|
|
36
|
+
RG --> Results
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Entry and execution
|
|
40
|
+
|
|
41
|
+
People and scripts enter through the CLI. Agents normally enter through the
|
|
42
|
+
local Streamable HTTP MCP endpoint configured by `zg install`.
|
|
43
|
+
|
|
44
|
+
The CLI routes indexed operations through `auto`, `server`, or `direct` mode.
|
|
45
|
+
Both Server and Direct modes call the same engine; the difference is process
|
|
46
|
+
lifetime and coordination, not search behavior. MCP requests always arrive
|
|
47
|
+
through the Server. Managed `zg query --rg` can run directly without a Server
|
|
48
|
+
or index.
|
|
49
|
+
|
|
50
|
+
See [Agent integrations](./01-agents.md), [CLI](./02-cli.md),
|
|
51
|
+
[MCP](./03-mcp.md), and [Server and execution modes](./06-server.md) for the
|
|
52
|
+
individual interfaces.
|
|
53
|
+
|
|
54
|
+
## Retrieval paths
|
|
55
|
+
|
|
56
|
+
The engine exposes two complementary paths behind the same product boundary:
|
|
57
|
+
|
|
58
|
+
| Path | Best for | Data source |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| Indexed retrieval | Intent, related concepts, and ranked keywords | BM25/FTS and vector data in the workspace index |
|
|
61
|
+
| Managed ripgrep | Known text, symbols, paths, and regular expressions | Workspace files scanned directly |
|
|
62
|
+
|
|
63
|
+
Indexed search can combine lexical and vector candidates and fuse their ranks
|
|
64
|
+
with reciprocal rank fusion (RRF). Managed ripgrep is exhaustive by default and
|
|
65
|
+
does not require an Embedding model. Both paths apply workspace-aware filtering
|
|
66
|
+
and return file-oriented results suitable for terminal reading or agent context.
|
|
67
|
+
|
|
68
|
+
The [Retrieval pipeline](./04-pipeline.md) covers indexing, freshness, filters,
|
|
69
|
+
and route selection in detail.
|
|
70
|
+
|
|
71
|
+
## State and trust boundary
|
|
72
|
+
|
|
73
|
+
The normal repository index lives under `<workspace>/.zvec-grep/`. Global
|
|
74
|
+
configuration and daemon state live under `~/.zvec-grep/`. Workspace scanning,
|
|
75
|
+
managed ripgrep, index storage, and local Embedding models remain on the local
|
|
76
|
+
machine, and the Server listens on loopback only.
|
|
77
|
+
|
|
78
|
+
Selecting a remote Embedding provider is the one path that can send query text
|
|
79
|
+
or workspace content outside the machine. zg requests explicit once-only or
|
|
80
|
+
workspace authorization before that transfer. MCP Bearer authentication protects
|
|
81
|
+
the local endpoint; it does not authorize remote Embedding.
|
|
82
|
+
|
|
83
|
+
See [Embedding models](./07-embedding.md#remote-embedding-and-authorization)
|
|
84
|
+
for provider authorization and
|
|
85
|
+
[Server authentication](./06-server.md#bearer-authentication) for the local
|
|
86
|
+
endpoint boundary.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Server and execution modes
|
|
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
|
+
The zvec-grep Server is a local daemon shared by agents and terminal commands.
|
|
9
|
+
It keeps the MCP endpoint available, coordinates active Workspace runtimes,
|
|
10
|
+
supports background index refresh, and can reuse loaded Embedding models across
|
|
11
|
+
requests.
|
|
12
|
+
|
|
13
|
+
You do not need the Server for every use of zg. Exact managed ripgrep and
|
|
14
|
+
indexed operations can also run directly in the current process.
|
|
15
|
+
|
|
16
|
+
## Choose an execution mode
|
|
17
|
+
|
|
18
|
+
Indexed CLI commands accept `--mode auto|server|direct`.
|
|
19
|
+
|
|
20
|
+
| Mode | Use it when | Behavior |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `auto` | Almost all terminal use | Use a ready Server; otherwise run Direct before submitting the operation |
|
|
23
|
+
| `server` | A script requires the daemon, shared state, or background refresh | Require the Server and fail if it is unavailable |
|
|
24
|
+
| `direct` | One-off use, CI, foreground debugging, or no daemon is desired | Run entirely in the current process |
|
|
25
|
+
|
|
26
|
+
`auto` is the default and the recommended mode for people. It does not start a
|
|
27
|
+
missing Server; it simply chooses the Server when one is already ready.
|
|
28
|
+
|
|
29
|
+
Use Server mode when:
|
|
30
|
+
|
|
31
|
+
- an Agent connects through MCP;
|
|
32
|
+
- indexed searches happen repeatedly across sessions;
|
|
33
|
+
- background refresh should keep an active Workspace current;
|
|
34
|
+
- multiple requests can benefit from a shared loaded model;
|
|
35
|
+
- operational tooling needs an explicit ready/not-ready contract.
|
|
36
|
+
|
|
37
|
+
Use Direct mode when:
|
|
38
|
+
|
|
39
|
+
- a command is an isolated one-off operation;
|
|
40
|
+
- a CI job should not leave a daemon running;
|
|
41
|
+
- you want foreground failures and resource lifetime tied to one process.
|
|
42
|
+
|
|
43
|
+
Managed `zg query --rg` does not need an index or loaded Embedding model. It
|
|
44
|
+
runs locally regardless of whether a Server is available.
|
|
45
|
+
|
|
46
|
+
## Agent setup
|
|
47
|
+
|
|
48
|
+
`zg install` configures the selected Agent and starts the Server when possible:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
zg install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Most Agent users therefore never need to run `zg server on` manually. Restart
|
|
55
|
+
the Agent or open a new session after installation so it discovers the MCP
|
|
56
|
+
endpoint.
|
|
57
|
+
|
|
58
|
+
Set `ZVEC_GREP_INSTALL_SKIP_SERVER=1` only when another process manager will
|
|
59
|
+
start the Server separately.
|
|
60
|
+
|
|
61
|
+
See [Agent integrations](./01-agents.md) for managed configuration and
|
|
62
|
+
[MCP](./03-mcp.md) for the exposed tools.
|
|
63
|
+
|
|
64
|
+
## Server lifecycle
|
|
65
|
+
|
|
66
|
+
Start the background daemon:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
zg server on
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Inspect process readiness, endpoint, PID, and MCP toolset:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
zg server status
|
|
76
|
+
zg server status --check-ready
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`--check-ready` preserves normal output and exits non-zero unless the Server is
|
|
80
|
+
ready, making it suitable for scripts and health checks.
|
|
81
|
+
|
|
82
|
+
Stop the daemon gracefully:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
zg server off
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Run it in the foreground for logs or process supervision:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
zg server run
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Only one Server instance can own a given zvec-grep home. If a running Server
|
|
95
|
+
uses the wrong MCP toolset, stop it before restarting with the new profile:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
zg server off
|
|
99
|
+
zg server on --mcp-toolset full
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Configure the mode
|
|
103
|
+
|
|
104
|
+
Choose a mode for one command:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
zg query --mode direct "root-local index discovery"
|
|
108
|
+
zg status --mode server --check-ready
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Set an environment default:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
export ZVEC_GREP_MODE=auto
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or set `client.mode` in `~/.zvec-grep/config.json`:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"version": 1,
|
|
122
|
+
"client": {
|
|
123
|
+
"mode": "auto"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
An explicit `--mode` wins over the environment and global configuration.
|
|
129
|
+
|
|
130
|
+
## Refresh behavior
|
|
131
|
+
|
|
132
|
+
The execution mode changes the default indexed-search refresh policy:
|
|
133
|
+
|
|
134
|
+
| Policy | Server | Direct |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| Default | `background` | `off` |
|
|
137
|
+
| `--refresh background` | Return current results and schedule an update | Warn and behave as `off` |
|
|
138
|
+
| `--refresh wait` | Wait for a fresh index | Update and wait in the current process |
|
|
139
|
+
| `--refresh off` | Search without updating | Search without updating |
|
|
140
|
+
|
|
141
|
+
Server searches may return useful results with `freshness: possibly_stale`
|
|
142
|
+
while an update continues. Use the result immediately when it answers the
|
|
143
|
+
question; use `--refresh wait` only when the latest file state is required.
|
|
144
|
+
|
|
145
|
+
## Endpoint and toolset
|
|
146
|
+
|
|
147
|
+
The default endpoint is:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
http://127.0.0.1:7999/mcp
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The Server only accepts loopback listen addresses. Change the loopback address
|
|
154
|
+
or port with:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
zg server on --listen 127.0.0.1:8999
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Set `ZVEC_GREP_SERVER_URL` when a client should use a non-default configured
|
|
161
|
+
endpoint.
|
|
162
|
+
|
|
163
|
+
The default `agent` MCP toolset exposes only `zvec_grep_search`. Use
|
|
164
|
+
`--mcp-toolset full` or `ZVEC_GREP_MCP_TOOLSET=full` to expose optional managed
|
|
165
|
+
rg together with the index and status tools. See [MCP](./03-mcp.md) for the tool
|
|
166
|
+
contract.
|
|
167
|
+
|
|
168
|
+
## Bearer authentication
|
|
169
|
+
|
|
170
|
+
Authentication is disabled by default because the Server is loopback-only. To
|
|
171
|
+
require a token, provide at least 32 characters through the environment or a
|
|
172
|
+
file:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
export ZVEC_GREP_SERVER_TOKEN="replace-with-a-long-random-token"
|
|
176
|
+
zg server on
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
zg server on --token-file /secure/path/zvec-grep.token
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Clients can use `ZVEC_GREP_SERVER_TOKEN` or `ZVEC_GREP_SERVER_TOKEN_FILE`.
|
|
184
|
+
Supported Agent integrations can reference an environment-backed token:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
zg install \
|
|
188
|
+
--target codex \
|
|
189
|
+
--mcp-token-env ZVEC_GREP_SERVER_TOKEN \
|
|
190
|
+
--yes
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The MCP Bearer token protects the local Server. It does not configure an
|
|
194
|
+
Embedding provider or authorize remote data transfer.
|
|
195
|
+
|
|
196
|
+
## Logs and state
|
|
197
|
+
|
|
198
|
+
The default daemon directory is `~/.zvec-grep/daemon/`. Its structured JSON
|
|
199
|
+
Lines log is written to:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
~/.zvec-grep/daemon/logs/server.log
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Credential, authorization, token, API-key, and query fields are filtered from
|
|
206
|
+
daemon log records. Repository identities are logged opaquely rather than as
|
|
207
|
+
raw paths where identity is sufficient.
|
|
208
|
+
|
|
209
|
+
Use `ZVEC_GREP_HOME` to relocate Server state. Check `zg server status` before
|
|
210
|
+
reading logs; routine searches do not need a status preflight.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Embedding models
|
|
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
|
+
The Embedding model determines the vector representation used by indexed
|
|
9
|
+
search. It affects language coverage, memory use, index size, input length, and
|
|
10
|
+
indexing speed. A new index needs an explicit model, an environment default, or
|
|
11
|
+
a configured default:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
zg index --embedding local/potion-code-16m-v2
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Local models keep workspace content and query text on the machine. Their files
|
|
18
|
+
are downloaded on first use and cached under `~/.zvec-grep/models` by default.
|
|
19
|
+
Remote models avoid local inference but send disclosed query or workspace
|
|
20
|
+
content to the configured provider after authorization.
|
|
21
|
+
|
|
22
|
+
## Quick selection
|
|
23
|
+
|
|
24
|
+
| Need | Start with | Why |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| A fast first index for a code repository | `local/potion-code-16m-v2` | Small static Model2Vec model with an 8,192-token input limit |
|
|
27
|
+
| A Transformer model specialized for code | `local/jina-embeddings-v2-base-code` | Code-oriented, multilingual, and long-context |
|
|
28
|
+
| General multilingual code and documents | `local/embeddinggemma-300m` | Broad language coverage in a local GGUF model |
|
|
29
|
+
| A smaller multilingual model | `local/multilingual-e5-small` | Compact 384-dimensional Transformer model |
|
|
30
|
+
| A lightweight English model | `local/all-minilm-l6-v2` | Small local model for short English text |
|
|
31
|
+
| Long English documents | `local/gte-modernbert-base` or `local/nomic-embed-text-v1.5` | 8,192-token local context |
|
|
32
|
+
| No local model runtime | `qwen/qwen3.7-text-embedding` | Managed text Embedding API |
|
|
33
|
+
| Text and image retrieval | `qwen/qwen3-vl-embedding` | Managed multimodal Embedding API |
|
|
34
|
+
|
|
35
|
+
The best model still depends on the repository and its real queries. Start with
|
|
36
|
+
the smallest model that covers the required languages and input length, then
|
|
37
|
+
compare representative results before committing to a larger model.
|
|
38
|
+
|
|
39
|
+
## Supported models
|
|
40
|
+
|
|
41
|
+
The input limit applies to each extracted entity or fragment, not the entire
|
|
42
|
+
file.
|
|
43
|
+
|
|
44
|
+
| Model | Runtime | Max input tokens | Dimensions |
|
|
45
|
+
| --- | --- | ---: | ---: |
|
|
46
|
+
| `local/potion-code-16m-v2` | Model2Vec FP16 | 8,192 | 256 |
|
|
47
|
+
| `local/potion-base-8m` | Model2Vec FP32 | 512 | 256 |
|
|
48
|
+
| `local/all-minilm-l6-v2` | ONNX Q4 | 256 | 384 |
|
|
49
|
+
| `local/bge-small-en-v1.5` | ONNX Q4 | 512 | 384 |
|
|
50
|
+
| `local/multilingual-e5-small` | ONNX Q8 | 512 | 384 |
|
|
51
|
+
| `local/jina-embeddings-v2-base-code` | ONNX Q8 | 8,192 | 768 |
|
|
52
|
+
| `local/gte-modernbert-base` | ONNX Q4 | 8,192 | 768 |
|
|
53
|
+
| `local/nomic-embed-text-v1.5` | ONNX Q4 | 8,192 | 768 |
|
|
54
|
+
| `local/embeddinggemma-300m` | GGUF Q8_0 | 2,048 | 768 |
|
|
55
|
+
| `local/qwen3-embedding-0.6b` | GGUF Q8_0 | 8,192 | 1,024 |
|
|
56
|
+
| `qwen/text-embedding-v4` | Remote text | 8,192 | 1,024 |
|
|
57
|
+
| `qwen/qwen3.7-text-embedding` | Remote text | 128,000 | 1,024 |
|
|
58
|
+
| `qwen/qwen3-vl-embedding` | Remote multimodal | 32,000 | 2,560 |
|
|
59
|
+
|
|
60
|
+
All catalog entries currently use cosine similarity. Exact model revisions are
|
|
61
|
+
pinned by zvec-grep so the same reference resolves consistently for a given
|
|
62
|
+
release.
|
|
63
|
+
|
|
64
|
+
## Configure a default model
|
|
65
|
+
|
|
66
|
+
Set a default for new indexes:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
zg config model set local/potion-code-16m-v2 --default
|
|
70
|
+
zg index
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`ZVEC_GREP_EMBEDDING` provides a process-level default that takes priority over
|
|
74
|
+
the configured global default for new indexes:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
export ZVEC_GREP_EMBEDDING=local/potion-code-16m-v2
|
|
78
|
+
zg index
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
An existing index always reuses its stored provider, model, dimensions, and
|
|
82
|
+
metric unless `--embedding` and `--rebuild` explicitly change them. `zg index`
|
|
83
|
+
forwards the current CLI environment default in server and auto modes; direct
|
|
84
|
+
MCP calls use the environment inherited by the daemon.
|
|
85
|
+
|
|
86
|
+
## Local runtime and device
|
|
87
|
+
|
|
88
|
+
Select a device for local Transformer and GGUF models:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
zg index \
|
|
92
|
+
--embedding local/jina-embeddings-v2-base-code \
|
|
93
|
+
--device auto
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Supported values are `auto`, `cpu`, `metal`, `vulkan`, and `cuda`. Save a model
|
|
97
|
+
preference globally with:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
zg config model set local/jina-embeddings-v2-base-code --device metal
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The equivalent environment override is `ZVEC_GREP_DEVICE`. Model2Vec models
|
|
104
|
+
such as Potion use static vector lookup, so selecting a GPU does not improve
|
|
105
|
+
their runtime.
|
|
106
|
+
|
|
107
|
+
Override the download cache with `--model-cache` or `ZVEC_GREP_MODEL_CACHE`:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
zg index \
|
|
111
|
+
--embedding local/potion-code-16m-v2 \
|
|
112
|
+
--model-cache /path/to/model-cache
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Remote Embedding and authorization
|
|
116
|
+
|
|
117
|
+
Configure the Qwen provider credential and, optionally, a model endpoint:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
zg config provider set qwen --api-key "$DASHSCOPE_API_KEY"
|
|
121
|
+
zg config model set qwen/text-embedding-v4 --default
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
One-off values can be passed directly or through `ZVEC_GREP_API_KEY` and
|
|
125
|
+
`ZVEC_GREP_ENDPOINT`:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
zg index \
|
|
129
|
+
--embedding qwen/text-embedding-v4 \
|
|
130
|
+
--api-key "$DASHSCOPE_API_KEY" \
|
|
131
|
+
--allow-remote
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Credentials configure access to a provider; they do not authorize data
|
|
135
|
+
transfer. `--allow-remote` authorizes Remote Embedding only for the current
|
|
136
|
+
command. To create a signed Workspace grant shared by the CLI and MCP server:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
zg auth grant \
|
|
140
|
+
--capability embedding \
|
|
141
|
+
--scope workspace \
|
|
142
|
+
--embedding qwen/text-embedding-v4
|
|
143
|
+
|
|
144
|
+
zg auth status
|
|
145
|
+
zg auth revoke
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Before granting access, confirm that the workspace content is permitted to be
|
|
149
|
+
sent to the selected provider and endpoint. MCP tool approval is separate from
|
|
150
|
+
this data authorization.
|
|
151
|
+
|
|
152
|
+
## Input length and truncation
|
|
153
|
+
|
|
154
|
+
zvec-grep uses the selected model's input limit when it creates fragments, but
|
|
155
|
+
characters and tokens do not map one-to-one across languages. If an extracted
|
|
156
|
+
input still exceeds the model limit, the provider truncates it and the index
|
|
157
|
+
records the count.
|
|
158
|
+
|
|
159
|
+
Inspect the index after changing models or file scope:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
zg status
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Prefer a model with a larger input limit or narrow the indexed content when
|
|
166
|
+
`truncated_fragments` is unexpectedly high.
|
|
167
|
+
|
|
168
|
+
## Change models
|
|
169
|
+
|
|
170
|
+
Vector spaces from different models are incompatible, even when their
|
|
171
|
+
dimensions match. Rebuild explicitly when changing models:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
zg index --rebuild --embedding local/jina-embeddings-v2-base-code
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Changing a remote endpoint also requires a rebuild because the endpoint is part
|
|
178
|
+
of the stored index schema. API key and local device changes affect runtime and
|
|
179
|
+
do not require rebuilding the vectors.
|