@jayyuen66/dsh-zvec-grep 0.1.9 → 0.1.11
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 +46 -1
- package/LICENSE +1 -1
- package/README.md +11 -11
- package/README.zh-CN.md +33 -32
- package/THIRD_PARTY_NOTICES.md +10 -3
- package/client.js +60 -75
- package/docs/DETAIL.md +4 -4
- package/docs/DETAIL.zh.md +6 -6
- package/host.js +565 -203
- package/package.json +49 -45
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) {
|
|
@@ -648,6 +643,11 @@ function numberText(raw, fallback) {
|
|
|
648
643
|
* `undefined` 是**必要**的一臂,不是兜底:旧版 host 的应答里没有 `serverReady` 这个字段,
|
|
649
644
|
* 而「应答里没写」与「写了未就绪」是两件事——把前者显示成后者,卡片就在用户眼前谎称了一次
|
|
650
645
|
* 「没有守护进程」。判据收在可单测的这一层,client 只负责渲染它选出来的那一行。
|
|
646
|
+
*
|
|
647
|
+
* 入参写 `unknown` 而不是 `boolean | undefined`:应答里的这一位只有类型声明、没有运行时校验
|
|
648
|
+
* (lib/rebuild-shape.ts),把形状收紧在声明上等于假定畸形值不会出现,而这里的严格判等正是
|
|
649
|
+
* 为了不让 `null` / `"false"` / `0` 这类值被 falsy 判断误收成「未就绪」。调用方交来的仍是
|
|
650
|
+
* `boolean | undefined`,收紧的一侧由它自己保证。
|
|
651
651
|
*/
|
|
652
652
|
function daemonNoteKey(ready) {
|
|
653
653
|
let key;
|
|
@@ -689,69 +689,48 @@ function cardStore(scope) {
|
|
|
689
689
|
/**
|
|
690
690
|
* 三个数值字段的显示值都是「草稿优先 + 默认文案」,且共享同一条清空语义:
|
|
691
691
|
* touched 里显式写了 undefined(用户清空输入)= 待 unset,显示空串;「从没动过、
|
|
692
|
-
*
|
|
693
|
-
*
|
|
692
|
+
* 快照里也没有」不是清空,显示默认文案。判据统一收在这里,与卡片数值控件
|
|
693
|
+
* (numberDisplay / NumberField)的「清空即回『未填』」对齐。
|
|
694
694
|
*/
|
|
695
695
|
function numericFieldDisplay(touched, value, field, fallback) {
|
|
696
696
|
const draft = draftOf(touched, value, field);
|
|
697
|
-
if (draft === void 0) return
|
|
697
|
+
if (draft === void 0) return hasDraft(touched, field) ? "" : fallback;
|
|
698
698
|
return numberText(draft, fallback);
|
|
699
699
|
}
|
|
700
|
-
/**
|
|
700
|
+
/** 已提交端点值只收 HTTP(S);坏文本显示成空(输入框里键入的草稿不走这条过滤)。 */
|
|
701
701
|
const HTTP_URL_SCHEMA = zod.z.url({ protocol: /^https?$/u });
|
|
702
|
+
/**
|
|
703
|
+
* 端点字段的显示值:**草稿优先**,与三个数值字段同一条清空语义。
|
|
704
|
+
*
|
|
705
|
+
* 用户正在逐字键入时,草稿是「这一格此刻的文本」而不是待校验的值——半截 URL
|
|
706
|
+
* 必须原样回显,否则输入第一个字符就被过滤成空串、删掉已提交 URL 的一个字符就整格清空。
|
|
707
|
+
* 只有「这一格没动过、显示的是已提交快照」时才过 HTTP(S) 形态过滤:脏快照不该显示成
|
|
708
|
+
* 一个看起来能保存的地址。
|
|
709
|
+
*/
|
|
710
|
+
function endpointFieldDisplay(touched, value) {
|
|
711
|
+
if (Object.hasOwn(touched, "hfEndpoint")) {
|
|
712
|
+
const draft = touched["hfEndpoint"];
|
|
713
|
+
return typeof draft === "string" ? draft : "";
|
|
714
|
+
}
|
|
715
|
+
const committed = value["hfEndpoint"];
|
|
716
|
+
return typeof committed === "string" && HTTP_URL_SCHEMA.safeParse(committed).success ? committed : "";
|
|
717
|
+
}
|
|
702
718
|
/** 六个字段的草稿显示值(ZgCard 只渲染这里算出来的东西)。 */
|
|
703
719
|
function draftFields(touched, value) {
|
|
704
720
|
const embedding = draftOf(touched, value, "defaultEmbedding");
|
|
705
|
-
const endpoint = draftOf(touched, value, "hfEndpoint");
|
|
706
721
|
const enforce = draftOf(touched, value, "enforceSearchFirst");
|
|
707
722
|
return {
|
|
708
723
|
embedding: typeof embedding === "string" && embedding.length > 0 ? embedding : DEFAULT_EMBEDDING,
|
|
709
724
|
limitDisplay: numericFieldDisplay(touched, value, "defaultLimit", String(10)),
|
|
710
|
-
hfEndpoint:
|
|
725
|
+
hfEndpoint: endpointFieldDisplay(touched, value),
|
|
711
726
|
enforceSearchFirst: enforce !== false,
|
|
712
727
|
grepBudget: numericFieldDisplay(touched, value, "grepBudgetPerSearch", String(3)),
|
|
713
728
|
unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10))
|
|
714
729
|
};
|
|
715
730
|
}
|
|
716
|
-
/** 三个数值字段的 zod 域:输入校验与卡片显示共用,host schema 的区间是同一组常量。 */
|
|
717
731
|
const LIMIT_SCHEMA = zod.z.int().min(1).max(50);
|
|
718
732
|
const BUDGET_SCHEMA = zod.z.int().min(1).max(20);
|
|
719
733
|
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
734
|
/** 轮询应答的宽容形状:未知状态、非数字退出码、非字符串输出都折成缺位,
|
|
756
735
|
* 下游文案只按“缺位”兜底,不把坏类型带到渲染期。 */
|
|
757
736
|
const REBUILD_STATUSES = [
|
|
@@ -815,8 +794,8 @@ function parseOrThrow(schema, value) {
|
|
|
815
794
|
if (!parsed.success) throw new TypeError(zod.z.prettifyError(parsed.error));
|
|
816
795
|
return parsed.data;
|
|
817
796
|
}
|
|
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" });
|
|
797
|
+
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" });
|
|
798
|
+
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
799
|
/** 把宿主那三个方法挂到客户端远程面上的描述符(`id` 的形状照生成器:`<包>#<命名空间>/<方法>`)。
|
|
821
800
|
* 导出它只为一件事:`test/rebuild-remote.test.ts` 拿它与宿主侧 `remoteMethods()` 的标记对质
|
|
822
801
|
* —— 两侧分叉时卡片不会报错,只会"读不到",所以那条比较必须在门禁里。 */
|
|
@@ -904,7 +883,7 @@ function buildRebuildReader(ctx) {
|
|
|
904
883
|
mounted = void 0;
|
|
905
884
|
throw error;
|
|
906
885
|
}
|
|
907
|
-
const namespace = ctx.get?.(REBUILD_SERVICE_KEY
|
|
886
|
+
const namespace = ctx.get?.(REBUILD_SERVICE_KEY);
|
|
908
887
|
if (!isRebuildNamespace(namespace)) throw new Error(`${REBUILD_SERVICE_KEY} 未提供:宿主网关没有挂上这枚命名空间`);
|
|
909
888
|
return namespace;
|
|
910
889
|
};
|
|
@@ -939,10 +918,11 @@ function createRebuildReader(ctx) {
|
|
|
939
918
|
return typeof ctx.get === "function" ? buildRebuildReader(ctx) : void 0;
|
|
940
919
|
}
|
|
941
920
|
// src/ui-messages.ts
|
|
921
|
+
/** 推荐的 embedding 模型镜像(endpointHint 与 client-entry 的 placeholder 共用)。 */
|
|
922
|
+
const EMBEDDING_MIRROR_URL = "https://modelscope.cn/models";
|
|
942
923
|
const UI_MESSAGES = {
|
|
943
924
|
zh: {
|
|
944
925
|
statusReadOnly: "当前作用域只读",
|
|
945
|
-
statusDirty: "有未保存的修改,点「保存」生效",
|
|
946
926
|
statusClean: "无未保存的修改",
|
|
947
927
|
dirtyCount: "已修改 {count} 项",
|
|
948
928
|
save: "保存",
|
|
@@ -962,7 +942,7 @@ const UI_MESSAGES = {
|
|
|
962
942
|
limitInvalid: "请输入 {min}-{max} 的整数",
|
|
963
943
|
limitClamped: "已钳到 {min}-{max} 范围:{value}",
|
|
964
944
|
endpointLabel: "HuggingFace 镜像地址",
|
|
965
|
-
endpointHint:
|
|
945
|
+
endpointHint: `留空走 huggingface.co;国内网络可填 ${EMBEDDING_MIRROR_URL} 等兼容镜像(仅 llama-cpp 后端生效,如 qwen3)`,
|
|
966
946
|
enforceLabel: "强制 search-first(先 zg_search 再 grep/rg)",
|
|
967
947
|
enforceHint: "开启后,已建索引工作区内的 grep/rg 受配额门禁约束:每次成功 zg_search 解锁下方次数的 grep/rg(时效见下),用尽或过期后再次拦截(提高检索覆盖与准确性)",
|
|
968
948
|
budgetLabel: "每次 zg_search 解锁的 grep/rg 次数",
|
|
@@ -970,6 +950,7 @@ const UI_MESSAGES = {
|
|
|
970
950
|
windowLabel: "解锁时效",
|
|
971
951
|
windowHint: "超过该时长未再次 zg_search,配额整体过期;清空恢复默认 {default}(单位:分钟)",
|
|
972
952
|
rebuildLabel: "工作区重建(切换 embedding 并保存后执行)",
|
|
953
|
+
rebuildInputPlaceholder: "/workspace 的绝对路径",
|
|
973
954
|
daemonReadyNote: "守护进程:就绪(zg server 在跑)。",
|
|
974
955
|
daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg server on`。",
|
|
975
956
|
rebuildHint: "以当前默认模型重建:{embedding};等价于 zg index --rebuild。{roots}",
|
|
@@ -982,7 +963,7 @@ const UI_MESSAGES = {
|
|
|
982
963
|
rebuildKilled: "重建进程被终止",
|
|
983
964
|
rebuildFailed: "重建作业被宿主注册表判定失败(没拿到进程退出码)",
|
|
984
965
|
rebuildExitCode: "重建进程退出码 {exitCode}(zg 未安装/权限不足/沙箱拒绝都会走到这里)",
|
|
985
|
-
rebuildExitUnknown: "
|
|
966
|
+
rebuildExitUnknown: "重建没有可判定的结果(应答的 status 无法识别,或缺少进程退出码)",
|
|
986
967
|
rebuildMissingJobId: "启动重建失败:应答缺 jobId",
|
|
987
968
|
rebuildRootNotAbsolute: "root 必须是绝对路径(以 / 开头)",
|
|
988
969
|
rebuildUnavailable: "宿主没有提供工作区重建读面(未装远程服务)",
|
|
@@ -993,7 +974,6 @@ const UI_MESSAGES = {
|
|
|
993
974
|
},
|
|
994
975
|
en: {
|
|
995
976
|
statusReadOnly: "This scope is read-only",
|
|
996
|
-
statusDirty: "Unsaved changes — press Save to apply",
|
|
997
977
|
statusClean: "No unsaved changes",
|
|
998
978
|
dirtyCount: "{count} changed",
|
|
999
979
|
save: "Save",
|
|
@@ -1013,7 +993,7 @@ const UI_MESSAGES = {
|
|
|
1013
993
|
limitInvalid: "enter an integer between {min} and {max}",
|
|
1014
994
|
limitClamped: "clamped into the {min}-{max} range: {value}",
|
|
1015
995
|
endpointLabel: "HuggingFace mirror URL",
|
|
1016
|
-
endpointHint:
|
|
996
|
+
endpointHint: `Leave empty for huggingface.co; on networks that cannot reach HF, fill a compatible mirror such as ${EMBEDDING_MIRROR_URL} (llama-cpp backends only, e.g. qwen3)`,
|
|
1017
997
|
enforceLabel: "Enforce search-first (zg_search before grep/rg)",
|
|
1018
998
|
enforceHint: "When on, grep/rg inside indexed workspaces is quota-gated: each successful zg_search unlocks the number of grep/rg calls below (valid for the window below), and the gate blocks again once it is spent or expired (better coverage and relevance)",
|
|
1019
999
|
budgetLabel: "grep/rg calls unlocked per zg_search",
|
|
@@ -1021,6 +1001,7 @@ const UI_MESSAGES = {
|
|
|
1021
1001
|
windowLabel: "Unlock window",
|
|
1022
1002
|
windowHint: "Without another zg_search inside this window the whole quota expires; clear to restore the default {default} (minutes)",
|
|
1023
1003
|
rebuildLabel: "Workspace rebuild (run after switching embedding and saving)",
|
|
1004
|
+
rebuildInputPlaceholder: "absolute path to a /workspace",
|
|
1024
1005
|
daemonReadyNote: "Daemon: ready (zg server is running).",
|
|
1025
1006
|
daemonOfflineNote: "Daemon: not ready. What the daemon provides — incremental index refresh, refresh=background and the resident embedding model pool — is unavailable while it is absent; run `zg server on` in a terminal when you want it.",
|
|
1026
1007
|
rebuildHint: "Rebuild with the current default model: {embedding}; same as zg index --rebuild. {roots}",
|
|
@@ -1033,7 +1014,7 @@ const UI_MESSAGES = {
|
|
|
1033
1014
|
rebuildKilled: "the rebuild process was terminated",
|
|
1034
1015
|
rebuildFailed: "the host job registry reported the rebuild as failed (no process exit code)",
|
|
1035
1016
|
rebuildExitCode: "the rebuild process exited with code {exitCode} (missing zg, insufficient permissions and sandbox denials all land here)",
|
|
1036
|
-
rebuildExitUnknown: "the rebuild
|
|
1017
|
+
rebuildExitUnknown: "the rebuild has no determinable outcome (the response status is unrecognized, or its exit code is missing)",
|
|
1037
1018
|
rebuildMissingJobId: "failed to start the rebuild: the response has no jobId",
|
|
1038
1019
|
rebuildRootNotAbsolute: "root must be an absolute path (starting with /)",
|
|
1039
1020
|
rebuildUnavailable: "the host does not expose the rebuild Remote API",
|
|
@@ -1192,7 +1173,7 @@ function buildRebuildField(deps) {
|
|
|
1192
1173
|
className: "dsu-input zgc-rebuildInput",
|
|
1193
1174
|
value: root,
|
|
1194
1175
|
list: ROOT_OPTIONS_ID,
|
|
1195
|
-
placeholder: "
|
|
1176
|
+
placeholder: t("rebuildInputPlaceholder"),
|
|
1196
1177
|
onChange: (ev) => {
|
|
1197
1178
|
setRoot(ev.target.value);
|
|
1198
1179
|
}
|
|
@@ -1242,7 +1223,7 @@ function buildIndexSection(deps) {
|
|
|
1242
1223
|
...l(t("endpointHint")),
|
|
1243
1224
|
field: "hfEndpoint",
|
|
1244
1225
|
value: fields.hfEndpoint,
|
|
1245
|
-
placeholder:
|
|
1226
|
+
placeholder: EMBEDDING_MIRROR_URL,
|
|
1246
1227
|
monospace: true,
|
|
1247
1228
|
disabled: !editable,
|
|
1248
1229
|
onChange: (next) => {
|
|
@@ -1343,17 +1324,22 @@ function useRebuild(t, reader) {
|
|
|
1343
1324
|
});
|
|
1344
1325
|
const pollRef = (0, react.useRef)(null);
|
|
1345
1326
|
const pollingRef = (0, react.useRef)(false);
|
|
1327
|
+
const jobRef = (0, react.useRef)(null);
|
|
1346
1328
|
const mountedRef = (0, react.useRef)(true);
|
|
1347
1329
|
const isMounted = () => mountedRef.current;
|
|
1348
1330
|
function stopPolling() {
|
|
1331
|
+
jobRef.current = null;
|
|
1349
1332
|
if (pollRef.current !== null) {
|
|
1350
1333
|
clearInterval(pollRef.current);
|
|
1351
1334
|
pollRef.current = null;
|
|
1352
1335
|
}
|
|
1353
1336
|
}
|
|
1354
|
-
(0, react.useEffect)(() =>
|
|
1355
|
-
mountedRef.current =
|
|
1356
|
-
|
|
1337
|
+
(0, react.useEffect)(() => {
|
|
1338
|
+
mountedRef.current = true;
|
|
1339
|
+
return () => {
|
|
1340
|
+
mountedRef.current = false;
|
|
1341
|
+
stopPolling();
|
|
1342
|
+
};
|
|
1357
1343
|
}, []);
|
|
1358
1344
|
/** 拉白名单 + 就绪态。失败**不**改重建面板:面板 idle 时冒一个红字只是噪音,
|
|
1359
1345
|
* 用户真点「重建」时 start() 会把同一错误显示出来。 */
|
|
@@ -1376,11 +1362,11 @@ function useRebuild(t, reader) {
|
|
|
1376
1362
|
})();
|
|
1377
1363
|
}, [refreshAccess]);
|
|
1378
1364
|
async function pollStatus(jobId) {
|
|
1379
|
-
if (pollingRef.current || !isMounted()) return;
|
|
1365
|
+
if (pollingRef.current || !isMounted() || jobRef.current !== jobId) return;
|
|
1380
1366
|
pollingRef.current = true;
|
|
1381
1367
|
try {
|
|
1382
1368
|
const body = await requireReader(reader, t).status(jobId);
|
|
1383
|
-
if (!isMounted()) return;
|
|
1369
|
+
if (!isMounted() || jobRef.current !== jobId) return;
|
|
1384
1370
|
const poll = parseRebuildPoll(body, t);
|
|
1385
1371
|
if (poll.phase !== "running") stopPolling();
|
|
1386
1372
|
setRebuild({
|
|
@@ -1388,7 +1374,7 @@ function useRebuild(t, reader) {
|
|
|
1388
1374
|
output: poll.output
|
|
1389
1375
|
});
|
|
1390
1376
|
} catch (error) {
|
|
1391
|
-
if (!isMounted()) return;
|
|
1377
|
+
if (!isMounted() || jobRef.current !== jobId) return;
|
|
1392
1378
|
stopPolling();
|
|
1393
1379
|
setRebuild({
|
|
1394
1380
|
phase: "error",
|
|
@@ -1404,6 +1390,7 @@ function useRebuild(t, reader) {
|
|
|
1404
1390
|
const parsedStarted = zod.z.object({ jobId: zod.z.string() }).safeParse(started);
|
|
1405
1391
|
if (!parsedStarted.success) throw new TypeError(t("rebuildMissingJobId"));
|
|
1406
1392
|
const { jobId } = parsedStarted.data;
|
|
1393
|
+
jobRef.current = jobId;
|
|
1407
1394
|
pollRef.current = setInterval(() => {
|
|
1408
1395
|
pollStatus(jobId);
|
|
1409
1396
|
}, REBUILD_POLL_MS);
|
|
@@ -1505,7 +1492,6 @@ function ZgCard(props) {
|
|
|
1505
1492
|
saveError,
|
|
1506
1493
|
setField,
|
|
1507
1494
|
setRoot: rebuildView.setRoot,
|
|
1508
|
-
setSaveError,
|
|
1509
1495
|
onSave: () => {
|
|
1510
1496
|
save();
|
|
1511
1497
|
},
|
|
@@ -1570,7 +1556,6 @@ exports.cardStore = cardStore;
|
|
|
1570
1556
|
exports.draftFields = draftFields;
|
|
1571
1557
|
exports.inject = inject;
|
|
1572
1558
|
exports.parseRebuildPoll = parseRebuildPoll;
|
|
1573
|
-
exports.resolveLimitInput = resolveLimitInput;
|
|
1574
1559
|
return module.exports;
|
|
1575
1560
|
},
|
|
1576
1561
|
});
|
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,24 +5,24 @@
|
|
|
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
|
|
8
|
+
- **网络与索引** — `hfEndpoint` 默认指向 ModelScope 镜像(`https://modelscope.cn/models`);留空就是 huggingface.co,而这个环境通常连不上,所以默认值应当保留。`enforceSearchFirst`(默认开)在已建索引的工作区里拦住 `grep` / `rg`。`grepBudgetPerSearch`(默认 3)是一次**走索引的** `zg_search` 解锁多少次直查(无索引时自动改走穷举词法的检索同样成功,但不发配额),`unlockWindowMin`(默认 10)是这份解锁维持几分钟。配额按「会话 × 索引根」记账(索引根是 root 或最近的含索引祖先,最多上溯 8 层),不是全局一份;「让路」只在宿主提供了步骤准入(`toolSet`)且该视图不含 `zg_search` 时成立——不提供准入信息的宿主仍按原判据拦截。有效期在每次取用配额时现判,窗口一过就不再放行直查、不需要重启;分片表按会话数封顶 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
|
-
十项部署值刻意不进设置卡:`searchTimeoutMs`(300000)、`statusTimeoutMs`(60000)、`indexTimeoutMs`(600000)、`stdoutMaxBytes`(400000)、`rebuildWaitMs
|
|
18
|
+
十项部署值刻意不进设置卡:`searchTimeoutMs`(300000)、`statusTimeoutMs`(60000)、`indexTimeoutMs`(600000)、`stdoutMaxBytes`(400000)、`rebuildWaitMs`(120000)、`clientMode`(`auto` / `direct` / `server`)、`allowRemoteEmbedding`(false)、`remoteEmbeddingEndpoint`、`remoteEmbeddingApiKeyFrom`、`requireApprovalForExplicitRoot`(false)。这十项在卡上没有入口,能生效的只有下一段那条注册行 `config:`;优先级是注册行 `config:` > 代码里的 `.default()`。
|
|
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
|
|
|
28
|
-
|
|
28
|
+
参数守卫、`root` 判据与后台作业面都写在随包 README(`README.md` / `README.zh-CN.md`)。README 没有独立的错误码表:`zg` 不在 PATH 上按 `exit 127` 归到「未安装」(见「外部依赖」一节),其余失败按工具回执里的 `reason` 读。
|