@jayyuen66/dsh-zvec-grep 0.1.2 → 0.1.3

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 CHANGED
@@ -2,6 +2,31 @@
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.3
6
+
7
+ 修复一处**跟着真实宿主语义失效的作业身份判据**(它让重建轮询恒 404、卸载只杀进程不摘作业 ⇒ 官方环缓冲留在宿主内存),并给 `ignoreFiles` 补上起进程之前的**存在性 + 可读性**预检(一条读不成的忽略文件会永久弄坏整棵工作区索引)。测试面从「单测 + mock 宿主」扩到三层:新增真宿主半栈的集成层与直怼真 zg CLI 的点对点层。
8
+
9
+ ### Fixed
10
+
11
+ - **作业身份改用投影值,不再比注册表实例引用**。旧 `sameJob` 的一半判据是 `state.owner === ctx.get("jobs")`,而真实 cordis 每读一次服务都新建一枚 traceable 代理 ⇒ 同一枚注册表的两次读也不 `===`,该判据在真实宿主上**恒为假**(mock 上下文里恒真,故单测全绿、线上全崩)。后果有三:轮询端点对每条活着的重建恒回 404;卸载 / 超时臂只 `killProc` 而从不 `jobs.remove` ⇒ 官方环缓冲留在宿主内存里(内存泄露);「同根第二条启动复用在跑那条」的 follow 恒不生效。现改用官方 `JobView` 上三段**值稳定**的投影(`kind` / `label` / `startedAt`)做身份——`JobView` 虽每次新建对象,这三个原始值却跨读恒定。`startedAt` 未盖章时用占位 `0`(官方签的是 `Date.now()`,永不为 0),保证 `start` 同步跑第一拍时不会把同 id 的另一条作业误认成自己的。
12
+ - **`ignoreFiles` 预检补上「可读性」这半段,并与「是否存在」合成一次判定**。原判据只查 `statSync().isFile()`,而它对 mode 000 / 他人属主的文件照样返回 `true`(stat 只要父目录可搜索、不要文件本身可读);真 zg 去 open 它会 `EACCES` ⇒ 整次索引失败并把这条坏路径**写进工作区索引状态**,此后这棵树上的 `zg index` / `zg status` 都报同一个错,`--reset-paths` 清不掉,只有 `zg_index drop` 能救——与「文件不存在」是同一种永久损坏,却漏过了预检。现以 `accessSync(R_OK)` 在前、`isFile()` 在后合成一次 try:`accessSync` 与 zg 的读权限同 uid 同源(root 下两者都放行、非 root 下两者都拒),只查权限位、不读内容,没有 `readFileSync` 那种把大文件整段读进内存的代价。**刻意不拆成「不存在」与「读不了」两条独立分支 / 两句文案**:可读性那一档在 windows(chmod 只翻只读位、属主仍读得了)与 root(绕过 DAC)下造不出文件来触发,拆成独立分支会让 CI 的 windows 那格在 100% 覆盖率门禁下无从而钉(本仓不用 coverage-ignore 逃生口);合成一条 catch 后由跨平台的「不存在」这一档钉住,三种成因(ENOENT / EISDIR / EACCES)共用一句「不是一份存在且当前进程可读的文件」文案。
13
+ - **`drop` 那一臂不再被 `ignoreFiles` 预检误拒**。`--drop` 的命令只有 `zg index <root> --drop --yes`,`ignoreFiles` 被 `buildIndexCommand` 静默丢掉、根本不进 zg(也就无从损坏索引);而预检原先无条件先跑,于是 `drop:true` + 一条坏 `ignoreFiles` 会被「请给一个真实存在的忽略文件」这句误导文案拦下一次合法的删索引。现 `drop` 为真时整段跳过预检,判 `drop` 用与构造器**同一个** `boolOf`,两处口径不漂。
14
+
15
+ ### Added
16
+
17
+ - **`ignoreFiles` 可用性预检(`assertIgnoreFilesExist`)**:模型够得着 `ignoreFiles` 这个参数,而一条读不成的忽略文件会永久弄坏工作区索引,属于必须在起进程之前拦下的那一类。前台索引、模型侧后台索引、设置卡重建这三条起 `zg index` 的路径共用同一道预检(卡片那条不带 `ignoreFiles`,天然空转);`drop` 为真时整段跳过(见上)。三种不可用成因合成一句「不是存在且可读的文件」文案,双语,并写明代价与出路。
18
+ - **测试分三层**。原来只有 `test/*.test.ts`(单测 + 一枚 mock 宿主上下文)。新增:
19
+ - `test/integration/*`:真宿主半栈——官方 cordis `Context` + `dsh-tools` 的 `ToolRuntime`(含 pre-execute 瀑布与官方 JSON Schema 子集校验)+ `dsh-subprocess-local` / `dsh-bash-local` 的本地 bash 执行器(真 spawn / 真 deadline / 真 stdout 上限与 spill / 真凭据擦除)+ `dsh-jobs-local` 的 `LocalJobRegistry`(真环 / 真泵 / 真容量)+ 真 `node:http` 监听的 `dsh-host-webserver` + timer + approval,把插件挂进官方调用管线(`ctx.tools.execute()` / 真 `fetch`)驱动。宿主契约的缺陷都出在这一层:mock 上下文只会同意本包已经相信的事(`ctx.get("jobs") === ctx.get("jobs")` 在替身里恒真、真实 cordis 恒假,正是上面那条 Fixed 的成因)。
20
+ - `test/e2e/zg-cli.test.ts`:既无插件也无替身,只把 `lib/cli.ts` 造出的命令行喂给**真 zg CLI**,钉它的旗标面、输出形状、错误码,以及「坏 `ignoreFiles` 会弄坏整棵树」这类上游事实(含 ENOENT 与 EACCES 两档)。
21
+ - **两层按环境 gate,而非无条件跑**:真-zg 的 integration + e2e 整体 `describe.skipIf(!zgAvailable())`——CI 的干净 runner 没装真 zg,硬跑会以「command not found」变红而不是跳过;本机装了 zg 才跑。本包自己的判据另由 `test/host.test.ts` 的 mock 宿主独立钉到 100%(`assertIgnoreFilesExist`:drop 跳过 / 不存在 / 读不了 / 放行,绝对与相对两种写法都覆盖),所以这两层在 CI 跳过后覆盖率不塌;「读不了」那档再按 `canMakeUnreadableFile()`(root 或 windows 造不出属主读不了的文件)单独跳过,也不依赖它保覆盖率。
22
+ - 两份 README 各补一段「测试分三层」的说明。
23
+
24
+ ### Changed
25
+
26
+ - `devDependencies` 补 `@deepseek-ai/dsh-bash-local` / `dsh-http-proxy` / `dsh-subprocess-local` / `dsh-timeout`(真宿主台架的传递依赖,均**不进** `dependencies`)。
27
+ - `pnpm-workspace.yaml` 的 `allowBuilds` 把 `@deepseek-ai/dsh-subprocess-local` / `koffi` / `node-pty` 显式记为 `false`。这三枚是集测台架经 `dsh-subprocess-local` 传递引入的原生模块(各带安装脚本),而 pnpm 12 默认拦截未声明的构建脚本 ⇒ CI 那步 `pnpm install --frozen-lockfile` 以 `ERR_PNPM_IGNORED_BUILDS` 退出 1(本机因 `.modules.yaml` 早记下 ignoredBuilds 决定反而不报)。但本包根本用不到它们的构建产物:`dsh-subprocess-local` 经 `dsh-lazy-require` 惰性加载 `node-pty` / `koffi`,集成用例走的是 bash 执行路径、从不 require(本机 `.modules.yaml` 记的正是 ignoredBuilds,600 用例照绿)。显式 `false` 让 pnpm 跳过构建且不计入 ignoredBuilds(源码实测:唯有 `allowBuild()` 返回 `undefined` 的未声明档才报错),CI 也因此不必为用不到的原生模块在 windows 那一格背上 node-gyp 编译。`esbuild: true` 那条不动(vite 传递引入,确实要它落平台二进制)。
28
+ - `oxlint.config.ts` 的 `syncWrites` 声明 `chmodSync`(用例造 mode 000 的不可读忽略文件)与 `accessSync`(只读权限探针;共享基线的只读豁免表恰好没收录它,故经本包这唯一的 sync 例外口子声明)。
29
+
5
30
  ## 0.1.2
6
31
 
7
32
  宿主生态跟到 `0.2.1-alpha.2`,并把一处**跟着宿主变更而失效的安全判据**改回可用。这一版还补上了发布面与装载面的门禁,以及中英两份 README。
package/README.md CHANGED
@@ -158,6 +158,7 @@ What is not retained, stated plainly: the output ring keeps **UTF-8 bytes** (mea
158
158
 
159
159
  ### Development
160
160
 
161
+ - Tests come in three tiers. `test/*.test.ts` (unit + a mocked host context) pins this package's own pure logic; `test/integration/*` boots **real** host services (`dsh-tools` ToolRuntime, `dsh-subprocess-local` + `dsh-bash-local`, `dsh-jobs-local`, `dsh-host-webserver` over real HTTP, the timer and approval services) and drives the plugin through `ctx.tools.execute()` / actual `fetch`; `test/e2e/zg-cli.test.ts` has no plugin and no mock at all - it feeds the commands `lib/cli.ts` builds to the **real zg CLI** and pins its output shapes, error codes and flag surface. The middle tier is where host-contract bugs surface: a mocked context can only agree with what this package already believes (e.g. `ctx.get("jobs") === ctx.get("jobs")` holds for a mock but is false in real cordis, which reads a service through a fresh traceable proxy per call).
161
162
  - `npm run check` is the single gate to run before publishing: typecheck (both tsconfigs) + `oxlint` + rebuild both bundles + `vitest run --coverage` + `oxfmt --check`.
162
163
  - Coverage runs under a **100% global threshold** (statements/branches/functions/lines): any line or branch that no test pins turns the suite red by design.
163
164
  - `npm run build` / `npm run build:client` produce `host.js` / `client.js`, and neither is committed - `prepare` and `prepack` rebuild them, while `test/build-host.test.ts` / `test/build-client.test.ts` compare the on-disk bundle against an in-memory build byte for byte, so a stale bundle fails the suite. Never hand-edit the bundles: the published entry *is* the built artifact, because Node refuses to strip types for a `.ts` sitting inside `node_modules`.
package/README.zh-CN.md CHANGED
@@ -154,6 +154,7 @@ dsh plugin --profile web add @jayyuen66/dsh-zvec-grep
154
154
 
155
155
  ### 开发
156
156
 
157
+ - 测试分三层。`test/*.test.ts`(单测 + mock 宿主上下文)钉本包自己的纯逻辑;`test/integration/*` 起**真**宿主服务(`dsh-tools` 的 ToolRuntime、`dsh-subprocess-local` + `dsh-bash-local`、`dsh-jobs-local`、真 HTTP 的 `dsh-host-webserver`、timer 与 approval),把插件挂进官方调用管线(`ctx.tools.execute()` / 真 `fetch`)驱动;`test/e2e/zg-cli.test.ts` 既没有插件也没有替身,只把 `lib/cli.ts` 造出的命令行喂给**真 zg CLI**,钉它的输出形状、错误码与旗标面。宿主契约的缺陷都出在中间那层:mock 上下文只会同意本包已经相信的事(例如 `ctx.get("jobs") === ctx.get("jobs")` 在替身里恒真,而真实 cordis 每次读服务都新建一枚 traceable 代理,该等式恒假)。
157
158
  - `npm run check` 是发布前的一条门:typecheck(两侧 tsconfig)+ `oxlint` + 重建两个 bundle + `vitest run --coverage` + `oxfmt --check`。
158
159
  - 覆盖率按**全局 100% 阈值**跑(stmts/branches/funcs/lines):任何一行或分支没被用例钉住,套件当场红——这是本仓的既定质量门,不是巧合。
159
160
  - `npm run build` / `npm run build:client` 产出 `host.js` / `client.js`,两者**都不入库**:`prepare` 与 `prepack` 现产,而 `test/build-host.test.ts` / `test/build-client.test.ts` 拿磁盘产物与内存构建逐字节比,产物过期即变红。发布物不手改——发布入口本就是构建产物,因为 Node 对躺在 `node_modules` 里的 `.ts` 直接拒绝类型剥离。
package/host.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // GENERATED by build-host.mjs — edit host.ts / lib/*.ts, then run `node build-host.mjs`.
2
2
  import Schema from "@deepseek-ai/schemastery";
3
- import { existsSync, readFileSync } from "node:fs";
3
+ import { accessSync, constants, existsSync, readFileSync, statSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { guardBody, queryParam, sendJson } from "@jayyuen66/dsh-plugin-shared/lib/http";
@@ -230,6 +230,7 @@ const MESSAGES = {
230
230
  exhaustiveConflicts: "穷举检索(rg=true)与下列索引侧参数互斥:{names}。穷举是纯词法匹配,不支持这些参数;把它们去掉,或先建索引(zg_index)再用索引检索",
231
231
  embeddingNotAllowed: "embedding 引用 {reference} 不在本地候选清单内,而本部署未开放远程 embedding。远程 embedding 会把工作区内容送到外部端点,必须由用户在部署配置里显式开放(allowRemoteEmbedding),本插件不接受模型侧开启。可选本地模型:{choices}。若用户确已自行配好远程凭据(zg config provider set / zg auth grant <root> --capability embedding --scope workspace),请在插件部署配置里打开对应开关后重试。",
232
232
  dropWithResetPaths: "drop 与 resetPaths 互斥:--drop 整条命令只有删除索引一件事,resetPaths 无处安放(上游 zg 也拒这一对)。要清继承的文件选择设置,请不要传 drop。",
233
+ ignoreFileMissing: "ignoreFiles 里的 {path} 在 {root} 下不是一份「存在且当前进程可读的文件」(不存在、是目录、或有文件但读不了都算)。上游 zg 遇到读不成的忽略文件不会按「没有这条规则」继续,而是整次索引失败(ENOENT / EISDIR / EACCES),并把这条坏路径写进工作区索引状态——此后这条树上的 zg index / zg status 都会报同一个错,--reset-paths 也清不掉,只有 zg_index drop 能救。请给一个真实存在、当前用户可读的忽略文件路径。",
233
234
  exhaustiveFallbackNote: "[zvec-grep] 该工作区(含向上各级)尚无 zg 索引,已自动改用穷举词法检索(rg 模式)。结果是逐行字面匹配,不是语义相关度排序;需要语义检索请先 zg_index 建索引。",
234
235
  rgDescription: "穷举词法检索(对应 zg query --rg):不需要索引,逐行字面匹配。留空则在工作区无索引时自动改用它、有索引时照常走索引检索。显式 false 可要求只用索引检索(无索引即报错)。它不支持 preview / refresh / fuse / symbolTypes / preferSymbol / fts / vector / queries,且不发放 grep/rg 配额",
235
236
  intWithReceived: "{name} 必须是 >= {min} 的整数(收到 {received})",
@@ -377,6 +378,7 @@ const MESSAGES = {
377
378
  exhaustiveConflicts: "exhaustive search (rg=true) conflicts with these indexed-search parameters: {names}. Exhaustive search is pure lexical matching and does not support them; drop them, or build an index first (zg_index) and search the index",
378
379
  embeddingNotAllowed: "embedding reference {reference} is not in the local catalog, and this deployment has not enabled remote embedding. Remote embedding sends workspace content to an external endpoint and must be turned on explicitly by the user in the deployment config (allowRemoteEmbedding); this plugin never lets the model side enable it. Local choices: {choices}. If the user has already set up remote credentials themselves (zg config provider set / zg auth grant <root> --capability embedding --scope workspace), enable the matching deployment setting and retry.",
379
380
  dropWithResetPaths: "drop conflicts with resetPaths: --drop does nothing but delete the index, so resetPaths has nowhere to go (upstream zg rejects the pair too). To clear inherited file-selection settings, do not pass drop.",
381
+ ignoreFileMissing: "{path} under {root} is not an existing file the current process can read (missing, a directory, or present-but-unreadable all count). Upstream zg does not treat a failed ignore-file read as \"no such rule\": the whole indexing run fails (ENOENT / EISDIR / EACCES) and the bad path is written into the workspace index state, after which every zg index / zg status on that tree reports the same error — even --reset-paths cannot clear it, only zg_index drop can. Give a path that really exists and that the current user can read.",
380
382
  exhaustiveFallbackNote: "[zvec-grep] This workspace (and every directory above it) has no zg index, so the search fell back to exhaustive lexical matching (rg mode). Results are literal line matches, not ranked by semantic relevance; run zg_index first if you need semantic search.",
381
383
  rgDescription: "Exhaustive lexical search (zg query --rg): needs no index, matches literal text line by line. Leave it unset to fall back to it automatically when the workspace has no index, and to use the index when one exists. An explicit false demands indexed search only (an error when there is no index). It does not support preview / refresh / fuse / symbolTypes / preferSymbol / fts / vector / queries, and it grants no grep/rg quota",
382
384
  intWithReceived: "{name} must be an integer >= {min} (received {received})",
@@ -2278,18 +2280,38 @@ const REBUILD_JOB_KIND = "zvec-grep-rebuild";
2278
2280
  const REBUILD_HISTORY_MAX = 10;
2279
2281
  /** 卡片视图的尾部长度(打标文案在 lib/messages.ts,随语言走)。 */
2280
2282
  const JOB_OUT_VIEW_CHARS = 4e3;
2283
+ /** 从名册投影推导身份证(官方 `JobView` 的三段稳定事实)。 */
2284
+ function identityOf(view) {
2285
+ return {
2286
+ kind: view.kind,
2287
+ label: view.label,
2288
+ startedAt: view.startedAt
2289
+ };
2290
+ }
2291
+ /** 两段身份证是否同一回事(三段全同才算)。 */
2292
+ function sameIdentity(left, right) {
2293
+ return left.kind === right.kind && left.label === right.label && left.startedAt === right.startedAt;
2294
+ }
2295
+ /**
2296
+ * 身份证尚未盖章时的占位出生时刻。
2297
+ *
2298
+ * `startedAt` 由官方签发(`Date.now()`,永不为 0),而 kind/label 在 `start` 之前就已
2299
+ * 已知——那正是本包递给官方的那份规格。于是"start 的同步块里就跑到了 `run()`"那一档读取
2300
+ * (官方 `start` 会同步跑第一拍)比对时必然落到"对不上":那一刻还没有可比的出生时刻,
2301
+ * 不该把同 id 的另一条作业当成自己的收走。
2302
+ */
2303
+ const UNSIGNED_STARTED_AT = 0;
2281
2304
  /**
2282
2305
  * 名册里那条 id 是不是**我们**的那条作业。
2283
2306
  *
2284
2307
  * 只比 id 不够:计数器是注册表的实例字段(实测两枚实例对同一 kind 都从 1 开始),换一枚
2285
- * 实例就重名。出生时刻由官方签(`Date.now()`),跨实例撞上同一毫秒的机会与"用户在服务重载后
2286
- * 一毫秒内又起一次重建"同阶,而那已经是另一次用户意图,卡片 404 重来即可。
2308
+ * 实例就重名;那时同 id 指向的是另一条作业(另一棵树/另一条命令),旧卡片跟上去就是串台。
2287
2309
  * @param state 这条记录的状态盒
2288
2310
  * @param view 名册里同 id 的那条投影
2289
2311
  * @returns 同一条作业
2290
2312
  */
2291
- function sameJob(state, view, live) {
2292
- return state.owner === live && state.bornAt === view.startedAt;
2313
+ function sameJob(state, view) {
2314
+ return sameIdentity(state.identity, identityOf(view));
2293
2315
  }
2294
2316
  /** 终止重建进程:kill 异常忽略(进程可能已自然退出/已被回收)。 */
2295
2317
  function killProc(proc) {
@@ -2449,7 +2471,7 @@ function followRunningRebuild(jobs, records, res, root) {
2449
2471
  const following = [...records.values()].find((record) => {
2450
2472
  if (record.root !== root) return false;
2451
2473
  const view = jobView(jobs, record.id);
2452
- return view !== null && sameJob(record.state, view, jobs) && isLiveStatus(view.status);
2474
+ return view !== null && sameJob(record.state, view) && isLiveStatus(view.status);
2453
2475
  });
2454
2476
  if (following === void 0) return false;
2455
2477
  sendJson(res, 200, {
@@ -2663,7 +2685,7 @@ function rebuildJobSpec(routes, proc, state, command, root) {
2663
2685
  const live = jobsOf();
2664
2686
  if (live === void 0) return null;
2665
2687
  const view = jobView(live, handle.id);
2666
- if (view === null || !sameJob(state, view, live)) return null;
2688
+ if (view === null || !sameJob(state, view)) return null;
2667
2689
  return {
2668
2690
  jobs: live,
2669
2691
  status: view.status
@@ -2699,6 +2721,49 @@ function rebuildJobSpec(routes, proc, state, command, root) {
2699
2721
  };
2700
2722
  }
2701
2723
  /**
2724
+ * `ignoreFiles` 的可用性预检:模型给的第 N 条忽略文件必须是**当前进程读得了的普通文件**。
2725
+ *
2726
+ * 为什么必须预检(全部实测,见 test/e2e/zg-cli.test.ts):真 zg 遇到读不成的 ignore 文件
2727
+ * **不是**按"没有这条规则"继续,而是整次索引失败(`ZVEC_GREP.ENGINE.INDEXING.WORKSPACE_FAILED`,
2728
+ * 原因是 ENOENT / EACCES / EISDIR),并且那个坏路径会**写进工作区索引的状态**——此后这条树上的
2729
+ * `zg index` 与 `zg status` 都报同一个错,`--reset-paths` 清不掉,只有 `zg_index drop`(整棵
2730
+ * 索引删掉重来)能救。一个拼错的文件名、一个存在但读不了的文件(mode 000 / 他人属主,用绝对路径
2731
+ * 还够得着系统文件)、或一个目录,就把用户的工作区索引弄坏,属于必须在起进程之前拦下的那一类。
2732
+ *
2733
+ * 判据「读得了 + 是文件」合成**一次** try(accessSync 在前):`statSync().isFile()` 对 mode 000
2734
+ * 的文件照样返回 true(stat 只要父目录可搜索、不要文件本身可读),故先 `accessSync(R_OK)` 补上
2735
+ * "当前进程真能 open 来读"这半段——它与 zg 的读权限同 uid 同源(root 下两者都放行、非 root 下
2736
+ * 两者都拒);再用 `isFile()` 挡掉目录。**不拆成「不存在」与「读不了」两条独立分支**:可读性那
2737
+ * 一档在 windows(chmod 只翻只读位,属主仍读得了)与 root(绕过 DAC)下根本造不出来,拆成独立
2738
+ * 分支会让 CI 的 windows 那格在 100% 覆盖率门禁下无从而钉(本仓不用 coverage-ignore 逃生口)。
2739
+ * 合成一句「不是存在且可读的文件」文案,三种成因都准确覆盖,且 catch 由「不存在」这一档跨平台钉住。
2740
+ *
2741
+ * drop 那一臂整段跳过:`--drop` 的命令只有 `zg index <root> --drop --yes`,ignoreFiles 被
2742
+ * buildIndexCommand 静默丢掉、根本不进 zg(见 lib/cli.ts 的 drop 分支),预检它没有意义,还会
2743
+ * 拿"给一个真实存在的忽略文件"这句误导文案把一次合法的删索引拦下。判 drop 用与构造器**同一个**
2744
+ * `boolOf`,两处口径不会漂。
2745
+ * @param args 索引入参(`ignoreFiles` 单值或数组;`drop` 为真时整段跳过)
2746
+ * @param root 已归一的工作区根(相对路径按它解析)
2747
+ * @param messages 文案表
2748
+ * @returns {void}
2749
+ * @throws Error 指向第一个不可用的条目(不静默丢弃用户给的那一项)
2750
+ */
2751
+ function assertIgnoreFilesExist(args, root, messages) {
2752
+ if (boolOf(args.drop, "drop", messages)) return;
2753
+ for (const entry of singleOrList(args.ignoreFiles, "ignoreFiles", messages)) {
2754
+ const target = entry.startsWith("/") ? entry : `${root}/${entry}`;
2755
+ let usable = false;
2756
+ try {
2757
+ accessSync(target, constants.R_OK);
2758
+ usable = statSync(target).isFile();
2759
+ } catch {}
2760
+ if (!usable) throw new Error(fill(messages.ignoreFileMissing, {
2761
+ path: entry,
2762
+ root
2763
+ }));
2764
+ }
2765
+ }
2766
+ /**
2702
2767
  * 起一条 `zg index`:命令构造 + resolve + execute 三步。
2703
2768
  *
2704
2769
  * 设置卡重建端点与模型侧后台索引**共用**这一个函数(不是复制品),所以两条入口起的作业
@@ -2721,6 +2786,7 @@ async function spawnIndexWrite(routes, started, indexArgs, embedding) {
2721
2786
  let spawned;
2722
2787
  try {
2723
2788
  await routes.versionGate.ensure(started);
2789
+ assertIgnoreFilesExist(indexArgs, assertAbsoluteRoot(indexArgs.root, started), started);
2724
2790
  const built = buildIndexCommand(indexArgs, embedding, started, readClientMode(config, started), allowRemoteEmbedding(config));
2725
2791
  const env = zgEnv(config);
2726
2792
  const spec = host.shell.resolve({
@@ -2767,18 +2833,20 @@ function attachIndexWrite(routes, root, started, spawned) {
2767
2833
  }
2768
2834
  pruneRebuildHistory(starting, records);
2769
2835
  const state = {
2770
- bornAt: 0,
2771
- owner: null,
2836
+ identity: {
2837
+ kind: REBUILD_JOB_KIND,
2838
+ label: command,
2839
+ startedAt: UNSIGNED_STARTED_AT
2840
+ },
2772
2841
  lost: false,
2773
2842
  timeoutNote: null
2774
2843
  };
2775
2844
  let jobId;
2776
2845
  try {
2777
2846
  jobId = startUnderController(starting, rebuildJobSpec(routes, proc, state, command, root));
2778
- state.bornAt = starting.get(jobId).startedAt;
2779
- state.owner = starting;
2847
+ state.identity = identityOf(starting.get(jobId));
2780
2848
  const clashed = records.get(jobId);
2781
- if (clashed !== void 0 && clashed.state.owner !== starting) {
2849
+ if (clashed !== void 0 && !sameIdentity(clashed.state.identity, state.identity)) {
2782
2850
  killProc(proc);
2783
2851
  return {
2784
2852
  error: started.endpointRegistryReplaced,
@@ -2896,7 +2964,7 @@ function handleRebuildStatus(routes, req, res) {
2896
2964
  });
2897
2965
  return;
2898
2966
  }
2899
- if (!sameJob(record.state, output.view, jobs)) {
2967
+ if (!sameJob(record.state, output.view)) {
2900
2968
  sendJson(res, 404, {
2901
2969
  ok: false,
2902
2970
  error: fill(marks.unknownJobId, { maxJobs: REBUILD_HISTORY_MAX })
@@ -2931,7 +2999,7 @@ function releaseRebuildRecords(routes) {
2931
2999
  if (jobs === void 0) for (const record of records.values()) killProc(record.proc);
2932
3000
  else for (const record of records.values()) {
2933
3001
  const view = jobView(jobs, record.id);
2934
- if (view === null || !sameJob(record.state, view, jobs)) killProc(record.proc);
3002
+ if (view === null || !sameJob(record.state, view)) killProc(record.proc);
2935
3003
  else if (isLiveStatus(view.status)) jobs.kill(record.id, void 0, unloadReason);
2936
3004
  else jobs.remove(record.id);
2937
3005
  }
@@ -3382,6 +3450,7 @@ async function runIndexTool(runtime, args, exec, messages) {
3382
3450
  if (rewriting && rebuilds.claim(root, "tool") === null) return { text: fill(messages.indexRebuildInFlight, { root }) };
3383
3451
  if (background) return startBackgroundIndex(runtime, root, indexArgs, messages);
3384
3452
  try {
3453
+ assertIgnoreFilesExist(indexArgs, root, messages);
3385
3454
  const { command, workdir } = buildIndexCommand(indexArgs, readDefaultEmbedding(config), messages, readClientMode(config, messages), allowRemoteEmbedding(config));
3386
3455
  return { text: await runForeground(host, command, workdir, config.indexTimeoutMs, {
3387
3456
  signal: exec.signal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-zvec-grep",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "dsh 工作区语义检索插件(zg):zg_search / zg_index / zg_status + 本地 embedding 设置卡片 + systemPrompt 路由规则 + guard 安全兜底。",
5
5
  "keywords": [
6
6
  "cordis",
@@ -50,6 +50,7 @@
50
50
  "@deepseek-ai/cordis": "4.0.5-alpha.1",
51
51
  "@deepseek-ai/cordis-plugin-timer": "1.1.7-alpha.1",
52
52
  "@deepseek-ai/dsh-api-remotes": "0.2.1-alpha.2",
53
+ "@deepseek-ai/dsh-bash-local": "0.2.1-alpha.2",
53
54
  "@deepseek-ai/dsh-client-locale": "0.2.1-alpha.2",
54
55
  "@deepseek-ai/dsh-client-store": "0.2.1-alpha.2",
55
56
  "@deepseek-ai/dsh-client-ui-layout": "0.2.1-alpha.2",
@@ -58,6 +59,7 @@
58
59
  "@deepseek-ai/dsh-client-ui-settings": "0.2.1-alpha.2",
59
60
  "@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.2",
60
61
  "@deepseek-ai/dsh-host-webserver": "0.2.1-alpha.2",
62
+ "@deepseek-ai/dsh-http-proxy": "0.2.1-alpha.2",
61
63
  "@deepseek-ai/dsh-jobs": "0.2.1-alpha.2",
62
64
  "@deepseek-ai/dsh-jobs-local": "0.2.1-alpha.2",
63
65
  "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
@@ -70,7 +72,9 @@
70
72
  "@deepseek-ai/dsh-settings": "0.2.1-alpha.2",
71
73
  "@deepseek-ai/dsh-shell": "0.2.1-alpha.2",
72
74
  "@deepseek-ai/dsh-subprocess": "0.2.1-alpha.2",
75
+ "@deepseek-ai/dsh-subprocess-local": "0.2.1-alpha.2",
73
76
  "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
77
+ "@deepseek-ai/dsh-timeout": "0.2.1-alpha.2",
74
78
  "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
75
79
  "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.2",
76
80
  "@deepseek-ai/schemastery": "3.18.5-alpha.1",