@jayyuen66/dsh-zvec-grep 0.1.9 → 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 +22 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/THIRD_PARTY_NOTICES.md +10 -3
- package/client.js +45 -67
- package/docs/DETAIL.md +4 -4
- package/docs/DETAIL.zh.md +4 -4
- package/host.js +475 -182
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## 0.1.10
|
|
6
|
+
|
|
7
|
+
一轮跨面审查修复:search-first 门禁的词法判据重建、重建注册表代次化,状态读面与发布链收口。
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **发布链加固**(`.github/workflows/publish.yml`):分支守卫改比完整 `refs/heads/` ref;npm token 形态校验(`ghp_`/非 `npm_` 前缀拒用);发布对象改为 check 验过的那枚 tarball 本体、不再解包重打;发布前查 registry 版本占用,发布后轮询可见性(上限 5 分钟)。ci.yml 的 attest 限默认分支 dispatch;actionlint 的 SC2016 豁免从全局 `-ignore` 收窄为按文件 `-config-file`。
|
|
12
|
+
- **依赖与元数据**:author 改对象形(带 URL);`@deepseek-ai/schemastery` peer 放宽为 `^3.18.6-alpha.1`;devDependencies 新增 fast-check 4.10.2;catalog 的 shared 抬到 0.2.2;LICENSE 署名同步。
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **门禁词法**(`lib/search-predicates.ts`):包装命令取值旗标按包装名分表(sudo/time/git/xargs 各自的 `-n/-p/-E/-r/-t` 不再误吞真命令);新增检索侧取值旗标表与重定向标记(`grep foo src > /tmp/out` 的落点不算操作数);组字符只在独立成词时分隔(`${DIR}/src` 不再被切碎放行);命令位绝对路径不再当根外目标。
|
|
17
|
+
- **重建注册表代次化**(`lib/rebuild-state.ts`):`release`/`attach` 增加可选 claim 凭据校验,迟到收尾不再删改同根新条目;`wait` 改递归 `waitCovering`,祖先+后代同时覆盖时逐轮都等;全部键经 `normalizeRoot`。
|
|
18
|
+
- **状态读面**(`host.ts`、`lib/rebuild-remote.ts`):zg_status 的锁忙 stderr 不再被吸收成「未就绪」;`comparablePath` 的 `/private` 剥除加 darwin 门控;超时 `jobs.kill` 包 try、失效退回 `killProc`;历史裁剪按 `startedAt` 排序;`roots()` 探测失败不再连带白名单不可用;超时分钟数 `Math.max(1, ceil)`。
|
|
19
|
+
- **卡片与草稿**(`lib/card-logic.ts`、`lib/card-draft.ts`、`src/client-entry.ts`):端点草稿逐字回显,键入中不被 URL 校验吞;草稿/已提交两层都只判自有属性;useRebuild 加 jobRef 代次与重挂置真。
|
|
20
|
+
- **散修**:`lib/cli.ts` 查询串改 `--hybrid=` 等号拼值(`-` 开头的查询不再被当旗标)、embedding 引用 trim;`lib/messages.ts` `fill()` 只取自有属性;`lib/argv-guard.ts` 计数改过滤后长度;`lib/index-preflight.ts` 增 ENAMETOOLONG;`lib/sandbox-note.ts` trim 加「unknown」兜底;`lib/zg-errors.ts` 明细只认第一个错误块;`lib/zg-config.ts` 远程端点走与 HF 镜像同一套规范化校验;`lib/embedding-catalog.ts` 目录深冻结。
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **测试三层**:`test/platform/platform.test.ts`(平台门控/win32 根拒绝/CRLF/shq 往返)、`test/property/` 三件(paths、rebuild-state、zg-errors,fast-check)、`test/sandbox-note.test.ts`、`test/zg-config.test.ts`。
|
|
25
|
+
|
|
5
26
|
## 0.1.9
|
|
6
27
|
|
|
7
28
|
这一版让 search-first 门禁认识宿主的步骤准入,并把设置卡与读面校验统一到 shared 组件和 zod;
|
|
@@ -168,6 +189,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
168
189
|
- `@deepseek-ai/dsh-*` 家族与 peer 的 `@deepseek-ai/dsh` 从 `0.2.1-alpha.1` 升到 `0.2.1-alpha.2`;`@deepseek-ai/cordis` `4.0.5-alpha.1`、`@deepseek-ai/schemastery` `3.18.5-alpha.1`、`@deepseek-ai/cordis-plugin-timer` `1.1.7-alpha.1` **不动**——那是 alpha.2 自己钉的那几枚,registry 上没有更新的 alpha。
|
|
169
190
|
- `pnpm-workspace.yaml` 整体换成与 `dsh-danger-guard` / `dsh-plugin-shared` 逐字节相同的那一份:`dsh-*` 86 枚 override 跟到 alpha.2,工具链跟到 registry 现行头(`@types/node` 26.6.3→26.6.5、`vitest` 与 `@vitest/coverage-v8` 5.0.2→5.0.3、`vite` 8.3.1→8.3.4、`rolldown` 1.2.11→1.2.13、`oxlint` 1.86.0→1.87.0、`oxfmt` 0.71.0→0.72.0、`oxlint-tsgolint` 7.0.2003→7.0.2004、`happy-dom` 20.14.5→20.14.6、`jsdom` 30.1.1→30.1.2)。`@jayyuen66/dsh-plugin-shared` `^0.1.3`→`^0.1.4`(实装的 0.1.2 比声明还旧,锁文件已过期)。
|
|
170
191
|
- `engines` 取严格口径:`dsh: >=0.2.1-alpha.2`(shared 0.1.4 自己的 `engines.dsh` 就是这个下限,声明得更宽等于撒谎)、`node: ^22.19.0 || >=24.0.0`(同取自 shared)。宿主按 **peer 声明**判兼容、不读 `engines.dsh`,且逐条比对每一枚 `@deepseek-ai/dsh*`——本包的精确钉因此意味着**高于 0.2.1-alpha.2 的宿主也需要 `dsh plugin allow-version … --accept-risk`**,两份 README 已按实测写明。
|
|
192
|
+
(更正:宿主判据与上面这句相反——`engine.dsh` 在场时它**先判这一条且单独决定**,`peerDependencies` 根本不参与比较,比较时还带 `includePrerelease`(见 deepseek-harness `packages/boot/app-boot/src/plugin-compatibility.ts` 的 `satisfies` 与 `unmetRequirements`)。本包现行的 `engines.dsh` 是 `^0.2.1-rc.3`、`node` 是 `>=22.12.0`,两份 README 已按现行口径写。)
|
|
171
193
|
- README 拆成中英两份:`README.md` 为英文、`README.zh-CN.md` 为中文,两份顶部互链。原来是一份文件里的 `## 中文` / `## English` 两段,正文一字未改地按语言切开。
|
|
172
194
|
- 注释里「钉进依赖 `.d.ts` 的行号」全量换成文件 + 符号/原文锚点。抽查即见腐坏:`dsh-tools` 那组(`ToolDefinition` / `ToolGuard` / `ToolRuntime`)随 alpha.2 整体漂了 7–17 行,`tool.execute` 的调用点也是。测试夹具里的 `src/beta.ts:1-3` 那类是 **数据**(zg 的输出形态),不在射程内。
|
|
173
195
|
- `.github/workflows/publish.yml` 跟 `dsh-danger-guard` 同款加固:`concurrency` 防两次 dispatch 并行、action 钉 commit SHA、预检加「读本包」这一档(只查依赖就发现不了「版本号没进 main 就触发」)、发布用的 `NODE_AUTH_TOKEN` 走与预检同款清洗、加 `--provenance` 与 `--publish-wait-timeout 600000`,并且不再把凭据长度打进日志。
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ dsh plugin --profile web add @jayyuen66/dsh-zvec-grep
|
|
|
77
77
|
Remove with `dsh plugin --profile web remove @jayyuen66/dsh-zvec-grep`. The package is on the public npm registry; no credentials, no scoped-registry line.
|
|
78
78
|
|
|
79
79
|
- **Node.js `>= 22.12`** (ESM-only; that floor is what makes `require()` of an ESM entry work, hence `engines.node`).
|
|
80
|
-
- **Host `dsh` on the `0.2.1-rc.3` line.** The host reads `engines.dsh` (`^0.2.1-rc.3`) and it **decides alone** - with that field present, compatibility is judged before `peerDependencies` is ever consulted, prereleases included. Any `0.2.x` at or above `0.2.1-rc.3` passes; `0.3.0` and later need the risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against the three most recently released host versions at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
|
|
80
|
+
- **Host `dsh` on the `0.2.1-rc.3` / `0.2.2-alpha.2` line.** The host reads `engines.dsh` (`^0.2.1-rc.3`) and it **decides alone** - with that field present, compatibility is judged before `peerDependencies` is ever consulted, prereleases included. Any `0.2.x` at or above `0.2.1-rc.3` passes; `0.3.0` and later need the risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against the three most recently released host versions at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
|
|
81
81
|
- **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts`). Profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package there becomes a real second copy; `@deepseek-ai/dsh-tools` keys its scheduler with a plain `Symbol`, so **every native tool call throws** in that profile while build, typecheck and coverage stay green. The `@deepseek-ai/dsh*` peers carry the same support-window range (`^0.2.1-rc.3`), while the exact pins in `devDependencies` are the compile-time discipline against a second host type surface - not a claim the host consults.
|
|
82
82
|
- **Value imports are required peers.** `@deepseek-ai/schemastery` is the host fork (only its `resolve` wraps `.volatile()` fields); `@deepseek-ai/dsh-typert-protocol` provides `TypertRemoteService`, a class to `extends`; `@deepseek-ai/dsh-scope` provides `scopeOf` for the step-admission lookup; shared's `lib/text` value-imports `@deepseek-ai/dsh-output-retention`. Each sits in `peerDependencies` plus the same exact pin in `devDependencies` - missing one is `ERR_MODULE_NOT_FOUND` at load, not a graceful downgrade. `dependencies` holds `@jayyuen66/dsh-plugin-shared` and `zod` (the latter versioned through the umbrella catalog, used by the settings card's strict codecs).
|
|
83
83
|
- **What ships**: `host.js`, `client.js`, `cordis.patch.yml`, `icon.svg`, both READMEs, `CHANGELOG.md`, `THIRD_PARTY_NOTICES.md`. Artifacts are rebuilt by `prepack`, never committed.
|
package/README.zh-CN.md
CHANGED
|
@@ -77,7 +77,7 @@ dsh plugin --profile web add @jayyuen66/dsh-zvec-grep
|
|
|
77
77
|
卸载用 `dsh plugin --profile web remove @jayyuen66/dsh-zvec-grep`。包在公共 npm registry 上,不需要凭据,也不需要 scoped-registry 配置行。
|
|
78
78
|
|
|
79
79
|
- **Node.js `>= 22.12`**(纯 ESM;正是这个下限让 `require()` 一枚 ESM 入口成为可能,`engines.node` 因此声明)。
|
|
80
|
-
- **宿主 `dsh` 在 `0.2.1-rc.3` 这条线上。** 宿主读 `engines.dsh`(`^0.2.1-rc.3`)且**单独决定**——该字段在场时兼容性先于 `peerDependencies` 判定,prerelease 参与比较。`0.2.x` 里不低于 `0.2.1-rc.3` 的都通过;`0.3.0` 及以上需要风险授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <确切版本> --accept-risk`。支持窗口是滚动的:本包在发布时最近的三个已发布宿主版本上逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
|
|
80
|
+
- **宿主 `dsh` 在 `0.2.1-rc.3` / `0.2.2-alpha.2` 这条线上。** 宿主读 `engines.dsh`(`^0.2.1-rc.3`)且**单独决定**——该字段在场时兼容性先于 `peerDependencies` 判定,prerelease 参与比较。`0.2.x` 里不低于 `0.2.1-rc.3` 的都通过;`0.3.0` 及以上需要风险授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <确切版本> --accept-risk`。支持窗口是滚动的:本包在发布时最近的三个已发布宿主版本上逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
|
|
81
81
|
- **按契约,`dependencies` 下不放任何 `@deepseek-ai/*`**(`test/publish-manifest.test.ts` 钉住)。profile 以 `nodeLinker: hoisted` 与 `autoInstallPeers: false` 安装,宿主包在那里会落成真实的第二份副本;`@deepseek-ai/dsh-tools` 用普通 `Symbol` 给调度器做键,那个 profile 里**每一次原生工具调用都抛错**,而构建、类型检查与覆盖率照绿。`@deepseek-ai/dsh*` 的 peer 写同一条支持窗口范围(`^0.2.1-rc.3`),`devDependencies` 里的精确钉版才是防「第二份宿主类型面」的编译期纪律——那不是宿主会去读的声明。
|
|
82
82
|
- **值导入都是必需 peer。** `@deepseek-ai/schemastery` 是宿主 fork(只有它的 `resolve` 认 `.volatile()` 字段);`@deepseek-ai/dsh-typert-protocol` 提供 `TypertRemoteService` 这个要 `extends` 的类;`@deepseek-ai/dsh-scope` 提供步骤准入判定用的 `scopeOf`;shared 的 `lib/text` 自己值导入 `@deepseek-ai/dsh-output-retention`。四者都落 peer 加同版精确钉的 devDependencies——缺一枚就是装载期 `ERR_MODULE_NOT_FOUND`,不是优雅降级。`dependencies` 里是 `@jayyuen66/dsh-plugin-shared` 与 `zod`(后者版本走伞根 catalog,供设置卡的 strict codec 校验)。
|
|
83
83
|
- **随包发什么**:`host.js`、`client.js`、`cordis.patch.yml`、`icon.svg`、两份 README、`CHANGELOG.md`、`THIRD_PARTY_NOTICES.md`。产物由 `prepack` 现产,不入库。
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -13,11 +13,18 @@
|
|
|
13
13
|
上游由用户自行 `npm install -g @zvec/zvec-grep` 安装。正因如此,本包不随包附上游的许可文本:
|
|
14
14
|
Apache-2.0 第 4 条的再分发条件挂在「被再分发的第三方代码」上,而本包里没有那段代码。若把两者
|
|
15
15
|
打包在一起再分发,请按各自许可分别保留声明。
|
|
16
|
+
- 派生数据:`lib/embedding-catalog.ts` 的本地模型条目抄自上游 `0.2.2` 的 `EMBEDDING_MODEL_CATALOG`
|
|
17
|
+
(只取「引用 / 后端 / 维度」三列),`lib/routing.ts` 的工作区清单文件名等常量与上游同名同值。这些
|
|
18
|
+
是名称与数值一类的派生数据,不含上游实现代码;上游改了名称表时由 `verify:env` 与这一族用例发现。
|
|
19
|
+
再分发时请连同上游的 Apache-2.0 声明一起保留。
|
|
16
20
|
- 版本契约:命令形态与旗标名按 `0.2.2` 书写;低于该版本本包在下发任何命令之前停住并点名实际版本
|
|
17
21
|
(判据在 `lib/zg-version.ts`)。这是本包自负的责任边界——上游改了旗标语义却没升主版本时,只有
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
22
|
+
这一族用例与那道版本门能发现。这道门是 **fail-open**:只认「整串就是一个三段数字」(`v` 前缀与
|
|
23
|
+
首尾空白容忍),读不懂(多行、`0.2.2-rc.1`、`>=0.2.2`、探测失败)一律放行而不是拦死命令——把
|
|
24
|
+
「探测不到」判成「太旧」,等于拿一个猜出来的版本拦住真实用户。
|
|
25
|
+
- 数据边界:索引与向量库(`.zvec-grep/`、`manifest.json`)由上游读写。本包只读 `manifest.json` 的
|
|
26
|
+
`manifestVersion` 与 `rootPaths[].absolutePath`,用于「这份清单是不是本包认得的索引、覆不覆盖目标根」
|
|
27
|
+
的判定;其余字段与索引本体不解析,也从不写入或改写。
|
|
21
28
|
|
|
22
29
|
## 编译期与运行期依赖
|
|
23
30
|
|
package/client.js
CHANGED
|
@@ -17,16 +17,7 @@ const DEFAULT_EMBEDDING = "local/qwen3-embedding-0.6b";
|
|
|
17
17
|
* 而不是静默产出一个不在联合里的字符串。
|
|
18
18
|
*/
|
|
19
19
|
const TRANSFORMERS_JS_BACKEND = "transformers-js";
|
|
20
|
-
|
|
21
|
-
* 本地候选清单,按后端分三档(体积/语言口径,实测 zg v0.2.1):
|
|
22
|
-
* - llama-cpp:qwen3-embedding-0.6b 约 640MB(本包默认)、
|
|
23
|
-
* embeddinggemma-300m 约 300MB(英文)——两档都要原生件,Metal 加速由 zg 侧 device=auto 试;
|
|
24
|
-
* - model2vec:potion-code-16m-v2 约 32MB(代码专用、最轻最快)、potion-multilingual-128m
|
|
25
|
-
* (多语言轻量)、potion-retrieval-32m(通用检索)——纯 JS worker,零原生依赖;
|
|
26
|
-
* - transformers-js:其余 ONNX 小模型,384 维那批是英文/多语言轻量档,768 维那批里
|
|
27
|
-
* jina 面向代码、gte/nomic 面向 8192 长文。
|
|
28
|
-
*/
|
|
29
|
-
const LOCAL_EMBEDDINGS = [
|
|
20
|
+
const LOCAL_EMBEDDINGS = Object.freeze([
|
|
30
21
|
{
|
|
31
22
|
reference: "local/qwen3-embedding-0.6b",
|
|
32
23
|
backend: "llama-cpp",
|
|
@@ -82,7 +73,7 @@ const LOCAL_EMBEDDINGS = [
|
|
|
82
73
|
backend: TRANSFORMERS_JS_BACKEND,
|
|
83
74
|
dimension: 768
|
|
84
75
|
}
|
|
85
|
-
];
|
|
76
|
+
].map((entry) => Object.freeze(entry)));
|
|
86
77
|
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
|
|
87
78
|
function e$2(t, n, r) {
|
|
88
79
|
if (t == null || n == null) return (t ?? null) === (n ?? null);
|
|
@@ -632,10 +623,14 @@ function S(t) {
|
|
|
632
623
|
}
|
|
633
624
|
// lib/card-draft.ts
|
|
634
625
|
/** 草稿优先取值:touched 有该键(哪怕值是 undefined=待清空)即用草稿。
|
|
635
|
-
*
|
|
636
|
-
* `constructor` 这类继承键,把 Object.prototype
|
|
626
|
+
* 两层都只判**自有**属性:本函数收任意字段名,`in`/裸下标会沿原型链命中 `toString` /
|
|
627
|
+
* `constructor` 这类继承键,把 Object.prototype 的成员当成已提交值交出去。 */
|
|
628
|
+
function hasDraft(touched, field) {
|
|
629
|
+
return Object.hasOwn(touched, field);
|
|
630
|
+
}
|
|
637
631
|
function draftOf(touched, value, field) {
|
|
638
|
-
|
|
632
|
+
if (hasDraft(touched, field)) return touched[field];
|
|
633
|
+
return Object.hasOwn(value, field) ? value[field] : void 0;
|
|
639
634
|
}
|
|
640
635
|
/** 数值型输入的显示文本:非有限数(含 undefined)回落到默认文案。 */
|
|
641
636
|
function numberText(raw, fallback) {
|
|
@@ -689,69 +684,48 @@ function cardStore(scope) {
|
|
|
689
684
|
/**
|
|
690
685
|
* 三个数值字段的显示值都是「草稿优先 + 默认文案」,且共享同一条清空语义:
|
|
691
686
|
* touched 里显式写了 undefined(用户清空输入)= 待 unset,显示空串;「从没动过、
|
|
692
|
-
*
|
|
693
|
-
*
|
|
687
|
+
* 快照里也没有」不是清空,显示默认文案。判据统一收在这里,与卡片数值控件
|
|
688
|
+
* (numberDisplay / NumberField)的「清空即回『未填』」对齐。
|
|
694
689
|
*/
|
|
695
690
|
function numericFieldDisplay(touched, value, field, fallback) {
|
|
696
691
|
const draft = draftOf(touched, value, field);
|
|
697
|
-
if (draft === void 0) return
|
|
692
|
+
if (draft === void 0) return hasDraft(touched, field) ? "" : fallback;
|
|
698
693
|
return numberText(draft, fallback);
|
|
699
694
|
}
|
|
700
|
-
/**
|
|
695
|
+
/** 已提交端点值只收 HTTP(S);坏文本显示成空(输入框里键入的草稿不走这条过滤)。 */
|
|
701
696
|
const HTTP_URL_SCHEMA = zod.z.url({ protocol: /^https?$/u });
|
|
697
|
+
/**
|
|
698
|
+
* 端点字段的显示值:**草稿优先**,与三个数值字段同一条清空语义。
|
|
699
|
+
*
|
|
700
|
+
* 用户正在逐字键入时,草稿是「这一格此刻的文本」而不是待校验的值——半截 URL
|
|
701
|
+
* 必须原样回显,否则输入第一个字符就被过滤成空串、删掉已提交 URL 的一个字符就整格清空。
|
|
702
|
+
* 只有「这一格没动过、显示的是已提交快照」时才过 HTTP(S) 形态过滤:脏快照不该显示成
|
|
703
|
+
* 一个看起来能保存的地址。
|
|
704
|
+
*/
|
|
705
|
+
function endpointFieldDisplay(touched, value) {
|
|
706
|
+
if (Object.hasOwn(touched, "hfEndpoint")) {
|
|
707
|
+
const draft = touched["hfEndpoint"];
|
|
708
|
+
return typeof draft === "string" ? draft : "";
|
|
709
|
+
}
|
|
710
|
+
const committed = value["hfEndpoint"];
|
|
711
|
+
return typeof committed === "string" && HTTP_URL_SCHEMA.safeParse(committed).success ? committed : "";
|
|
712
|
+
}
|
|
702
713
|
/** 六个字段的草稿显示值(ZgCard 只渲染这里算出来的东西)。 */
|
|
703
714
|
function draftFields(touched, value) {
|
|
704
715
|
const embedding = draftOf(touched, value, "defaultEmbedding");
|
|
705
|
-
const endpoint = draftOf(touched, value, "hfEndpoint");
|
|
706
716
|
const enforce = draftOf(touched, value, "enforceSearchFirst");
|
|
707
717
|
return {
|
|
708
718
|
embedding: typeof embedding === "string" && embedding.length > 0 ? embedding : DEFAULT_EMBEDDING,
|
|
709
719
|
limitDisplay: numericFieldDisplay(touched, value, "defaultLimit", String(10)),
|
|
710
|
-
hfEndpoint:
|
|
720
|
+
hfEndpoint: endpointFieldDisplay(touched, value),
|
|
711
721
|
enforceSearchFirst: enforce !== false,
|
|
712
722
|
grepBudget: numericFieldDisplay(touched, value, "grepBudgetPerSearch", String(3)),
|
|
713
723
|
unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10))
|
|
714
724
|
};
|
|
715
725
|
}
|
|
716
|
-
/** 三个数值字段的 zod 域:输入校验与卡片显示共用,host schema 的区间是同一组常量。 */
|
|
717
726
|
const LIMIT_SCHEMA = zod.z.int().min(1).max(50);
|
|
718
727
|
const BUDGET_SCHEMA = zod.z.int().min(1).max(20);
|
|
719
728
|
const WINDOW_SCHEMA = zod.z.int().min(1).max(240);
|
|
720
|
-
function resolveLimitInput(raw, t) {
|
|
721
|
-
const trimmed = raw.trim();
|
|
722
|
-
if (trimmed.length === 0) return { kind: "empty" };
|
|
723
|
-
const num = Number(trimmed);
|
|
724
|
-
const parsed = LIMIT_SCHEMA.safeParse(num);
|
|
725
|
-
if (parsed.success) return {
|
|
726
|
-
kind: "valid",
|
|
727
|
-
value: parsed.data
|
|
728
|
-
};
|
|
729
|
-
if (!Number.isSafeInteger(num)) return {
|
|
730
|
-
kind: "invalid",
|
|
731
|
-
hint: t("limitInvalid", {
|
|
732
|
-
min: 1,
|
|
733
|
-
max: 50
|
|
734
|
-
})
|
|
735
|
-
};
|
|
736
|
-
if (num < 1) return {
|
|
737
|
-
kind: "clamped",
|
|
738
|
-
value: 1,
|
|
739
|
-
hint: t("limitClamped", {
|
|
740
|
-
min: 1,
|
|
741
|
-
max: 50,
|
|
742
|
-
value: 1
|
|
743
|
-
})
|
|
744
|
-
};
|
|
745
|
-
return {
|
|
746
|
-
kind: "clamped",
|
|
747
|
-
value: 50,
|
|
748
|
-
hint: t("limitClamped", {
|
|
749
|
-
min: 1,
|
|
750
|
-
max: 50,
|
|
751
|
-
value: 50
|
|
752
|
-
})
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
729
|
/** 轮询应答的宽容形状:未知状态、非数字退出码、非字符串输出都折成缺位,
|
|
756
730
|
* 下游文案只按“缺位”兜底,不把坏类型带到渲染期。 */
|
|
757
731
|
const REBUILD_STATUSES = [
|
|
@@ -815,8 +789,8 @@ function parseOrThrow(schema, value) {
|
|
|
815
789
|
if (!parsed.success) throw new TypeError(zod.z.prettifyError(parsed.error));
|
|
816
790
|
return parsed.data;
|
|
817
791
|
}
|
|
818
|
-
const START_SCHEMA = zod.z.object({ root: zod.z.string({ error: "rebuild request requires a string root" }) }, { error: "rebuild request requires a string root" });
|
|
819
|
-
const STATUS_SCHEMA = zod.z.object({ jobId: zod.z.string({ error: "rebuild status request requires a string jobId" }) }, { error: "rebuild status request requires a string jobId" });
|
|
792
|
+
const START_SCHEMA = zod.z.object({ root: zod.z.string({ error: "rebuild request requires a string root" }).trim().min(1, { error: "rebuild request requires a non-empty root" }) }, { error: "rebuild request requires a string root" });
|
|
793
|
+
const STATUS_SCHEMA = zod.z.object({ jobId: zod.z.string({ error: "rebuild status request requires a string jobId" }).trim().min(1, { error: "rebuild status request requires a non-empty jobId" }) }, { error: "rebuild status request requires a string jobId" });
|
|
820
794
|
/** 把宿主那三个方法挂到客户端远程面上的描述符(`id` 的形状照生成器:`<包>#<命名空间>/<方法>`)。
|
|
821
795
|
* 导出它只为一件事:`test/rebuild-remote.test.ts` 拿它与宿主侧 `remoteMethods()` 的标记对质
|
|
822
796
|
* —— 两侧分叉时卡片不会报错,只会"读不到",所以那条比较必须在门禁里。 */
|
|
@@ -904,7 +878,7 @@ function buildRebuildReader(ctx) {
|
|
|
904
878
|
mounted = void 0;
|
|
905
879
|
throw error;
|
|
906
880
|
}
|
|
907
|
-
const namespace = ctx.get?.(REBUILD_SERVICE_KEY
|
|
881
|
+
const namespace = ctx.get?.(REBUILD_SERVICE_KEY);
|
|
908
882
|
if (!isRebuildNamespace(namespace)) throw new Error(`${REBUILD_SERVICE_KEY} 未提供:宿主网关没有挂上这枚命名空间`);
|
|
909
883
|
return namespace;
|
|
910
884
|
};
|
|
@@ -1343,17 +1317,22 @@ function useRebuild(t, reader) {
|
|
|
1343
1317
|
});
|
|
1344
1318
|
const pollRef = (0, react.useRef)(null);
|
|
1345
1319
|
const pollingRef = (0, react.useRef)(false);
|
|
1320
|
+
const jobRef = (0, react.useRef)(null);
|
|
1346
1321
|
const mountedRef = (0, react.useRef)(true);
|
|
1347
1322
|
const isMounted = () => mountedRef.current;
|
|
1348
1323
|
function stopPolling() {
|
|
1324
|
+
jobRef.current = null;
|
|
1349
1325
|
if (pollRef.current !== null) {
|
|
1350
1326
|
clearInterval(pollRef.current);
|
|
1351
1327
|
pollRef.current = null;
|
|
1352
1328
|
}
|
|
1353
1329
|
}
|
|
1354
|
-
(0, react.useEffect)(() =>
|
|
1355
|
-
mountedRef.current =
|
|
1356
|
-
|
|
1330
|
+
(0, react.useEffect)(() => {
|
|
1331
|
+
mountedRef.current = true;
|
|
1332
|
+
return () => {
|
|
1333
|
+
mountedRef.current = false;
|
|
1334
|
+
stopPolling();
|
|
1335
|
+
};
|
|
1357
1336
|
}, []);
|
|
1358
1337
|
/** 拉白名单 + 就绪态。失败**不**改重建面板:面板 idle 时冒一个红字只是噪音,
|
|
1359
1338
|
* 用户真点「重建」时 start() 会把同一错误显示出来。 */
|
|
@@ -1376,11 +1355,11 @@ function useRebuild(t, reader) {
|
|
|
1376
1355
|
})();
|
|
1377
1356
|
}, [refreshAccess]);
|
|
1378
1357
|
async function pollStatus(jobId) {
|
|
1379
|
-
if (pollingRef.current || !isMounted()) return;
|
|
1358
|
+
if (pollingRef.current || !isMounted() || jobRef.current !== jobId) return;
|
|
1380
1359
|
pollingRef.current = true;
|
|
1381
1360
|
try {
|
|
1382
1361
|
const body = await requireReader(reader, t).status(jobId);
|
|
1383
|
-
if (!isMounted()) return;
|
|
1362
|
+
if (!isMounted() || jobRef.current !== jobId) return;
|
|
1384
1363
|
const poll = parseRebuildPoll(body, t);
|
|
1385
1364
|
if (poll.phase !== "running") stopPolling();
|
|
1386
1365
|
setRebuild({
|
|
@@ -1388,7 +1367,7 @@ function useRebuild(t, reader) {
|
|
|
1388
1367
|
output: poll.output
|
|
1389
1368
|
});
|
|
1390
1369
|
} catch (error) {
|
|
1391
|
-
if (!isMounted()) return;
|
|
1370
|
+
if (!isMounted() || jobRef.current !== jobId) return;
|
|
1392
1371
|
stopPolling();
|
|
1393
1372
|
setRebuild({
|
|
1394
1373
|
phase: "error",
|
|
@@ -1404,6 +1383,7 @@ function useRebuild(t, reader) {
|
|
|
1404
1383
|
const parsedStarted = zod.z.object({ jobId: zod.z.string() }).safeParse(started);
|
|
1405
1384
|
if (!parsedStarted.success) throw new TypeError(t("rebuildMissingJobId"));
|
|
1406
1385
|
const { jobId } = parsedStarted.data;
|
|
1386
|
+
jobRef.current = jobId;
|
|
1407
1387
|
pollRef.current = setInterval(() => {
|
|
1408
1388
|
pollStatus(jobId);
|
|
1409
1389
|
}, REBUILD_POLL_MS);
|
|
@@ -1505,7 +1485,6 @@ function ZgCard(props) {
|
|
|
1505
1485
|
saveError,
|
|
1506
1486
|
setField,
|
|
1507
1487
|
setRoot: rebuildView.setRoot,
|
|
1508
|
-
setSaveError,
|
|
1509
1488
|
onSave: () => {
|
|
1510
1489
|
save();
|
|
1511
1490
|
},
|
|
@@ -1570,7 +1549,6 @@ exports.cardStore = cardStore;
|
|
|
1570
1549
|
exports.draftFields = draftFields;
|
|
1571
1550
|
exports.inject = inject;
|
|
1572
1551
|
exports.parseRebuildPoll = parseRebuildPoll;
|
|
1573
|
-
exports.resolveLimitInput = resolveLimitInput;
|
|
1574
1552
|
return module.exports;
|
|
1575
1553
|
},
|
|
1576
1554
|
});
|
package/docs/DETAIL.md
CHANGED
|
@@ -5,23 +5,23 @@ Searches the workspace through a local index instead of raw grep, and can requir
|
|
|
5
5
|
## What the card changes
|
|
6
6
|
|
|
7
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) how many minutes that unlock stays valid
|
|
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
9
|
|
|
10
10
|
These are read per call and take effect without restarting the host.
|
|
11
11
|
|
|
12
12
|
## The Rebuild action is not a setting
|
|
13
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
|
|
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
15
|
|
|
16
16
|
## Restart-only values
|
|
17
17
|
|
|
18
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
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 `cordis.patch.yml
|
|
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
21
|
|
|
22
22
|
## What it needs from outside
|
|
23
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). `ZVEC_GREP_ENDPOINT` and `ZVEC_GREP_API_KEY`
|
|
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
25
|
|
|
26
26
|
## Further detail
|
|
27
27
|
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
## 设置卡上改的是什么
|
|
6
6
|
|
|
7
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
|
|
8
|
+
- **网络与索引** — `hfEndpoint` 默认指向 ModelScope 镜像(`https://modelscope.cn/models`);留空就是 huggingface.co,而这个环境通常连不上,所以默认值应当保留。`enforceSearchFirst`(默认开)在已建索引的工作区里拦住 `grep` / `rg`。`grepBudgetPerSearch`(默认 3)是一次成功的 `zg_search` 解锁多少次直查,`unlockWindowMin`(默认 10)是这份解锁维持几分钟。有效期在每次取用配额时现判,窗口一过就不再放行直查、不需要重启;分片表按会话数封顶 256,超出时先淘汰最久未用的那一份。本步骤的工具准入不含 `zg_search` 时,门禁让路,不强迫模型去调一个本步骤调不动的工具。
|
|
9
9
|
|
|
10
10
|
这些每次调用现读,改完不需要重启宿主。
|
|
11
11
|
|
|
12
12
|
## Rebuild 不是设置项
|
|
13
13
|
|
|
14
|
-
卡上的 Rebuild 是对守护进程已经观察到的工作区跑一次等价于 `zg index --rebuild`
|
|
14
|
+
卡上的 Rebuild 是对守护进程已经观察到的工作区跑一次等价于 `zg index --rebuild` 的动作,不是被存起来的偏好。这条路上不会弹审批:pre-execute 审批只覆盖显式给了 root 的 `zg_*` 工具,Remote 方法不走工具准入;真正管住它的是守护进程那份已观测根白名单(以及它自己的单操作锁)。
|
|
15
15
|
|
|
16
16
|
## 要重启的值
|
|
17
17
|
|
|
18
18
|
十项部署值刻意不进设置卡:`searchTimeoutMs`(300000)、`statusTimeoutMs`(60000)、`indexTimeoutMs`(600000)、`stdoutMaxBytes`(400000)、`rebuildWaitMs`、`clientMode`(`auto` / `direct` / `server`)、`allowRemoteEmbedding`(false)、`remoteEmbeddingEndpoint`、`remoteEmbeddingApiKeyFrom`、`requireApprovalForExplicitRoot`(false)。
|
|
19
19
|
|
|
20
|
-
「工作区内容能不能离开本机」被当成部署决定,而不是给模型选的开关,所以远程嵌入那三枚既不在卡上也不在工具参数里;即便开了,`zg` 自己仍要求 `--allow-remote` 或 `zg auth grant
|
|
20
|
+
「工作区内容能不能离开本机」被当成部署决定,而不是给模型选的开关,所以远程嵌入那三枚既不在卡上也不在工具参数里;即便开了,`zg` 自己仍要求 `--allow-remote` 或 `zg auth grant`。这些值都写在**自己 profile 的 `cordis.yml`** 里本插件注册行的 `config:` 块(随包那份 `cordis.patch.yml` 只带 `id` / `name` 两行),改值随重启生效。
|
|
21
21
|
|
|
22
22
|
## 需要外部提供什么
|
|
23
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
|
|
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
25
|
|
|
26
26
|
## 更完整的说明
|
|
27
27
|
|