@jayyuen66/dsh-zvec-grep 0.1.8 → 0.1.10
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/CHANGELOG.md +51 -0
- package/LICENSE +1 -1
- package/README.md +4 -3
- package/README.zh-CN.md +4 -3
- package/THIRD_PARTY_NOTICES.md +18 -9
- package/client.js +769 -376
- package/docs/DETAIL.md +28 -0
- package/docs/DETAIL.zh.md +28 -0
- package/host.js +505 -188
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +58 -42
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Zvec indexed search
|
|
2
|
+
|
|
3
|
+
Searches the workspace through a local index instead of raw grep, and can require an indexed search before plain `grep` / `rg` are allowed.
|
|
4
|
+
|
|
5
|
+
## What the card changes
|
|
6
|
+
|
|
7
|
+
- **Search model** — `defaultEmbedding` (default `local/qwen3-embedding-0.6b`, about 640 MB) applies to **new** indexes only; an existing index keeps its model until it is rebuilt. `defaultLimit` (1–50, default 10) is how many hits each result group returns.
|
|
8
|
+
- **Network and indexing** — `hfEndpoint` defaults to the ModelScope mirror (`https://modelscope.cn/models`); leaving it empty means huggingface.co, which this environment typically cannot reach, so the default should stay. `enforceSearchFirst` (on) gates `grep` / `rg` inside indexed workspaces. `grepBudgetPerSearch` (default 3) is how many plain searches each successful `zg_search` unlocks, and `unlockWindowMin` (default 10) is how many minutes that unlock stays valid. Expiry is checked whenever the budget is read, so an elapsed window stops granting searches without a restart; the per-session table keeps at most 256 sessions and evicts the least recently used one first. When the step's tool admission does not include `zg_search`, the gate stands down rather than forcing a call the step cannot make.
|
|
9
|
+
|
|
10
|
+
These are read per call and take effect without restarting the host.
|
|
11
|
+
|
|
12
|
+
## The Rebuild action is not a setting
|
|
13
|
+
|
|
14
|
+
The card's Rebuild button runs the equivalent of `zg index --rebuild` for a workspace the daemon has already observed; it is an action, not a stored preference. No approval prompt fires on this path: the pre-execute approval only covers the `zg_*` tools when they name an explicit root, and Remote methods do not go through tool admission. What guards the action is the daemon's list of observed roots (plus its own single-operation lock).
|
|
15
|
+
|
|
16
|
+
## Restart-only values
|
|
17
|
+
|
|
18
|
+
Ten deployment values stay off the card: `searchTimeoutMs` (300000), `statusTimeoutMs` (60000), `indexTimeoutMs` (600000), `stdoutMaxBytes` (400000), `rebuildWaitMs`, `clientMode` (`auto` / `direct` / `server`), `allowRemoteEmbedding` (false), `remoteEmbeddingEndpoint`, `remoteEmbeddingApiKeyFrom`, `requireApprovalForExplicitRoot` (false).
|
|
19
|
+
|
|
20
|
+
Whether workspace content may leave the machine at all is treated as a deployment decision rather than a model-visible choice, which is why the remote-embedding trio appears in neither the card nor the tool parameters; and even when it is enabled, `zg` itself still requires `--allow-remote` or `zg auth grant`. Set all of these in the `config:` block of this plugin's row in your profile's `cordis.yml` (the `cordis.patch.yml` shipped in this package only carries the row's `id` / `name`); they take effect on restart.
|
|
21
|
+
|
|
22
|
+
## What it needs from outside
|
|
23
|
+
|
|
24
|
+
The external `zg` CLI (`@zvec/zvec-grep`, installed with `npm install -g @zvec/zvec-grep`). The plugin enforces a version floor of **0.2.2** before it builds any command and says so when the installed one is older; a missing CLI is reported as such instead of failing a search. Incremental index refresh, `refresh=background` and the resident model pool need the daemon running (`zg server on`) — when it is offline the card says so. Local embedding backends may require their own native dependency (llama-cpp needs `node-llama-cpp`; model2vec and transformers-js are pure JavaScript). When `allowRemoteEmbedding` is on, the plugin forwards two variables to `zg`: `ZVEC_GREP_ENDPOINT` carries the literal value of `remoteEmbeddingEndpoint` (the deployment endpoint, not a variable name), and `ZVEC_GREP_API_KEY` is the secret looked up from the variable named by `remoteEmbeddingApiKeyFrom`. The key is passed explicitly because the host's subprocess layer strips secret-shaped variables.
|
|
25
|
+
|
|
26
|
+
## Further detail
|
|
27
|
+
|
|
28
|
+
The error-code table, the argument guards and the background-job surface are in the package README (`README.md` / `README.zh-CN.md`).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Zvec 索引检索
|
|
2
|
+
|
|
3
|
+
用本地索引检索工作区,而不是裸 grep;也可以要求先走一次索引检索,才允许用普通 `grep` / `rg`。
|
|
4
|
+
|
|
5
|
+
## 设置卡上改的是什么
|
|
6
|
+
|
|
7
|
+
- **检索模型** — `defaultEmbedding`(默认 `local/qwen3-embedding-0.6b`,约 640 MB)只作用于**新建**的索引;已有索引沿用它自己的模型,要换得先重建。`defaultLimit`(1–50,默认 10)是每组结果返回多少条命中。
|
|
8
|
+
- **网络与索引** — `hfEndpoint` 默认指向 ModelScope 镜像(`https://modelscope.cn/models`);留空就是 huggingface.co,而这个环境通常连不上,所以默认值应当保留。`enforceSearchFirst`(默认开)在已建索引的工作区里拦住 `grep` / `rg`。`grepBudgetPerSearch`(默认 3)是一次成功的 `zg_search` 解锁多少次直查,`unlockWindowMin`(默认 10)是这份解锁维持几分钟。有效期在每次取用配额时现判,窗口一过就不再放行直查、不需要重启;分片表按会话数封顶 256,超出时先淘汰最久未用的那一份。本步骤的工具准入不含 `zg_search` 时,门禁让路,不强迫模型去调一个本步骤调不动的工具。
|
|
9
|
+
|
|
10
|
+
这些每次调用现读,改完不需要重启宿主。
|
|
11
|
+
|
|
12
|
+
## Rebuild 不是设置项
|
|
13
|
+
|
|
14
|
+
卡上的 Rebuild 是对守护进程已经观察到的工作区跑一次等价于 `zg index --rebuild` 的动作,不是被存起来的偏好。这条路上不会弹审批:pre-execute 审批只覆盖显式给了 root 的 `zg_*` 工具,Remote 方法不走工具准入;真正管住它的是守护进程那份已观测根白名单(以及它自己的单操作锁)。
|
|
15
|
+
|
|
16
|
+
## 要重启的值
|
|
17
|
+
|
|
18
|
+
十项部署值刻意不进设置卡:`searchTimeoutMs`(300000)、`statusTimeoutMs`(60000)、`indexTimeoutMs`(600000)、`stdoutMaxBytes`(400000)、`rebuildWaitMs`、`clientMode`(`auto` / `direct` / `server`)、`allowRemoteEmbedding`(false)、`remoteEmbeddingEndpoint`、`remoteEmbeddingApiKeyFrom`、`requireApprovalForExplicitRoot`(false)。
|
|
19
|
+
|
|
20
|
+
「工作区内容能不能离开本机」被当成部署决定,而不是给模型选的开关,所以远程嵌入那三枚既不在卡上也不在工具参数里;即便开了,`zg` 自己仍要求 `--allow-remote` 或 `zg auth grant`。这些值都写在**自己 profile 的 `cordis.yml`** 里本插件注册行的 `config:` 块(随包那份 `cordis.patch.yml` 只带 `id` / `name` 两行),改值随重启生效。
|
|
21
|
+
|
|
22
|
+
## 需要外部提供什么
|
|
23
|
+
|
|
24
|
+
外部 `zg` 命令行(`@zvec/zvec-grep`,装法是 `npm install -g @zvec/zvec-grep`)。本插件在拼出任何命令之前先校版本,地板是 **0.2.2**,装的版本低于它会直接说明;命令行不存在时按「未安装」报,而不是伪装成一次查不到。增量索引刷新、`refresh=background` 与常驻模型池都需要守护进程在跑(`zg server on`),离线时卡上会写出来。本地嵌入的后端可能还要各自的依赖(llama-cpp 需要 `node-llama-cpp`;model2vec 与 transformers-js 是纯 JavaScript)。只有 `allowRemoteEmbedding` 开着时,插件才向 `zg` 转发这两个变量:`ZVEC_GREP_ENDPOINT` 放的是 `remoteEmbeddingEndpoint` 的字面值(部署端点,不是变量名),`ZVEC_GREP_API_KEY` 才是按 `remoteEmbeddingApiKeyFrom` 指的变量名去环境里查出来的密钥。密钥要显式转发,因为宿主的子进程层会抹掉形似密钥的变量。
|
|
25
|
+
|
|
26
|
+
## 更完整的说明
|
|
27
|
+
|
|
28
|
+
错误码表、参数守卫与后台作业面都写在随包 README(`README.md` / `README.zh-CN.md`)。
|