@zvec/zvec-grep 0.1.6 → 0.1.8
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 -52
- package/README_CN.md +85 -49
- package/dist/cli/args.js +40 -7
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth.js +1 -4
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/commands.js +53 -24
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/format/context.d.ts +3 -0
- package/dist/cli/format/context.js +93 -22
- package/dist/cli/format/context.js.map +1 -1
- package/dist/cli/format/debug.js +10 -4
- package/dist/cli/format/debug.js.map +1 -1
- package/dist/cli/format/status.d.ts +3 -1
- package/dist/cli/format/status.js +34 -0
- package/dist/cli/format/status.js.map +1 -1
- package/dist/cli/help.js +149 -16
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/install.js +174 -56
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/server-search.d.ts +3 -0
- package/dist/cli/server-search.js +12 -0
- package/dist/cli/server-search.js.map +1 -0
- package/dist/cli/types.d.ts +3 -0
- package/dist/cli/types.js.map +1 -1
- package/dist/client/daemon-client.d.ts +12 -0
- package/dist/client/daemon-client.js +23 -0
- package/dist/client/daemon-client.js.map +1 -1
- package/dist/daemon/backend.d.ts +2 -0
- package/dist/daemon/backend.js +121 -90
- package/dist/daemon/backend.js.map +1 -1
- package/dist/daemon/change-set.d.ts +5 -0
- package/dist/daemon/change-set.js +75 -13
- package/dist/daemon/change-set.js.map +1 -1
- package/dist/daemon/http-server.js +1 -0
- package/dist/daemon/http-server.js.map +1 -1
- package/dist/daemon/index-coordinator.d.ts +3 -4
- package/dist/daemon/index-coordinator.js +8 -21
- package/dist/daemon/index-coordinator.js.map +1 -1
- package/dist/daemon/root-runtime.js +2 -2
- package/dist/daemon/root-runtime.js.map +1 -1
- package/dist/daemon/runtime-manager.d.ts +1 -0
- package/dist/daemon/runtime-manager.js +4 -1
- package/dist/daemon/runtime-manager.js.map +1 -1
- package/dist/daemon/server-controller.js +138 -14
- package/dist/daemon/server-controller.js.map +1 -1
- package/dist/daemon/watch-manager.d.ts +5 -0
- package/dist/daemon/watch-manager.js +68 -21
- package/dist/daemon/watch-manager.js.map +1 -1
- package/dist/engine/code-formats.d.ts +3 -0
- package/dist/engine/code-formats.js +14 -0
- package/dist/engine/code-formats.js.map +1 -0
- package/dist/engine/extraction/code/adapter.js +1 -1
- package/dist/engine/extraction/code/adapter.js.map +1 -1
- package/dist/engine/extraction/code/extractor.d.ts +5 -0
- package/dist/engine/extraction/code/extractor.js +53 -26
- package/dist/engine/extraction/code/extractor.js.map +1 -1
- package/dist/engine/extraction/index.d.ts +2 -1
- package/dist/engine/extraction/index.js +2 -1
- package/dist/engine/extraction/index.js.map +1 -1
- package/dist/engine/extraction/markdown/extractor.js +5 -3
- package/dist/engine/extraction/markdown/extractor.js.map +1 -1
- package/dist/engine/extraction/runtime.d.ts +6 -1
- package/dist/engine/extraction/runtime.js +11 -0
- package/dist/engine/extraction/runtime.js.map +1 -1
- package/dist/engine/extraction/vector-content.d.ts +5 -0
- package/dist/engine/extraction/vector-content.js +83 -0
- package/dist/engine/extraction/vector-content.js.map +1 -0
- package/dist/engine/file-size-policy.d.ts +6 -0
- package/dist/engine/file-size-policy.js +20 -0
- package/dist/engine/file-size-policy.js.map +1 -0
- package/dist/engine/file-type.d.ts +10 -0
- package/dist/engine/file-type.js +71 -38
- package/dist/engine/file-type.js.map +1 -1
- package/dist/engine/manifest.d.ts +1 -0
- package/dist/engine/manifest.js +4 -0
- package/dist/engine/manifest.js.map +1 -1
- package/dist/engine/models/backends/model2vec-runtime.d.ts +63 -0
- package/dist/engine/models/backends/model2vec-runtime.js +112 -0
- package/dist/engine/models/backends/model2vec-runtime.js.map +1 -0
- package/dist/engine/models/backends/model2vec-tokenizer.d.ts +2 -0
- package/dist/engine/models/backends/model2vec-tokenizer.js +42 -0
- package/dist/engine/models/backends/model2vec-tokenizer.js.map +1 -0
- package/dist/engine/models/backends/model2vec-worker-pool.d.ts +25 -0
- package/dist/engine/models/backends/model2vec-worker-pool.js +264 -0
- package/dist/engine/models/backends/model2vec-worker-pool.js.map +1 -0
- package/dist/engine/models/backends/model2vec-worker.d.ts +1 -0
- package/dist/engine/models/backends/model2vec-worker.js +41 -0
- package/dist/engine/models/backends/model2vec-worker.js.map +1 -0
- package/dist/engine/models/backends/model2vec.d.ts +3 -20
- package/dist/engine/models/backends/model2vec.js +107 -128
- package/dist/engine/models/backends/model2vec.js.map +1 -1
- package/dist/engine/models/catalog.d.ts +26 -7
- package/dist/engine/models/catalog.js +26 -7
- package/dist/engine/models/catalog.js.map +1 -1
- package/dist/engine/models/embeddings.d.ts +1 -0
- package/dist/engine/models/embeddings.js.map +1 -1
- package/dist/engine/models/resolution.js +1 -1
- package/dist/engine/models/resolution.js.map +1 -1
- package/dist/engine/pipeline/indexing/index.js +102 -78
- package/dist/engine/pipeline/indexing/index.js.map +1 -1
- package/dist/engine/pipeline/indexing/input-budget.d.ts +2 -0
- package/dist/engine/pipeline/indexing/input-budget.js +51 -0
- package/dist/engine/pipeline/indexing/input-budget.js.map +1 -0
- package/dist/engine/pipeline/indexing/scanner/index.d.ts +5 -1
- package/dist/engine/pipeline/indexing/scanner/index.js +129 -20
- package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
- package/dist/engine/pipeline/search/index.js.map +1 -1
- package/dist/engine/service/index.d.ts +1 -1
- package/dist/engine/service/root.d.ts +1 -4
- package/dist/engine/service/root.js +15 -22
- package/dist/engine/service/root.js.map +1 -1
- package/dist/engine/service/structure-enrichment.d.ts +1 -1
- package/dist/engine/service/structure-enrichment.js +10 -10
- package/dist/engine/service/structure-enrichment.js.map +1 -1
- package/dist/engine/service/types.d.ts +8 -1
- package/dist/engine/service/workspace-index.d.ts +6 -4
- package/dist/engine/service/workspace-index.js +18 -12
- package/dist/engine/service/workspace-index.js.map +1 -1
- package/dist/engine/service/zvec-grep.js +47 -29
- package/dist/engine/service/zvec-grep.js.map +1 -1
- package/dist/engine/storage/index.d.ts +28 -21
- package/dist/engine/storage/index.js +2 -1
- package/dist/engine/storage/index.js.map +1 -1
- package/dist/engine/storage/layout.d.ts +10 -0
- package/dist/engine/storage/layout.js +29 -0
- package/dist/engine/storage/layout.js.map +1 -0
- package/dist/engine/storage/zvec.d.ts +2 -42
- package/dist/engine/storage/zvec.js +62 -71
- package/dist/engine/storage/zvec.js.map +1 -1
- package/dist/engine/types.d.ts +14 -0
- package/dist/engine/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/input-normalization.d.ts +2 -2
- package/dist/mcp/input-normalization.js +14 -5
- package/dist/mcp/input-normalization.js.map +1 -1
- package/dist/mcp/schemas.d.ts +242 -0
- package/dist/mcp/schemas.js +73 -14
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/stdio-bridge.d.ts +11 -0
- package/dist/mcp/stdio-bridge.js +134 -0
- package/dist/mcp/stdio-bridge.js.map +1 -0
- package/dist/mcp/tools.d.ts +4 -1
- package/dist/mcp/tools.js +78 -44
- package/dist/mcp/tools.js.map +1 -1
- package/dist/prompts/zvec-grep-guidance.d.ts +2 -0
- package/dist/prompts/zvec-grep-guidance.js +9 -0
- package/dist/prompts/zvec-grep-guidance.js.map +1 -0
- package/docs/01-agents.md +26 -5
- package/docs/02-cli.md +11 -1
- package/docs/03-mcp.md +29 -11
- package/docs/04-pipeline.md +10 -2
- package/docs/06-server.md +9 -0
- package/docs/07-embedding.md +6 -3
- package/package.json +5 -4
- package/skills/zvec-grep/SKILL.md +0 -61
- package/skills/zvec-grep/agents/openai.yaml +0 -4
- package/skills/zvec-grep/references/cli-fallback.md +0 -85
package/README.md
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
|
-
<p>
|
|
7
|
-
<a href="./docs/08-roadmap.md"><img src="https://img.shields.io/badge/status-work%20in%20progress-F59E0B?style=for-the-badge" alt="Work in progress" /></a>
|
|
8
|
-
</p>
|
|
9
6
|
<picture>
|
|
10
7
|
<source media="(prefers-color-scheme: dark)" srcset="./.github/assets/zg-logo-dark.svg">
|
|
11
8
|
<img src="./.github/assets/zg-logo.svg" width="150" alt="zg logo" />
|
|
@@ -23,7 +20,7 @@
|
|
|
23
20
|
<p>
|
|
24
21
|
<a href="#tour">🎬 <strong>Tour</strong></a> |
|
|
25
22
|
<a href="#features">💫 <strong>Features</strong></a> |
|
|
26
|
-
<a href="#
|
|
23
|
+
<a href="#try-it-yourself">🚀 <strong>Try it yourself</strong></a> |
|
|
27
24
|
<a href="./docs/README.md">📚 <strong>Docs</strong></a> |
|
|
28
25
|
<a href="#benchmarks">📊 <strong>Benchmarks</strong></a> |
|
|
29
26
|
<a href="#community">🤝 <strong>Community</strong></a>
|
|
@@ -39,91 +36,130 @@ terminal, or let your agent use it for you.
|
|
|
39
36
|
## 🎬 See it in action
|
|
40
37
|
|
|
41
38
|
<div align="center">
|
|
42
|
-
<img src="./.github/assets/zvec-grep-tour.gif" width="1000" alt="Install the agent integration, index a
|
|
39
|
+
<img src="./.github/assets/zvec-grep-tour.gif" width="1000" alt="Install the agent integration, index a workspace, and let the agent search it with zvec-grep" />
|
|
43
40
|
</div>
|
|
44
41
|
|
|
45
|
-
Install the integration once, index the workspace, then search from the terminal
|
|
46
|
-
or ask your agent naturally.
|
|
47
|
-
|
|
48
42
|
<a id="features"></a>
|
|
49
43
|
|
|
50
44
|
## 💫 Why zg?
|
|
51
45
|
|
|
52
|
-
- **
|
|
53
|
-
|
|
54
|
-
- **
|
|
55
|
-
exact text
|
|
56
|
-
- **
|
|
57
|
-
|
|
58
|
-
- **
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
- **Ready for humans and agents** — install once, index once, then use the same
|
|
47
|
+
workspace from the CLI or your agent on macOS, Linux, and Windows.
|
|
48
|
+
- **Search beyond keywords** — discover by meaning, rank by relevance, then
|
|
49
|
+
verify with exact text or regex when needed.
|
|
50
|
+
- **Multi-format search** — search source code, documents, and structured data
|
|
51
|
+
while preserving useful structure and source locations.
|
|
52
|
+
- **Less searching, less context** — ranked, source-linked results surface the
|
|
53
|
+
right evidence with fewer tool calls, fewer tokens, and less noise.
|
|
54
|
+
- **Local by default** — files, indexes, and local models stay on your machine;
|
|
55
|
+
remote embeddings receive data only with your permission.
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
<a id="try-it-yourself"></a>
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
## 🚀 Try it yourself
|
|
66
60
|
|
|
67
|
-
### 1.
|
|
61
|
+
### 1. Set up a sample bookshelf
|
|
68
62
|
|
|
69
63
|
```bash
|
|
64
|
+
# Requires Node.js 22 or newer.
|
|
70
65
|
npm install -g @zvec/zvec-grep
|
|
71
|
-
zg install
|
|
72
|
-
```
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
mkdir zg-mystery && cd zg-mystery
|
|
68
|
+
curl --retry 3 --retry-all-errors --progress-bar -fL \
|
|
69
|
+
-o alice-in-wonderland.txt https://raw.githubusercontent.com/GITenberg/Alice-s-Adventures-in-Wonderland_11/master/11.txt \
|
|
70
|
+
-o sherlock-holmes.txt https://raw.githubusercontent.com/GITenberg/The-Memoirs-of-Sherlock-Holmes_834/master/834.txt
|
|
78
71
|
|
|
79
|
-
|
|
80
|
-
zg install --target codex --yes
|
|
72
|
+
zg index --embedding local/potion-retrieval-32m
|
|
81
73
|
```
|
|
82
74
|
|
|
83
|
-
### 2.
|
|
75
|
+
### 2. Choose how to search
|
|
76
|
+
|
|
77
|
+
#### For agents: ask with OpenCode
|
|
78
|
+
|
|
79
|
+
With [OpenCode](https://opencode.ai/) configured:
|
|
84
80
|
|
|
85
81
|
```bash
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
zg install --target opencode --yes
|
|
83
|
+
opencode run --model opencode/deepseek-v4-flash-free \
|
|
84
|
+
"An unseen creature left a few marks. What did the detective infer? Cite local evidence."
|
|
88
85
|
```
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
[Potion Code v2](./docs/07-embedding.md) model so you can build the first index
|
|
92
|
-
quickly. The first run downloads it; the index stays in `.zvec-grep/`, and later
|
|
93
|
-
updates only need `zg index`. See the
|
|
94
|
-
[retrieval pipeline](./docs/04-pipeline.md#indexing) to control scope, updates, and
|
|
95
|
-
rebuilds.
|
|
87
|
+
OpenCode chooses zg on its own—the prompt does not name a tool.
|
|
96
88
|
|
|
97
|
-
|
|
89
|
+
<details>
|
|
90
|
+
<summary><strong>See the full agent run and answer</strong></summary>
|
|
98
91
|
|
|
99
92
|
```text
|
|
100
|
-
|
|
93
|
+
⚙ zvec_grep_zvec_grep_search {"root":".../zg-mystery","query":"An unseen creature left a few marks. What did the detective infer?","fts":["marks","unseen creature","inferred","detective"],"fuse":true}
|
|
94
|
+
→ Read sherlock-holmes.txt [offset=5440, limit=120]
|
|
95
|
+
|
|
96
|
+
Answer:
|
|
97
|
+
The detective is Sherlock Holmes in *The Adventure of the Crooked Man*.
|
|
98
|
+
From the animal's foot-marks, he inferred:
|
|
99
|
+
|
|
100
|
+
- It was not a dog, cat, monkey, or other familiar creature: its print had
|
|
101
|
+
five foot-pads, long nails, and was nearly as large as a dessert-spoon
|
|
102
|
+
(sherlock-holmes.txt:5479-5486).
|
|
103
|
+
- It had a long body and very short legs: nearly two feet long, but with a
|
|
104
|
+
stride of only about three inches (sherlock-holmes.txt:5497-5502).
|
|
105
|
+
- It was carnivorous because it climbed the curtain toward a canary's cage
|
|
106
|
+
(sherlock-holmes.txt:5509-5510).
|
|
107
|
+
- It was probably from the weasel or stoat tribe, though unusually large
|
|
108
|
+
(sherlock-holmes.txt:5514-5516).
|
|
109
|
+
|
|
110
|
+
Holmes also inferred that a man entered through the window with it and later
|
|
111
|
+
left with the key (sherlock-holmes.txt:5464-5470, 5527-5528).
|
|
101
112
|
```
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
full toolset, which retains managed rg.
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
#### For humans: search directly
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
[CLI guide](./docs/02-cli.md) for routes, filters, and output controls.
|
|
118
|
+
Search the same bookshelf directly, without an agent:
|
|
110
119
|
|
|
111
120
|
```bash
|
|
112
|
-
zg query --human "
|
|
121
|
+
zg query --human "An unseen creature left a few marks. What did the detective infer?" --limit 3
|
|
113
122
|
```
|
|
114
123
|
|
|
124
|
+
zg returns the relevant passages from `sherlock-holmes.txt`, ranked ahead of
|
|
125
|
+
`alice-in-wonderland.txt`.
|
|
126
|
+
|
|
115
127
|
<a id="benchmarks"></a>
|
|
116
128
|
|
|
117
129
|
## 📊 Benchmarks
|
|
118
130
|
|
|
119
|
-
|
|
131
|
+
zg helps agents find relevant evidence faster by **narrowing the effective
|
|
132
|
+
search space** — using **fewer tokens, tool calls, and less time** while
|
|
133
|
+
preserving answer quality.
|
|
134
|
+
|
|
135
|
+
Each benchmark follows a **controlled, reproducible paired A/B protocol**: the
|
|
136
|
+
same agent runs the same pinned tasks with identical model, prompt, environment,
|
|
137
|
+
and limits; **only `zg` access and usage guidance differ**.
|
|
138
|
+
|
|
139
|
+
<img src="./.github/assets/benchmark-comparison-v2.svg" alt="Paired baseline and zvec-grep comparison for SWE-QA-Bench and BrowseComp-Plus" width="900" />
|
|
140
|
+
|
|
141
|
+
| Benchmark | Answer quality ↑ | Avg. input tokens ↓ | Avg. tool calls ↓ | Avg. agent time ↓ |
|
|
142
|
+
| --- | ---: | ---: | ---: | ---: |
|
|
143
|
+
| [**SWE-QA-Bench**](./benchmarks/swe-qa-bench/README.md)<br>20 tasks · Codebase QA | Judge Score<br>80.42 → 81.92 | 558,651 → 294,262 | 23.42 → 9.70 | 127.5s → 79.7s |
|
|
144
|
+
| [**BrowseComp-Plus**](./benchmarks/browse-comp-plus/README.md)<br>80 cases · Deep-research QA | Accuracy<br>90.00% → 90.00% | 2.04M → 1.19M | 22.70 → 14.24 | 284.8s → 199.3s |
|
|
145
|
+
|
|
146
|
+
Values show **Baseline → zg**.
|
|
120
147
|
|
|
121
|
-
|
|
148
|
+
See the [benchmark documentation](./benchmarks/README.md) for full results and
|
|
149
|
+
reproduction details.
|
|
122
150
|
|
|
123
|
-
|
|
124
|
-
more out-of-the-box experience, and support from desktop to mobile.
|
|
151
|
+
## 📚 Documentation
|
|
125
152
|
|
|
126
|
-
|
|
153
|
+
| Guide | What you can do |
|
|
154
|
+
| :--- | :--- |
|
|
155
|
+
| [Agent integrations](./docs/01-agents.md) | Connect zg to Codex, Claude Code, Cursor, or OpenCode and verify that it works. |
|
|
156
|
+
| [CLI guide](./docs/02-cli.md) | Search, index, and manage your local workspaces from the terminal. |
|
|
157
|
+
| [MCP guide](./docs/03-mcp.md) | Understand which zg tools your agent can use and how access is secured. |
|
|
158
|
+
| [Retrieval pipeline](./docs/04-pipeline.md) | Choose what to index, keep it fresh, and get better search results. |
|
|
159
|
+
| [Architecture](./docs/05-architecture.md) | See how zg handles your query and where your data stays. |
|
|
160
|
+
| [Server and execution modes](./docs/06-server.md) | Choose between one-off commands and a long-running local server. |
|
|
161
|
+
| [Embedding models](./docs/07-embedding.md) | Pick the right model for speed, search quality, privacy, and your hardware. |
|
|
162
|
+
| [Roadmap](./docs/08-roadmap.md) | See what is coming next and help shape zg's priorities. |
|
|
127
163
|
|
|
128
164
|
<a id="community"></a>
|
|
129
165
|
|
package/README_CN.md
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
|
-
<p>
|
|
7
|
-
<a href="./docs/08-roadmap.md"><img src="https://img.shields.io/badge/status-work%20in%20progress-F59E0B?style=for-the-badge" alt="项目开发中" /></a>
|
|
8
|
-
</p>
|
|
9
6
|
<picture>
|
|
10
7
|
<source media="(prefers-color-scheme: dark)" srcset="./.github/assets/zg-logo-dark.svg">
|
|
11
8
|
<img src="./.github/assets/zg-logo.svg" width="150" alt="zg logo" />
|
|
@@ -23,7 +20,7 @@
|
|
|
23
20
|
<p>
|
|
24
21
|
<a href="#tour">🎬 <strong>功能演示</strong></a> |
|
|
25
22
|
<a href="#features">💫 <strong>核心特性</strong></a> |
|
|
26
|
-
<a href="#
|
|
23
|
+
<a href="#try-it-yourself">🚀 <strong>动手体验</strong></a> |
|
|
27
24
|
<a href="./docs/README.md">📚 <strong>文档</strong></a> |
|
|
28
25
|
<a href="#benchmarks">📊 <strong>性能测试</strong></a> |
|
|
29
26
|
<a href="#community">🤝 <strong>社区</strong></a>
|
|
@@ -31,94 +28,133 @@
|
|
|
31
28
|
</div>
|
|
32
29
|
|
|
33
30
|
**zg**(**z**vec-**g**rep)将 ripgrep、BM25 与向量检索统一在一个
|
|
34
|
-
[本地优先的检索入口](./docs/05-architecture.md)
|
|
35
|
-
|
|
31
|
+
[本地优先的检索入口](./docs/05-architecture.md)中。既可以由人在终端中搜索,
|
|
32
|
+
也可以让 Agent 根据问题选择合适的本地检索方式。
|
|
36
33
|
|
|
37
34
|
<a id="tour"></a>
|
|
38
35
|
|
|
39
36
|
## 🎬 功能演示
|
|
40
37
|
|
|
41
38
|
<div align="center">
|
|
42
|
-
<img src="./.github/assets/zvec-grep-tour.gif" width="1000" alt="安装 Agent
|
|
39
|
+
<img src="./.github/assets/zvec-grep-tour.gif" width="1000" alt="安装 Agent 集成、为工作区建索引并让 Agent 使用 zvec-grep 检索本地内容" />
|
|
43
40
|
</div>
|
|
44
41
|
|
|
45
|
-
只需安装一次集成并为工作区建索引,之后既可以在终端中搜索,也可以直接向
|
|
46
|
-
Agent 提问。
|
|
47
|
-
|
|
48
42
|
<a id="features"></a>
|
|
49
43
|
|
|
50
44
|
## 💫 为什么选择 zg?
|
|
51
45
|
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
- **人与 Agent 开箱即用**:安装一次、索引一次,即可在 macOS、Linux 和
|
|
47
|
+
Windows 上通过 CLI 或 Agent 复用同一个工作区。
|
|
48
|
+
- **不止关键词搜索**:先按语义发现内容、按相关性排序,再在需要时使用精确文本
|
|
49
|
+
或正则完成验证。
|
|
50
|
+
- **多格式检索**:搜索源代码、文档和结构化数据,同时保留有用的内容结构与
|
|
51
|
+
来源位置。
|
|
52
|
+
- **更少搜索,更少上下文**:经过排序并保留来源的结果,可以减少工具调用、
|
|
53
|
+
Token 消耗与无关噪声,更快找到所需证据。
|
|
54
|
+
- **默认本地运行**:文件、索引与本地模型都留在本机;只有经过你的授权,远程
|
|
55
|
+
Embedding 服务才能接收数据。
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
<a id="try-it-yourself"></a>
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
## 🚀 动手体验
|
|
66
60
|
|
|
67
|
-
### 1.
|
|
61
|
+
### 1. 准备示例书架
|
|
68
62
|
|
|
69
63
|
```bash
|
|
64
|
+
# 需要 Node.js 22 或更新版本。
|
|
70
65
|
npm install -g @zvec/zvec-grep
|
|
71
|
-
zg install
|
|
72
|
-
```
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
mkdir zg-mystery && cd zg-mystery
|
|
68
|
+
curl --retry 3 --retry-all-errors --progress-bar -fL \
|
|
69
|
+
-o alice-in-wonderland.txt https://raw.githubusercontent.com/GITenberg/Alice-s-Adventures-in-Wonderland_11/master/11.txt \
|
|
70
|
+
-o sherlock-holmes.txt https://raw.githubusercontent.com/GITenberg/The-Memoirs-of-Sherlock-Holmes_834/master/834.txt
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
zg install --target codex --yes
|
|
72
|
+
zg index --embedding local/potion-retrieval-32m
|
|
80
73
|
```
|
|
81
74
|
|
|
82
|
-
### 2.
|
|
75
|
+
### 2. 选择检索方式
|
|
76
|
+
|
|
77
|
+
#### Agent:通过 OpenCode 提问
|
|
78
|
+
|
|
79
|
+
配置好 [OpenCode](https://opencode.ai/) 后:
|
|
83
80
|
|
|
84
81
|
```bash
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
zg install --target opencode --yes
|
|
83
|
+
opencode run --model opencode/deepseek-v4-flash-free \
|
|
84
|
+
"An unseen creature left a few marks. What did the detective infer? Cite local evidence."
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
第一次运行会下载模型,索引保存在 `.zvec-grep/` 下;后续更新只需运行
|
|
91
|
-
`zg index`。查看 [检索 Pipeline](./docs/04-pipeline.md#indexing),进一步控制检索范围、
|
|
92
|
-
增量更新和重建。
|
|
87
|
+
Prompt 中没有指定任何工具,OpenCode 会自主选择 zg。
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
<details>
|
|
90
|
+
<summary><strong>展开查看完整 Agent 调用与回答</strong></summary>
|
|
95
91
|
|
|
96
92
|
```text
|
|
97
|
-
|
|
93
|
+
⚙ zvec_grep_zvec_grep_search {"root":".../zg-mystery","query":"An unseen creature left a few marks. What did the detective infer?","fts":["marks","unseen creature","inferred","detective"],"fuse":true}
|
|
94
|
+
→ Read sherlock-holmes.txt [offset=5440, limit=120]
|
|
95
|
+
|
|
96
|
+
Answer:
|
|
97
|
+
The detective is Sherlock Holmes in *The Adventure of the Crooked Man*.
|
|
98
|
+
From the animal's foot-marks, he inferred:
|
|
99
|
+
|
|
100
|
+
- It was not a dog, cat, monkey, or other familiar creature: its print had
|
|
101
|
+
five foot-pads, long nails, and was nearly as large as a dessert-spoon
|
|
102
|
+
(sherlock-holmes.txt:5479-5486).
|
|
103
|
+
- It had a long body and very short legs: nearly two feet long, but with a
|
|
104
|
+
stride of only about three inches (sherlock-holmes.txt:5497-5502).
|
|
105
|
+
- It was carnivorous because it climbed the curtain toward a canary's cage
|
|
106
|
+
(sherlock-holmes.txt:5509-5510).
|
|
107
|
+
- It was probably from the weasel or stoat tribe, though unusually large
|
|
108
|
+
(sherlock-holmes.txt:5514-5516).
|
|
109
|
+
|
|
110
|
+
Holmes also inferred that a man entered through the window with it and later
|
|
111
|
+
left with the key (sherlock-holmes.txt:5464-5470, 5527-5528).
|
|
98
112
|
```
|
|
99
113
|
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
#### 用户:直接检索
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
搜索方式、过滤条件和输出控制。
|
|
118
|
+
不通过 Agent,直接搜索同一个书架:
|
|
105
119
|
|
|
106
120
|
```bash
|
|
107
|
-
zg query --human "
|
|
121
|
+
zg query --human "An unseen creature left a few marks. What did the detective infer?" --limit 3
|
|
108
122
|
```
|
|
109
123
|
|
|
124
|
+
zg 会将 `sherlock-holmes.txt` 中的相关段落排在
|
|
125
|
+
`alice-in-wonderland.txt` 前面。
|
|
126
|
+
|
|
110
127
|
<a id="benchmarks"></a>
|
|
111
128
|
|
|
112
129
|
## 📊 性能测试
|
|
113
130
|
|
|
114
|
-
|
|
131
|
+
zg 通过**缩小有效搜索空间**,帮助 Agent 更快找到相关证据 —— 在保持回答质量的同时,使用**更少的 Token、工具调用和时间**。
|
|
132
|
+
|
|
133
|
+
每项测试均采用**受控、可复现的配对 A/B 评测**:同一个 Agent 在完全相同的模型、Prompt、环境和资源限制下执行同一组预先固定的任务;**实验组仅额外提供 `zg` 工具及其使用说明**。
|
|
134
|
+
|
|
135
|
+
<img src="./.github/assets/benchmark-comparison-cn-v2.svg" alt="SWE-QA-Bench 和 BrowseComp-Plus 中 Baseline 与 zvec-grep 的配对对比" width="900" />
|
|
136
|
+
|
|
137
|
+
| 测试 | 回答质量 ↑ | 平均输入 Token ↓ | 平均工具调用 ↓ | 平均 Agent 耗时 ↓ |
|
|
138
|
+
| --- | ---: | ---: | ---: | ---: |
|
|
139
|
+
| [**SWE-QA-Bench**](./benchmarks/swe-qa-bench/README_CN.md)<br>20 个任务 · 代码库 QA | 评审得分<br>80.42 → 81.92 | 558,651 → 294,262 | 23.42 → 9.70 | 127.5s → 79.7s |
|
|
140
|
+
| [**BrowseComp-Plus**](./benchmarks/browse-comp-plus/README_CN.md)<br>80 个样例 · 深度研究 QA | 准确率<br>90.00% → 90.00% | 2.04M → 1.19M | 22.70 → 14.24 | 284.8s → 199.3s |
|
|
141
|
+
|
|
142
|
+
表中数值均按 **Baseline → zg** 展示。
|
|
115
143
|
|
|
116
|
-
|
|
144
|
+
完整结果和复现细节参见[性能测试文档](./benchmarks/README_CN.md)。
|
|
117
145
|
|
|
118
|
-
|
|
119
|
-
桌面端到移动端的全平台支持。
|
|
146
|
+
## 📚 文档
|
|
120
147
|
|
|
121
|
-
|
|
148
|
+
| 指南 | 你可以完成什么 |
|
|
149
|
+
| :--- | :--- |
|
|
150
|
+
| [Agent 集成](./docs/01-agents.md) | 将 zg 接入 Codex、Claude Code、Cursor 或 OpenCode,并验证是否正常工作。 |
|
|
151
|
+
| [CLI 指南](./docs/02-cli.md) | 在终端中搜索、索引和管理本地工作区。 |
|
|
152
|
+
| [MCP 指南](./docs/03-mcp.md) | 了解 Agent 可以使用哪些 zg 工具,以及访问权限如何受到保护。 |
|
|
153
|
+
| [检索 Pipeline](./docs/04-pipeline.md) | 选择索引范围、保持内容新鲜,并获得更好的检索结果。 |
|
|
154
|
+
| [架构](./docs/05-architecture.md) | 了解 zg 如何处理查询,以及数据会保留在哪里。 |
|
|
155
|
+
| [服务端与执行模式](./docs/06-server.md) | 在一次性命令和长期运行的本地服务之间选择。 |
|
|
156
|
+
| [Embedding 模型](./docs/07-embedding.md) | 根据速度、检索质量、隐私和本机硬件选择合适的模型。 |
|
|
157
|
+
| [Roadmap](./docs/08-roadmap.md) | 了解接下来的产品方向,并参与影响 zg 的优先级。 |
|
|
122
158
|
|
|
123
159
|
<a id="community"></a>
|
|
124
160
|
|
package/dist/cli/args.js
CHANGED
|
@@ -146,6 +146,9 @@ export function parseArgs(args) {
|
|
|
146
146
|
else if (arg === "--force-direct") {
|
|
147
147
|
options.forceDirect = true;
|
|
148
148
|
}
|
|
149
|
+
else if (arg === "--stdio") {
|
|
150
|
+
options.serverStdio = true;
|
|
151
|
+
}
|
|
149
152
|
else if (isLongOptionWithValue(arg, "--mcp-toolset")) {
|
|
150
153
|
options.mcpToolset = parseMcpToolset(valueFromLongOption(arg));
|
|
151
154
|
}
|
|
@@ -182,6 +185,12 @@ export function parseArgs(args) {
|
|
|
182
185
|
else if (arg === "--mcp-token-env") {
|
|
183
186
|
options.installMcpTokenEnv = parseEnvironmentVariable(readOptionValue(args, ++index, arg), arg);
|
|
184
187
|
}
|
|
188
|
+
else if (isLongOptionWithValue(arg, "--mcp-transport")) {
|
|
189
|
+
options.installMcpTransport = parseMcpInstallTransport(valueFromLongOption(arg));
|
|
190
|
+
}
|
|
191
|
+
else if (arg === "--mcp-transport") {
|
|
192
|
+
options.installMcpTransport = parseMcpInstallTransport(readOptionValue(args, ++index, arg));
|
|
193
|
+
}
|
|
185
194
|
else if (arg === "--yes") {
|
|
186
195
|
options.yes = true;
|
|
187
196
|
}
|
|
@@ -523,7 +532,6 @@ function validateCliShape(command, options, positionals) {
|
|
|
523
532
|
[options.hybridQueries?.length, "--hybrid"],
|
|
524
533
|
[options.routes?.length, "--fts/--vector"],
|
|
525
534
|
[options.fuse, "--fuse"],
|
|
526
|
-
[options.debug, "--debug"],
|
|
527
535
|
[options.trace, "--trace"],
|
|
528
536
|
[options.human, "--human"],
|
|
529
537
|
[options.preview, "--preview"],
|
|
@@ -538,6 +546,9 @@ function validateCliShape(command, options, positionals) {
|
|
|
538
546
|
if (command !== "query" && queryOnly) {
|
|
539
547
|
throw new Error(`${queryOnly} can only be used with zg query`);
|
|
540
548
|
}
|
|
549
|
+
if (options.debug && command !== "query" && command !== "index") {
|
|
550
|
+
throw new Error("--debug can only be used with zg query or zg index");
|
|
551
|
+
}
|
|
541
552
|
const sharedSelection = firstEnabledOption([
|
|
542
553
|
[options.globs?.length, "--glob"],
|
|
543
554
|
[options.insensitiveGlobs?.length, "--iglob"],
|
|
@@ -602,12 +613,16 @@ function validateCliShape(command, options, positionals) {
|
|
|
602
613
|
throw new Error("--default can only be used with zg config model set");
|
|
603
614
|
}
|
|
604
615
|
if (command === "server") {
|
|
605
|
-
if (!options.serverAction) {
|
|
606
|
-
throw new Error("zg server requires on, off, status, or
|
|
616
|
+
if (!options.serverAction && !options.serverStdio) {
|
|
617
|
+
throw new Error("zg server requires on, off, status, run, or --stdio");
|
|
618
|
+
}
|
|
619
|
+
if (options.serverAction && options.serverStdio) {
|
|
620
|
+
throw new Error("--stdio cannot be combined with a server action");
|
|
607
621
|
}
|
|
608
622
|
if (options.listen !== undefined &&
|
|
609
623
|
options.serverAction !== "run" &&
|
|
610
|
-
options.serverAction !== "on"
|
|
624
|
+
options.serverAction !== "on" &&
|
|
625
|
+
!options.serverStdio) {
|
|
611
626
|
throw new Error("--listen can only be used with zg server on or run");
|
|
612
627
|
}
|
|
613
628
|
if (options.serverTokenFile !== undefined &&
|
|
@@ -616,12 +631,16 @@ function validateCliShape(command, options, positionals) {
|
|
|
616
631
|
}
|
|
617
632
|
if (options.mcpToolset !== undefined &&
|
|
618
633
|
options.serverAction !== "on" &&
|
|
619
|
-
options.serverAction !== "run"
|
|
634
|
+
options.serverAction !== "run" &&
|
|
635
|
+
!options.serverStdio) {
|
|
620
636
|
throw new Error("--mcp-toolset can only be used with zg server on or run");
|
|
621
637
|
}
|
|
622
638
|
}
|
|
623
|
-
else if (options.mcpToolset !== undefined) {
|
|
624
|
-
throw new Error("--mcp-toolset can only be used with zg server on or
|
|
639
|
+
else if (options.mcpToolset !== undefined && command !== "install") {
|
|
640
|
+
throw new Error("--mcp-toolset can only be used with zg server on, run, --stdio, or zg install");
|
|
641
|
+
}
|
|
642
|
+
else if (options.serverStdio !== undefined) {
|
|
643
|
+
throw new Error("--stdio can only be used with zg server");
|
|
625
644
|
}
|
|
626
645
|
if (options.rg &&
|
|
627
646
|
(hasExplicitRoutes(options) || options.hybridQueries?.length)) {
|
|
@@ -679,6 +698,14 @@ function validateCliShape(command, options, positionals) {
|
|
|
679
698
|
if (options.installMcpTokenEnv !== undefined && command !== "install") {
|
|
680
699
|
throw new Error("--mcp-token-env can only be used with zg install");
|
|
681
700
|
}
|
|
701
|
+
if (options.installMcpTransport !== undefined && command !== "install") {
|
|
702
|
+
throw new Error("--mcp-transport can only be used with zg install");
|
|
703
|
+
}
|
|
704
|
+
if (command === "install" &&
|
|
705
|
+
options.installMcpTransport !== "http" &&
|
|
706
|
+
options.installMcpTokenEnv !== undefined) {
|
|
707
|
+
throw new Error("--mcp-token-env requires --mcp-transport http");
|
|
708
|
+
}
|
|
682
709
|
if (options.force && command !== "install") {
|
|
683
710
|
throw new Error("--force can only be used with zg install");
|
|
684
711
|
}
|
|
@@ -743,6 +770,7 @@ function validateCliShape(command, options, positionals) {
|
|
|
743
770
|
options.ignoreFiles?.length ||
|
|
744
771
|
options.maxDepth !== undefined ||
|
|
745
772
|
options.maxFileSizeBytes !== undefined ||
|
|
773
|
+
options.debug ||
|
|
746
774
|
options.follow ||
|
|
747
775
|
options.embeddingConcurrency)) {
|
|
748
776
|
throw new Error("zg index --drop cannot be combined with indexing options");
|
|
@@ -1014,6 +1042,11 @@ function parseEnvironmentVariable(value, option) {
|
|
|
1014
1042
|
}
|
|
1015
1043
|
return value;
|
|
1016
1044
|
}
|
|
1045
|
+
function parseMcpInstallTransport(value) {
|
|
1046
|
+
if (value === "stdio" || value === "http")
|
|
1047
|
+
return value;
|
|
1048
|
+
throw new Error("--mcp-transport must be stdio or http");
|
|
1049
|
+
}
|
|
1017
1050
|
function parseByteSize(value, option) {
|
|
1018
1051
|
const match = value.trim().match(/^(\d+)([KMGT])?$/i);
|
|
1019
1052
|
if (!match) {
|