为 DeepSeek Harness 适配 Context Mode:进程内 ctx_* 工具(沙箱代码执行与 FTS5 知识库),并注入上下文窗口路由指引。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:icanfinish11/dsh-context-mode
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Context Mode (the MCP server that keeps raw data out of the context window) as
a self-contained DeepSeek Harness plugin package. This folder is its own
npm package (package.json declares dsh.bundle), so it installs and
publishes independently of the context-mode npm package.
The plugin loads context-mode's engine library in-process (build/server.js
of the dependency context-mode package — the same module the OpenCode/Kilo
native adapter imports) and registers the ctx_* tools natively into dsh's
tools registry under their bare names — no MCP child process, no
mcp__context-mode__ prefix. The engine is always taken from the original
author's published npm package; this repo ships only the dsh adapter.
Contents
| Path | Purpose |
|---|---|
index.js |
Plugin module (name / inject / apply), engine location + registration |
cordis.patch.yml |
dsh bundle patch (insert row id context-mode) |
package.json |
npm metadata + dsh.bundle.patch manifest, depends on context-mode |
scripts/dev-harness.mjs |
Engine-level test: mock ctx, tool registration + FTS5 round trip |
scripts/dev-boot-probe.mjs |
Real dsh profile boot probe (dsh-app-boot), tool catalog check |
What you get
| context-mode surface | dsh surface |
|---|---|
ctx_execute / ctx_execute_file / ctx_batch_execute |
native dsh tools (sandbox subprocess, only printed output enters the conversation) |
ctx_index / ctx_search / ctx_fetch_and_index |
native dsh tools (persistent FTS5 knowledge base, BM25 search) |
ctx_stats / ctx_doctor / ctx_purge / ctx_insight |
native dsh tools |
| SessionStart routing-block hook | context-mode:routing system-prompt section (dsh has no hook channel; the section plus the tool schemas are the enforcement surface) |
| session continuity (PreCompact/PostToolUse capture) | not wired — dsh has its own session/compaction layers; use ctx_index explicitly for durable memory |
All tools run the exact context-mode implementations, including security
routing (curl/wget/inline-fetch blocking), the executor's language matrix, and
the FTS5 content store. Storage defaults to dsh's own home
($DSH_HOME/context-mode, i.e. ~/.dsh/context-mode) so the knowledge base
is per-harness and never writes into another harness's config tree; set the
plugin storageDir (or CONTEXT_MODE_DIR/config) to override.
Install
Requirements: Node.js ≥ 22.5 and a running dsh profile. The context-mode
engine package is a regular dependency and is installed automatically; no
build step is needed for this plugin (pure JS).
From GitHub (the canonical install):
dsh plugin --profile web add icanfinish11/dsh-context-mode
From npm (once the dsh-context-mode package is published):
dsh plugin --profile web add dsh-context-mode
From a local checkout of this repo:
npm install # installs the context-mode engine dependency
dsh plugin --profile web add link:/path/to/dsh-context-mode
If you develop with this folder checked out inside a context-mode repo clone (
dsh/next to the engine root), build the engine first (npm run buildin the engine root) so the sibling layout resolves; a normal install never needs that.
Restart dsh web. Verify with ctx stats in a session, or:
node scripts/dev-boot-probe.mjs # DSH_HOME + DSH_PROFILE env required
Engine location order
config.enginePath(plugin config)CONTEXT_MODE_ENGINEenv var- the dependency
context-modepackage via Node resolution — thecontext-mode/package.jsonsubpath export when upstream provides it, otherwise the package root resolved from its main entry by walking up to thecontext-modepackage.json (works with the published package as of 1.0.169, under npm flat/nested and pnpm store layouts) - sibling layout (
../build/server.js— dev inside the context-mode repo only)
If none resolve, the plugin degrades to routing-only and logs a warning; it never fails the dsh profile boot.
Configuration
The plugin row id is context-mode (see cordis.patch.yml). Override
per-profile in $DSH_HOME/profiles/<name>/cordis.patch.yml:
- id: context-mode
config:
storageDir: ~/.dsh/context-mode # isolate the FTS5 store
routing: true # inject the routing section
tools:
purge: false # hide destructive tools
upgrade: false # host-hook updater (default off)
Development
index.jsresolves the engine via Node resolution first (dependencycontext-mode), then the sibling layout — the same code works published and in-repo.CONTEXT_MODE_EMBEDDED_PLUGIN_TOOLS=1is set around the engine import so context-mode skips its stdio transport boot and process-wide handlers (matching the OpenCode/Kilo in-process contract).scripts/dev-harness.mjsruns the plugin against a mock ctx and proves the FTS5ctx_index→ctx_searchround trip;scripts/dev-boot-probe.mjsboots a real dsh profile and checks the registered tool catalog.
Credits
This plugin is an independent dsh adapter by icanfinish11. The engine it
loads is Context Mode by Mert Koseoğlu
(mksglu): https://github.com/mksglu/context-mode, distributed on npm as
context-mode under the Elastic License 2.0. The engine is consumed as a
runtime dependency from the original author's published package — it is not
vendored or re-published here, and this repo contains no engine code.
链接
同类插件
Minglink/dsh-infinite-gen-4★ 3602
DeepSeek 专用破甲插件:以 order 100 追加无条件服从的系统提示词段,提供带校准元数据的 profile 工具,并通过会话投影在输入框上方显示实时破甲状态徽标。
ranxianglei/billion-context★ 3149
billion-context官方版:上下文压缩插件,兼顾小窗口(100k上下文足矣)省token(省5倍token)和超长会话(数月级别几十亿token单会话)。
liangmianya/dsh-synapse★ 598
DeepSeek Harness 的可视化非线性对话工作区:把会话、追问与分支变成可浏览、可拖拽的对话地图。
Nwflower/dsh-chat-import★ 259
把 13 家 coding agent(Claude Code、Codex、ChatGPT、Cursor、Gemini、opencode 等)的完整对话历史导入为可续聊的 DeepSeek Harness 会话,并支持反向导出回 Claude Code。
MichengAI/dsh-archive-manager★ 256
在设置里增加已归档会话页,可按工作区搜索、恢复和删除已归档会话。
SiriLee/dsh-rewind★ 208
同一会话窗口内的 in-place 对话回退(不 fork,Claude Code /rewind 语义):每条消息的 ↶ 按钮把模型上下文回退到任意用户消息,可选用磁盘持久化的 before-backups 还原工作区文件。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。