dsh-zvec-grep: Integrating workspace semantic search into DSH sessions

Preface

When doing code-related tasks in DSH, models typically start by doing literal matching with grep or ripgrep. In large repositories, when keywords don’t line up, or when the question itself is “where is this logic”, purely lexical search can easily miss files that are semantically related but worded differently. Building a custom vector index and writing a search script on top of that requires maintaining a separate CLI, embeddings, and an index directory, and doesn’t fit into the toolchain of the session either.

The following introduces the community plugin @jayyuen66/dsh-zvec-grep (maintainer JayYuen666). It hooks zg CLI’s BM25, vector, and RRF hybrid search into dsh, exposing zg_search, zg_index, and zg_status to the model, along with systemPrompt routing, a search-first gate for grep/rg, and a web settings card. The current version of the plugin is 0.1.6 (MIT), with 0 GitHub stars.

What This Is

In one sentence: @jayyuen66/dsh-zvec-grep is a dsh adapter layer on top of zg (@zvec/zvec-grep). It calls zg through the host shell and does not distribute the upstream binary within the package.

Underlying search is handled by the separately installed zg; this plugin is responsible for registering model tools, injecting rules and guards, providing an embeddings and rebuild-related settings interface, and, in already-indexed workspaces, requiring “semantic search first, then grep/rg” (the gate can be disabled via configuration, with safety fallbacks still in place).

Core Features

Three Model Tools

  1. zg_search: requires at least one of query, queries, fts, vector (up to 32 total groups, up to 4000 characters per entry). Supports parameters such as globs, fileTypes, limit, preview, refresh, and device. When the workspace has no index, the default behavior automatically falls back to zg’s --rg exhaustive lexical channel; when an index exists, hybrid semantic search is used. The default transport mode is --mode auto: if the daemon is ready it uses server, otherwise zg silently falls back to direct.

  2. zg_index: confirm must be true for execution. Can build indexes, rebuild, and switch embeddings (switching embeddings requires rebuild=true). Supports background=true to run indexing on the model side in the background, sharing the same job registration logic as the settings card’s “workspace rebuild”.

  3. zg_status: view index status; when checkReady=true, readiness is expressed via the exit code according to the zg contract, while the report is still written to stdout.

All three accept an optional root (defaults to the current session workspace). Timeouts and stdout limits have deployment defaults (search 5 minutes, index 10 minutes, status 60 seconds, stdout 400000 bytes).

Rules and Gates

  • Injects a zvec-grep-routing section into the systemPrompt (order 1550), guiding the model to prefer semantic search.
  • search-first: in workspaces judged as “already contains an index”, grep/rg in bash/pwsh command strings or in native grep tools must be preceded by one successful zg_search (quota and window can be adjusted in settings: grepBudgetPerSearch, unlockWindowMin). enforceSearchFirst=false only turns off the gate, without weakening zg_*’s safety fallbacks such as root and confirm.
  • zg_* safety fallbacks: for example, zg_index without confirm is rejected; root must be an absolute path starting with / (POSIX).

Web Settings Card

The namespace zvec-grep is implicitly registered by the host. The card allows configuring the default embedding, defaultLimit, the HF mirror base URL hfEndpoint, the search-first switch and quota, etc.; additionally, there is a daemon-ready indicator row and a “workspace rebuild” button. Rebuild status is polled by the client every 2 seconds against the Remote interface zvecGrepRebuild (REBUILD_POLL_MS = 2000).

Platform and Support

  • Linux / macOS: root and command forms are designed according to POSIX (bash -c, paths separated by /).
  • Windows is not supported: when the workspace looks like C:\Users\…, the three zg tools fail-fast at the rootOf stage, with an explanation that root must start with /.

Installation and Enablement

Install the dsh Plugin

The package is on public npm with no credentials required. The official install command is:

dsh plugin --profile web add @jayyuen66/dsh-zvec-grep

add/remove maintains the registration line - id: zvec-grep in the package’s cordis.patch.yml. Bundle installation uses pnpm (>= 12.3.0), and when dsh.client.platform is web, the settings card client half is delivered by the host.

Host compatibility is compared against @deepseek-ai/dsh and each @deepseek-ai/dsh-* version according to peer declarations. This package pins exact versions of dsh-*; if the host is above the plugin’s declared 0.2.1-rc.2 range, use as prompted by the host:

dsh plugin --profile web allow-version @jayyuen66/dsh-zvec-grep@<version> --dsh-version <exact-version> --accept-risk

apply requires all five inject surfaces to be present: settings, shell, tools, systemPrompt, and timer; if any one is missing, cordis will not activate that entry.

Install the zg CLI

The plugin does not bundle zg. You must install the upstream CLI in your PATH, with version no lower than 0.2.2:

npm install -g @zvec/zvec-grep

When not installed or not in PATH, the tools distinguish exit 127 (zg missing) from other runner failures. Upstream repo: https://github.com/zvec-ai/zvec-grep, licensed under Apache-2.0.

Optional: Daemon (server mode)

refresh=background, the index watcher, and the resident embedding model pool are only available in server mode. The plugin does not run zg server on for you; start it yourself in a terminal if needed. This package only caches the exit code of zg server status --check-ready for about 60 seconds and displays the ready state on the settings card.

Typical Usage

1. Build an index for the current workspace

The model calls zg_index with confirm=true. For large repositories, globs/fileTypes can be added to narrow the scope; long-running indexing can use background=true, then progress can be viewed via the official job_list / job_output or on the settings card.

After building an index, use zg_search with a natural language or keyword query. The default preview=short attaches limited context; the default refresh=wait waits for the index to flush to the latest before searching.

3. Literal search without an index

On a root that has never been indexed, zg_search defaults to automatically using the --rg exhaustive channel and declares before the results that this is line-by-line literal matching rather than semantic ranking. For semantic results, you must run zg_index first.

4. Continue using grep/rg in an indexed workspace

When search-first is enabled, you must first complete one successful zg_search, then use grep/rg within the quota and time window. If rejected with a prompt saying “zg_search has not been executed yet”, simply run a semantic search first; there’s no need to turn off the entire plugin.

5. Change embedding or rebuild on the settings card

Modify volatile items like defaultEmbedding in the web settings; after switching embeddings, a rebuild (via the card button or zg_index with rebuild=true) is required for it to take effect. Remote embeddings are disabled by default; you must explicitly enable the relevant item in the deployment config, and on the zg side you also need to authorize yourself via zg auth grant.

Use Cases and Notes

Who it’s for: developers who frequently ask the model to search code within DSH (web profile) and are willing to maintain a local zg index and embeddings on Linux/macOS.

Dependencies and versions: if the profile uses pnpm overrides to pin @jayyuen66/dsh-plugin-shared, the version must not be lower than the one declared by this package, otherwise an export-missing error of “the package installs, but the entry doesn’t activate” may occur.

Data and privacy: indexes are written under .zvec-grep/ in each search root, written by zg; this plugin itself does not write to $DSH_HOME. Common secret extension names are excluded by default; secret files without extensions need to be declared yourself via ignoreFiles. Explicit embeddings only allow models from the local candidate list by default, to prevent the model from arbitrarily specifying a remote endpoint that would send the workspace externally.

Permissions and security: the plugin calls zg via the shell with the permissions of the current dsh process; the read/write scope is consistent with the session workspace and zg’s behavior. Before installing, please read the GitHub repository source code and the MIT license; zg upstream is Apache-2.0, and when distributing together, the respective license notices must be retained separately.

The DSH ecosystem emphasizes “everything is a plugin”; the community directory SkillHub plugin page has no official affiliation with DeepSeek / Hundsun Funds and is only for discovery and linking purposes.

Conclusion

@jayyuen66/dsh-zvec-grep brings zg’s hybrid search, index management, and search-first discipline into the dsh tool surface, reducing the gap between “only knowing how to grep for keywords” and “setting up a separate set of index scripts”. After installing the plugin and zg as described above, and building an index on a POSIX host, the model can locate code using semantic search within the session, while continuing to use grep/rg within the bounds allowed by the rules.

  • Community directory: https://www.skillhub.cn/plugins/JayYuen666/dsh-zvec-grep
  • Source code and docs: https://github.com/JayYuen666/dsh-zvec-grep
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye