Dsh-SessionRelay: Auto-Inject SessionRelay Project Brief into DSH

Introduction

In command-line clients like ZCode and Claude Code, the process working directory is typically the project root, allowing hooks like SessionStart to inject project briefings into the context at the start of a session. DeepSeek Harness (DSH), however, is a desktop GUI application where the situation differs: process.cwd() points to the installation directory rather than the project; ctx.cmdlineArgs is empty; and AssembleContext only contains scope and signal, lacking cwd and project path information. While SessionRelay itself is an MCP service that can be queried, the MCP initialize response cannot inject instructions or resources into the conversation—content appearing in the context without explicit model requests must be placed by the client.

The following section introduces the community plugin dsh-sessionrelay (npm package name dsh-srelay-brief, maintained by rui08984-dot). It connects the project memory of SessionRelay to DSH’s official systemPrompt.section() injection point and renders a briefing before every model step. It also provides project resolution, automatic database creation, and two-stage secure binding. The plugin is categorized as “Memory,” currently has 0 GitHub stars, and is at version 0.2.0 (MIT).

What is this

dsh-sessionrelay is a native plugin for DSH, equivalent to the “SessionStart auto-briefing” capability in CLI clients, but adapted for DSH’s desktop environment regarding project determination and injection paths. Memory data is stored in .sessionrelay/ within the project directory. At runtime, it prioritizes the plugin’s bundled vendor/ copy. The design supports offline, self-contained operation and does not force users to install SessionRelay globally.

Core Features

Per-Turn Briefing Injection

The plugin registers a systemPrompt section that executes during every context assembly (i.e., before every model step). It displays recent decisions and pending issues for the current project; decisions include [MM-DD] dates, with a total length limit of 1200 characters.

The data retrieval path is SQL-First: it uses node:sqlite to open the local database in read-only mode (see src/brief-sql.mjs), with the CLI subprocess serving only as a fallback. The magnitudes provided in the documentation are: approximately 5 ms for the cold path and 1 ms for the hot path, compared to approximately 310–360 ms for a pure CLI approach. To compare against the old path, you can set the environment variable:

SRELAY_BRIEF_FORCE_CLI=1

Project Resolution

In common cases, no manual configuration is needed. The determination order is as follows:

① agent.session.header.cwd      → DSH-validated absolute cwd (per agent)
② env SRELAY_PROJECT_ROOT       → Must point to a directory containing .sessionrelay
③ DSH Session Reverse Lookup    → Most recently active session group under ~/.dsh/sessions
④ Registry's Only Live Project  → When there is only one valid project globally
⑤ Dangling                      → Do not guess; list candidates for user selection

The primary signal is ①: DSH provides the working directory upon session creation. The fallback ③ leverages DSH’s storage of sessions by directory slug, e.g., ~/.dsh/sessions/--E-music~0020player-- corresponds to E:\music player. Decoding cannot rely solely on string replacement (due to ambiguity between - and real paths); the plugin performs filesystem depth-first pruning, exploring only path prefixes that actually exist.

Level ⑤ intentionally avoids guessing the wrong project: injecting Project A’s briefing into a Project B session is more dangerous than not injecting at all, as the model cannot distinguish the source.

Automatic Initialization

The rule is a blacklist: Except for temporary directories, the DSH installation directory and ~/.dsh, npm global roots, and drive letter roots, opening a real folder in DSH will trigger an attempt to automatically create a memory database (approx. 190 ms, 166 KB; can be undone by deleting .sessionrelay/). Directories after git clone and folders opened via file managers will trigger this; monorepo subdirectories will bind to the repository root. It shares the same blacklist logic with the ZCode hook (~/.zcode/hooks/statebrief/brief.mjs); changes to the rules must be synchronized on both sides.

Seven Native Tools

Tool Function
srelay_search Search project history sessions and discussions
srelay_show View specific session messages and sources
srelay_record Sediment confirmed decisions
srelay_init Create a memory database for a directory (single step, reversible)
srelay_bind_project Propose switching the bound project
srelay_confirm_bind_project Takes effect after user confirmation
srelay_cancel_bind_project Cancel a pending proposal

srelay_init allows the model to actively create a database when needed; binding to an existing database follows a two-stage process (see next section).

Two-Stage Secure Binding

srelay_bind_project determines which SQLite database decisions are written to and cannot be unilaterally enforced by the model. The flow is: first call srelay_bind_project({ projectPath }) to merely record the proposal and prompt the user for confirmation; after the user agrees, call srelay_confirm_bind_project(); srelay_cancel_bind_project() abandons the proposal. Proposals are isolated by scope. The target path must already contain .sessionrelay, otherwise a “binding successful but subsequent calls silently fail” scenario may occur.

Self-Contained Runtime (vendor/)

Resolution order: SRELAY_CLI_PATH (development) → bundled vendor/ (default) → global npm (last resort fallback).

The Git repository does not contain vendor/ (approx. 62 MB of build artifacts). After installation, you must confirm the vendor directory is in place; otherwise, the plugin will not report an error but may fall back to the global upstream srelay, resulting in a semi-failed state where “everything seems normal, but briefings are always empty.” Acquisition methods include:

Method Description
Release Assets Download vendor-*.tar.gz from Releases and extract it to the plugin directory (offline capable)
npm Fetch node vendor-srelay.mjs (requires internet)
Local Copy node vendor-srelay.mjs --from <path> (offline)

Verification:

node -e "console.log(require('fs').existsSync('vendor/dist/srelay.js'))"

Should output true.

Installation and Activation

The plugin runs in the current DSH process’s Node environment, requiring Node ^22.19.0 || >=24.0.0 (see package.json). It is recommended to read the repository source code and MIT license before installing; the plugin directory page and GitHub are maintained by the community and have no official affiliation with DeepSeek / High-Flyer. In the DSH ecosystem, “everything is a plugin,” and SkillHub etc. are independent community directories.

Fill in the package name on the DSH Plugins page and install:

dsh-srelay-brief

Method 2: Command Line

dsh plugin --profile web add dsh-srelay-brief

Method 3: Install from GitHub

dsh plugin --profile web add https://github.com/rui08984-dot/dsh-sessionrelay

Regardless of the method, after installation, you should confirm that vendor/ is in place as described in the previous section. The documentation states: No pre-installation of SessionRelay globally is required.

Optional environment variable:

SRELAY_PROJECT_ROOT=/path/to/project/with/.sessionrelay

Typical Usage

  1. Open the project folder in DSH; if the directory is not blacklisted, the memory database will be created automatically.
  2. Chat normally: before every model step, the system prompt will include the project briefing (decisions and pending issues).
  3. When needing to check history or write decisions, ask the model to call srelay_search, srelay_show, srelay_record.
  4. To switch binding to another project that already has .sessionrelay: the model calls srelay_bind_project, and after you confirm in the interface, the model or you trigger srelay_confirm_bind_project().
  5. For a new project without automatic database creation, use srelay_init to create the database.

Applicable Scenarios and Notes

Suitable for: Teams or individuals who develop on the same repository in DSH long-term, wish to retain “decisions made / pending issues” across sessions, and have adopted or are willing to adopt the SessionRelay data model.

Notes:

  • The plugin accesses local files and SQLite with the same permissions as DSH; binding errors will write decisions to the wrong project database irreversibly, hence binding requires user confirmation.
  • If there is no vendor and the global srelay is not this specific fork, silent empty briefings may occur.
  • SRELAY_PROJECT_ROOT is noted in the documentation to mainly take effect for serve; CLI subcommands prioritize cwd.
  • Community Directory Page: SkillHub - dsh-sessionrelay; Source Code & Chinese README: GitHub - rui08984-dot/dsh-sessionrelay.

Conclusion

dsh-sessionrelay connects SessionRelay’s project memory to the only suitable injection point in DSH. Using SQL-first briefings, project resolution via DSH session reverse lookup, blacklist-based automatic database creation, and two-stage binding, it fills the gap in “opening memory” for desktop clients compared to CLI clients. The installation package name is dsh-srelay-brief; be sure to check the vendor directory after installation. For more information, see the Directory Page and GitHub Repository.

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

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

Xiaoye