dsh-session-query-cjk: Enabling Chinese Session Retrieval in DeepSeek Harness

Introduction

In DeepSeek Harness (DSH), searching old conversations is commonly done via the magnifying glass in the session sidebar or the session.search triggered by a shortcut. The official backend @deepseek-ai/dsh-session-query-sqlite is based on SQLite FTS5’s unicode61 tokenizer: continuous Chinese characters are often treated as a single token, making it only possible to match whole paragraphs. Single or double characters scattered in the body are hard to find. When spoken terms do not match the text (e.g., saying “香包” [incense bag] but writing “香囊” [incense pouch]), alignment is difficult.

The community plugin dsh-session-query-cjk (maintainer sarsgy-wenjian, category: Memory) replaces the official SQLite backend at the interface level. It uses a three-layer stack of character-level indexing, alias expansion, and pinyin fuzzy matching to fill these gaps. The following sections explain “What it is -> Capabilities -> Installation -> Configuration and Usage -> Notes”.

What is it

dsh-session-query-cjk is a session full-text search backend plugin, version 0.5.0 (MIT). Its peerDependencies align with DSH 0.2.2-rc.3 and session-related packages. It does not modify the client UI; it only takes over the Host side’s searchSessions implementation. The plugin reads and writes the local index and cache under the current DSH process permissions. Before installing, you should check the source code and license of the repository yourself.

One-sentence positioning: Chinese character-level FTS5 index (searchable from 1 character) + colloquial alias expansion + pinyin fuzzy matching; it can directly replace the official dsh-session-query-sqlite.

What is missing or added compared to the official backend

The pain point of the official solution is written directly in the README: the same continuous Chinese string can only be matched as a whole. The processing chain of this plugin is: Index at character level -> Expand synonym/homophone candidates on query -> OR check.

Capability Solves
Character-level index Searchable from 1 character, no need to accumulate three characters
Alias expansion Inputting “香包” can match the original “香囊”
Pinyin fuzzy matching Still find the target even if the pronunciation is correct but characters are wrong (depends on alias table/vocab range)

Benchmarks from the README on the local index database (88 sessions, 19,035 docs, 88.0 MB) include: single character “林” matched 2,220 docs; alias “香包” expanded to “香囊” matched 2,494 docs; misspelled “林晚丘” normalized by pinyin got the same result as “林晚秋”. These numbers are from the repo README and do not represent your environment.

Installation and Usage

Environment Requirements

Item Requirement
Node (Plugin) ≥ 22.13 (Built-in node:sqlite; recommended 24.x)
Node (npm install @deepseek-ai/dsh) ≥ 24.9
DeepSeek Harness 0.2.2-rc.3

Run node -v before installing. The default Node on cloud hosts may be below requirements, so you need to place a compatible version of Node in the PATH.

The package declares dsh.bundle. After installing the bundle, the official backend is automatically disabled and this package is enabled, no need to manually modify the profile:

plugin_manager install_bundle
  target: git+https://github.com/sarsgy-wenjian/dsh-session-query-cjk

(When published to npm, you can also use the short name dsh-session-query-cjk.)

Restart DSH after installation; Indexing starts on the first search (default openAt: first-search, to avoid creating an empty database when the session service is not ready at startup).

Method B: Manual Installation

  1. Place the package directory in %USERPROFILE%\.dsh\profiles\<profile名>\node_modules\dsh-session-query-cjk\, confirming lib/index.js and lib/pinyin-data.json exist.
  2. In the profile’s cordis.patch.yml, disable the official backend and insert this plugin (consistent with the one in the repository’s cordis.patch.yml):
- id: session-query-sqlite
  name: "@deepseek-ai/dsh-session-query-sqlite"
  disabled: true

- insert:
    - id: session-query-cjk
      name: dsh-session-query-cjk
  1. Restart DSH.
    Indexing takes time related to data volume (README example: ~1 minute for the scale mentioned above). The index defaults to ~/.dsh/cache/session-query-cjk.db, with a size about 3 times that of the original text.

Configuration Items (Can be omitted entirely)

Zero configuration works: if config is not written, the index database and default alias path are automatically created in the约定 directory. Common fields are as follows.

Configuration Default Description
path ~/.dsh/cache/session-query-cjk.db Index database path
openAt first-search When to build DB: startup / first-search / never
defaultLimit 20 Default return count
maxLimit 100 Single query upper limit
aliasFile ~/.dsh/cache/session-query-aliases.json Alias table; no extension if not exists
vocabFile ~/.dsh/cache/session-query-vocab.json Corpus pinyin vocabulary; if not exists, pinyin layer mainly relies on alias table
relax auto Whether to automatically relax one character when there is zero hit: auto / off

aliasFile, pinyinFile, vocabFile support hot update. Starting from 0.4.0, when there are zero hits, punctuation can be removed, window truncated, or one character deleted before re-querying according to rules. The summary will be marked 〔Relaxed to “…”〕 when a match is found; set relax: off to disable.

Typical Usage

Search in the Client

The entry point for DSH 0.2.2-rc.3 is still there: the magnifying glass to the right of the “Session/Workspace” group title in the sidebar (visible when the sidebar is expanded), or Ctrl+K (Web version Ctrl+Alt+K). After entering keywords, it goes through session.search -> this plugin retrieves.

Note: The client merged display upper limit is 20 sessions (SESSION_SEARCH_RESULT_LIMIT), and only shows sessions that exist in the list and are not filtered by archive. When the backend has more hits, having fewer items in the interface is a client limitation, not a missing index. To get full results, use Agent-side tools or query the index database directly.

Alias Table (Zero Configuration Path)

If aliasFile is not written, just place the JSON in ~/.dsh/cache/session-query-aliases.json:

{
  "香包": ["香囊"],
  "册子": ["图册"],
  "惠兰": ["李蕙兰"],
  "林氏": ["林家"]
}

The original query word still participates in the search. Up to 6 candidates can be expanded per time, connected by OR. Keys starting with _ are treated as comments. Aliases need to be maintained manually; the plugin does not include a built-in business vocabulary.

Corpus Pinyin Vocabulary (0.5.0)

If roles, place names, etc., appear only in the session body, you can run the script not distributed with the package inside the repository, extract words from the local index database and write them to the default session-query-vocab.json:

node dev/build-vocab.mjs

You can refresh after rebuilding the index. Pure alphabetic queries (since 0.4.1) will split by syllable and query the pinyin index, e.g., linwanqiu expands to “林晚秋” – provided there is a corresponding entity in the alias table or corpus vocabulary.

Principle Summary

Write and Query share sanitizeFtsText(): Insert \u0001 between adjacent characters, making unicode61 tokenize by character, then wrap it into an FTS5 phrase, semantically equivalent to original text substring matching. Aliases and Pinyin are expanded into multiple phrases OR in quoteFtsData(). The Pinyin layer normalizes zh/ch/sh, n/l, front/back nasal sounds, etc., covering only words in the alias table and corpus vocabulary, not a full database pinyin index.

Suitable Scenarios and Limitations

Suitable for: Many Chinese conversations, relying on sidebar or Ctrl+K to recall context; colloquial names and frequent typos; willing to maintain a small alias JSON, or accepting the generation of a corpus vocabulary from the local database.

Must Note:

  • Single character query has a wide hit range (README example “林” thousands of docs), which is substring semantics, not a bug.
  • After new sessions are indexed, the index is a snapshot; you need to delete .db or refresh according to project instructions before you can search for new content.
  • Pinyin polyphones only take the Unihan main reading; low-frequency corpus vocabulary may be filtered by the build script min-count.
  • Auxiliary scripts (PDF/OCR attachment search, etc.) are in a separate directory, not included in the npm package, and are unrelated to the session search lifecycle.

The DSH ecosystem is “everything is a plugin”; the SkillHub Directory Page is community-captured and has no official subordination relationship with DeepSeek / Huafang.

Conclusion

If your pain points are “incomplete Chinese search, inconsistent naming, homophone typos”, dsh-session-query-cjk allows you to try it by replacing the backend with a bundle or patch while keeping the official search entry. Details and changes can be found in the repository README and CHANGELOG.md; directory index can be found on the SkillHub Plugin Page.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye