@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.
Files changed (161) hide show
  1. package/README.md +88 -52
  2. package/README_CN.md +85 -49
  3. package/dist/cli/args.js +40 -7
  4. package/dist/cli/args.js.map +1 -1
  5. package/dist/cli/auth.js +1 -4
  6. package/dist/cli/auth.js.map +1 -1
  7. package/dist/cli/commands.js +53 -24
  8. package/dist/cli/commands.js.map +1 -1
  9. package/dist/cli/format/context.d.ts +3 -0
  10. package/dist/cli/format/context.js +93 -22
  11. package/dist/cli/format/context.js.map +1 -1
  12. package/dist/cli/format/debug.js +10 -4
  13. package/dist/cli/format/debug.js.map +1 -1
  14. package/dist/cli/format/status.d.ts +3 -1
  15. package/dist/cli/format/status.js +34 -0
  16. package/dist/cli/format/status.js.map +1 -1
  17. package/dist/cli/help.js +149 -16
  18. package/dist/cli/help.js.map +1 -1
  19. package/dist/cli/index.d.ts +1 -1
  20. package/dist/cli/index.js +1 -1
  21. package/dist/cli/install.js +174 -56
  22. package/dist/cli/install.js.map +1 -1
  23. package/dist/cli/server-search.d.ts +3 -0
  24. package/dist/cli/server-search.js +12 -0
  25. package/dist/cli/server-search.js.map +1 -0
  26. package/dist/cli/types.d.ts +3 -0
  27. package/dist/cli/types.js.map +1 -1
  28. package/dist/client/daemon-client.d.ts +12 -0
  29. package/dist/client/daemon-client.js +23 -0
  30. package/dist/client/daemon-client.js.map +1 -1
  31. package/dist/daemon/backend.d.ts +2 -0
  32. package/dist/daemon/backend.js +121 -90
  33. package/dist/daemon/backend.js.map +1 -1
  34. package/dist/daemon/change-set.d.ts +5 -0
  35. package/dist/daemon/change-set.js +75 -13
  36. package/dist/daemon/change-set.js.map +1 -1
  37. package/dist/daemon/http-server.js +1 -0
  38. package/dist/daemon/http-server.js.map +1 -1
  39. package/dist/daemon/index-coordinator.d.ts +3 -4
  40. package/dist/daemon/index-coordinator.js +8 -21
  41. package/dist/daemon/index-coordinator.js.map +1 -1
  42. package/dist/daemon/root-runtime.js +2 -2
  43. package/dist/daemon/root-runtime.js.map +1 -1
  44. package/dist/daemon/runtime-manager.d.ts +1 -0
  45. package/dist/daemon/runtime-manager.js +4 -1
  46. package/dist/daemon/runtime-manager.js.map +1 -1
  47. package/dist/daemon/server-controller.js +138 -14
  48. package/dist/daemon/server-controller.js.map +1 -1
  49. package/dist/daemon/watch-manager.d.ts +5 -0
  50. package/dist/daemon/watch-manager.js +68 -21
  51. package/dist/daemon/watch-manager.js.map +1 -1
  52. package/dist/engine/code-formats.d.ts +3 -0
  53. package/dist/engine/code-formats.js +14 -0
  54. package/dist/engine/code-formats.js.map +1 -0
  55. package/dist/engine/extraction/code/adapter.js +1 -1
  56. package/dist/engine/extraction/code/adapter.js.map +1 -1
  57. package/dist/engine/extraction/code/extractor.d.ts +5 -0
  58. package/dist/engine/extraction/code/extractor.js +53 -26
  59. package/dist/engine/extraction/code/extractor.js.map +1 -1
  60. package/dist/engine/extraction/index.d.ts +2 -1
  61. package/dist/engine/extraction/index.js +2 -1
  62. package/dist/engine/extraction/index.js.map +1 -1
  63. package/dist/engine/extraction/markdown/extractor.js +5 -3
  64. package/dist/engine/extraction/markdown/extractor.js.map +1 -1
  65. package/dist/engine/extraction/runtime.d.ts +6 -1
  66. package/dist/engine/extraction/runtime.js +11 -0
  67. package/dist/engine/extraction/runtime.js.map +1 -1
  68. package/dist/engine/extraction/vector-content.d.ts +5 -0
  69. package/dist/engine/extraction/vector-content.js +83 -0
  70. package/dist/engine/extraction/vector-content.js.map +1 -0
  71. package/dist/engine/file-size-policy.d.ts +6 -0
  72. package/dist/engine/file-size-policy.js +20 -0
  73. package/dist/engine/file-size-policy.js.map +1 -0
  74. package/dist/engine/file-type.d.ts +10 -0
  75. package/dist/engine/file-type.js +71 -38
  76. package/dist/engine/file-type.js.map +1 -1
  77. package/dist/engine/manifest.d.ts +1 -0
  78. package/dist/engine/manifest.js +4 -0
  79. package/dist/engine/manifest.js.map +1 -1
  80. package/dist/engine/models/backends/model2vec-runtime.d.ts +63 -0
  81. package/dist/engine/models/backends/model2vec-runtime.js +112 -0
  82. package/dist/engine/models/backends/model2vec-runtime.js.map +1 -0
  83. package/dist/engine/models/backends/model2vec-tokenizer.d.ts +2 -0
  84. package/dist/engine/models/backends/model2vec-tokenizer.js +42 -0
  85. package/dist/engine/models/backends/model2vec-tokenizer.js.map +1 -0
  86. package/dist/engine/models/backends/model2vec-worker-pool.d.ts +25 -0
  87. package/dist/engine/models/backends/model2vec-worker-pool.js +264 -0
  88. package/dist/engine/models/backends/model2vec-worker-pool.js.map +1 -0
  89. package/dist/engine/models/backends/model2vec-worker.d.ts +1 -0
  90. package/dist/engine/models/backends/model2vec-worker.js +41 -0
  91. package/dist/engine/models/backends/model2vec-worker.js.map +1 -0
  92. package/dist/engine/models/backends/model2vec.d.ts +3 -20
  93. package/dist/engine/models/backends/model2vec.js +107 -128
  94. package/dist/engine/models/backends/model2vec.js.map +1 -1
  95. package/dist/engine/models/catalog.d.ts +26 -7
  96. package/dist/engine/models/catalog.js +26 -7
  97. package/dist/engine/models/catalog.js.map +1 -1
  98. package/dist/engine/models/embeddings.d.ts +1 -0
  99. package/dist/engine/models/embeddings.js.map +1 -1
  100. package/dist/engine/models/resolution.js +1 -1
  101. package/dist/engine/models/resolution.js.map +1 -1
  102. package/dist/engine/pipeline/indexing/index.js +102 -78
  103. package/dist/engine/pipeline/indexing/index.js.map +1 -1
  104. package/dist/engine/pipeline/indexing/input-budget.d.ts +2 -0
  105. package/dist/engine/pipeline/indexing/input-budget.js +51 -0
  106. package/dist/engine/pipeline/indexing/input-budget.js.map +1 -0
  107. package/dist/engine/pipeline/indexing/scanner/index.d.ts +5 -1
  108. package/dist/engine/pipeline/indexing/scanner/index.js +129 -20
  109. package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
  110. package/dist/engine/pipeline/search/index.js.map +1 -1
  111. package/dist/engine/service/index.d.ts +1 -1
  112. package/dist/engine/service/root.d.ts +1 -4
  113. package/dist/engine/service/root.js +15 -22
  114. package/dist/engine/service/root.js.map +1 -1
  115. package/dist/engine/service/structure-enrichment.d.ts +1 -1
  116. package/dist/engine/service/structure-enrichment.js +10 -10
  117. package/dist/engine/service/structure-enrichment.js.map +1 -1
  118. package/dist/engine/service/types.d.ts +8 -1
  119. package/dist/engine/service/workspace-index.d.ts +6 -4
  120. package/dist/engine/service/workspace-index.js +18 -12
  121. package/dist/engine/service/workspace-index.js.map +1 -1
  122. package/dist/engine/service/zvec-grep.js +47 -29
  123. package/dist/engine/service/zvec-grep.js.map +1 -1
  124. package/dist/engine/storage/index.d.ts +28 -21
  125. package/dist/engine/storage/index.js +2 -1
  126. package/dist/engine/storage/index.js.map +1 -1
  127. package/dist/engine/storage/layout.d.ts +10 -0
  128. package/dist/engine/storage/layout.js +29 -0
  129. package/dist/engine/storage/layout.js.map +1 -0
  130. package/dist/engine/storage/zvec.d.ts +2 -42
  131. package/dist/engine/storage/zvec.js +62 -71
  132. package/dist/engine/storage/zvec.js.map +1 -1
  133. package/dist/engine/types.d.ts +14 -0
  134. package/dist/engine/types.js.map +1 -1
  135. package/dist/index.d.ts +2 -2
  136. package/dist/index.js.map +1 -1
  137. package/dist/mcp/input-normalization.d.ts +2 -2
  138. package/dist/mcp/input-normalization.js +14 -5
  139. package/dist/mcp/input-normalization.js.map +1 -1
  140. package/dist/mcp/schemas.d.ts +242 -0
  141. package/dist/mcp/schemas.js +73 -14
  142. package/dist/mcp/schemas.js.map +1 -1
  143. package/dist/mcp/stdio-bridge.d.ts +11 -0
  144. package/dist/mcp/stdio-bridge.js +134 -0
  145. package/dist/mcp/stdio-bridge.js.map +1 -0
  146. package/dist/mcp/tools.d.ts +4 -1
  147. package/dist/mcp/tools.js +78 -44
  148. package/dist/mcp/tools.js.map +1 -1
  149. package/dist/prompts/zvec-grep-guidance.d.ts +2 -0
  150. package/dist/prompts/zvec-grep-guidance.js +9 -0
  151. package/dist/prompts/zvec-grep-guidance.js.map +1 -0
  152. package/docs/01-agents.md +26 -5
  153. package/docs/02-cli.md +11 -1
  154. package/docs/03-mcp.md +29 -11
  155. package/docs/04-pipeline.md +10 -2
  156. package/docs/06-server.md +9 -0
  157. package/docs/07-embedding.md +6 -3
  158. package/package.json +5 -4
  159. package/skills/zvec-grep/SKILL.md +0 -61
  160. package/skills/zvec-grep/agents/openai.yaml +0 -4
  161. 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="#quickstart">🚀 <strong>Quickstart</strong></a> |
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 repository, and let the agent search it with zvec-grep" />
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
- - **Works out of the box** — one guided install connects zg to your agent on
53
- macOS, Linux, or Windows; ask naturally, with no search syntax to learn.
54
- - **All-in-one retrieval layer** — semantic discovery, BM25-ranked retrieval,
55
- exact text, and regex search all stay behind zg.
56
- - **Agent- and human-friendly** — compact, file-oriented context for agents
57
- and readable terminal output for people, with less noise for both.
58
- - **Local first, permission aware** — ripgrep, indexes, and local models stay
59
- on your machine; remote embeddings require explicit authorization.
60
-
61
- <a id="quickstart"></a>
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
- ## 🚀 Quickstart
57
+ <a id="try-it-yourself"></a>
64
58
 
65
- Requires Node.js 22 or newer on macOS, Linux, or Windows.
59
+ ## 🚀 Try it yourself
66
60
 
67
- ### 1. Install and connect your agent
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
- `zg install` detects Codex, Claude Code, Cursor, and OpenCode and configures the
75
- local MCP integration. See [Agent integrations](./docs/01-agents.md) for managed
76
- configuration, permissions, and uninstall instructions. You can also select one
77
- explicitly:
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
- ```bash
80
- zg install --target codex --yes
72
+ zg index --embedding local/potion-retrieval-32m
81
73
  ```
82
74
 
83
- ### 2. Index your repository
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
- cd your-repository
87
- zg index --embedding local/potion-code-16m-v2
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
- This quickstart uses the lightweight
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
- ### 3. Ask your agent
89
+ <details>
90
+ <summary><strong>See the full agent run and answer</strong></summary>
98
91
 
99
92
  ```text
100
- My app forgets dark mode every time I refresh. Find out why.
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
- The agent uses zg for semantic discovery and ranked keyword retrieval, while
104
- exact lexical lookup stays with native grep or rg. The
105
- [MCP guide](./docs/03-mcp.md) describes the default search tool and the optional
106
- full toolset, which retains managed rg.
114
+ </details>
115
+
116
+ #### For humans: search directly
107
117
 
108
- To search directly from the terminal, use the same local layer. See the
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 "theme preference persistence on startup" --limit 3
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
- > 🚧 **Work in progress.**
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&nbsp;quality&nbsp;↑ | Avg.&nbsp;input&nbsp;tokens&nbsp;↓ | Avg.&nbsp;tool&nbsp;calls&nbsp;↓ | Avg.&nbsp;agent&nbsp;time&nbsp;↓ |
142
+ | --- | ---: | ---: | ---: | ---: |
143
+ | [**SWE-QA-Bench**](./benchmarks/swe-qa-bench/README.md)<br>20 tasks · Codebase QA | Judge Score<br>80.42&nbsp;→&nbsp;81.92 | 558,651&nbsp;→&nbsp;294,262 | 23.42&nbsp;→&nbsp;9.70 | 127.5s&nbsp;→&nbsp;79.7s |
144
+ | [**BrowseComp-Plus**](./benchmarks/browse-comp-plus/README.md)<br>80 cases · Deep-research QA | Accuracy<br>90.00%&nbsp;→&nbsp;90.00% | 2.04M&nbsp;→&nbsp;1.19M | 22.70&nbsp;→&nbsp;14.24 | 284.8s&nbsp;→&nbsp;199.3s |
145
+
146
+ Values show **Baseline → zg**.
120
147
 
121
- ## 🗺️ Roadmap
148
+ See the [benchmark documentation](./benchmarks/README.md) for full results and
149
+ reproduction details.
122
150
 
123
- zg is moving toward richer multimodal formats, stronger hybrid retrieval, a
124
- more out-of-the-box experience, and support from desktop to mobile.
151
+ ## 📚 Documentation
125
152
 
126
- Explore the full [Roadmap](./docs/08-roadmap.md).
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="#quickstart">🚀 <strong>快速开始</strong></a> |
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
- 还是让 Agent 自主检索,只用 zg 即可。
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 集成、为仓库建索引并让 Agent 使用 zvec-grep 搜索代码" />
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
- - **开箱即用,零学习成本**:一套引导式安装即可在 macOS、Linux 和 Windows
53
- 上接入 Agent;直接用自然语言提问,无需学习搜索语法。
54
- - **一站式检索层**:语义发现、BM25 相关性检索、精确文本与正则搜索
55
- 都由 zg 统一提供。
56
- - **对 Agent 和开发者都友好**:为 Agent 提供紧凑、围绕文件组织的上下文,
57
- 为开发者提供易读的终端输出,双方都能减少无关噪声。
58
- - **本地优先、权限明确**:ripgrep、索引与本地模型均留在本机;远程 Embedding
59
- 需要显式授权。
60
-
61
- <a id="quickstart"></a>
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
- 需要 Node.js 22 或更新版本,支持 macOS、Linux 和 Windows。
59
+ ## 🚀 动手体验
66
60
 
67
- ### 1. 安装并连接 Agent
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
- `zg install` 会检测 Codex、Claude Code、Cursor 和 OpenCode,并配置本地 MCP 集成。
75
- 查看 [Agent 集成指南](./docs/01-agents.md),了解配置变更、权限和卸载方式。
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
- ```bash
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
- cd your-repository
86
- zg index --embedding local/potion-code-16m-v2
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
- 快速开始使用轻量的 [Potion Code v2](./docs/07-embedding.md),以便快速完成首次建索引。
90
- 第一次运行会下载模型,索引保存在 `.zvec-grep/` 下;后续更新只需运行
91
- `zg index`。查看 [检索 Pipeline](./docs/04-pipeline.md#indexing),进一步控制检索范围、
92
- 增量更新和重建。
87
+ Prompt 中没有指定任何工具,OpenCode 会自主选择 zg。
93
88
 
94
- ### 3. 直接向 Agent 提问
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
- Agent 会始终通过 zg 完成语义发现、关键词相关性检索与穷尽精确匹配。你无需
101
- 选择或调用其他搜索工具。[MCP 指南](./docs/03-mcp.md)介绍了 Agent 使用的两个工具。
114
+ </details>
115
+
116
+ #### 用户:直接检索
102
117
 
103
- 也可以直接在终端中使用同一个本地检索层。查看 [CLI 指南](./docs/02-cli.md),了解
104
- 搜索方式、过滤条件和输出控制。
118
+ 不通过 Agent,直接搜索同一个书架:
105
119
 
106
120
  ```bash
107
- zg query --human "theme preference persistence on startup" --limit 3
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
+ | 测试 | 回答质量&nbsp;↑ | 平均输入&nbsp;Token&nbsp;↓ | 平均工具调用&nbsp;↓ | 平均&nbsp;Agent&nbsp;耗时&nbsp;↓ |
138
+ | --- | ---: | ---: | ---: | ---: |
139
+ | [**SWE-QA-Bench**](./benchmarks/swe-qa-bench/README_CN.md)<br>20 个任务 · 代码库 QA | 评审得分<br>80.42&nbsp;→&nbsp;81.92 | 558,651&nbsp;→&nbsp;294,262 | 23.42&nbsp;→&nbsp;9.70 | 127.5s&nbsp;→&nbsp;79.7s |
140
+ | [**BrowseComp-Plus**](./benchmarks/browse-comp-plus/README_CN.md)<br>80 个样例 · 深度研究 QA | 准确率<br>90.00%&nbsp;→&nbsp;90.00% | 2.04M&nbsp;→&nbsp;1.19M | 22.70&nbsp;→&nbsp;14.24 | 284.8s&nbsp;→&nbsp;199.3s |
141
+
142
+ 表中数值均按 **Baseline → zg** 展示。
115
143
 
116
- ## 🗺️ Roadmap
144
+ 完整结果和复现细节参见[性能测试文档](./benchmarks/README_CN.md)。
117
145
 
118
- zg 正在迈向更丰富的多模态格式、更强的混合检索、更开箱即用的体验,以及从
119
- 桌面端到移动端的全平台支持。
146
+ ## 📚 文档
120
147
 
121
- 查看完整 [Roadmap](./docs/08-roadmap.md)。
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 run");
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 run");
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) {