icanfinish11/dsh-context-mode

Context window optimization for DeepSeek Harness agents. Sandboxes tool output in-process (only what you print enters the conversation), persists session memory in an FTS5 knowledge base, and enforces routing via a system-prompt routing section.

Project Overview项目介绍

dsh-context-mode is a standalone npm package shaped as a DeepSeek Harness (DSH) plugin bundle, declared through dsh.bundle in its package.json so it installs and publishes independently of the upstream context-mode npm package. Instead of launching a child MCP server, the adapter imports the engine's build/server.js directly via Node resolution — the exact module that the OpenCode and Kilo native adapters import — and registers every ctx_* surface (ctx_execute, ctx_execute_file, ctx_batch_execute, ctx_index, ctx_search, ctx_fetch_and_index, ctx_stats, ctx_doctor, ctx_purge, ctx_insight) into DSH's tools registry under its bare names, so there is no mcp__context-mode__ prefix and only the subprocess output enters the conversation. The SessionStart routing block is realised as a context-mode:routing section of the system prompt, because DSH exposes no hook channel for it.

It is aimed at DSH users who want to keep raw command output, curl/wget/inline-fetch responses and other noisy data out of the model context while still retrieving them later through a persistent FTS5/BM25 knowledge base, and at developers who need deterministic, sandboxed ctx_execute execution across sessions. Installation is one command — dsh plugin --profile web add icanfinish11/dsh-context-mode (or dsh-context-mode once published on npm, or link:/path/to/repo for a local checkout), followed by a dsh web restart and a ctx stats sanity check, or node scripts/dev-boot-probe.mjs with DSH_HOME/DSH_PROFILE set.

Runtime requirements are Node.js 22.5 or newer and a running DSH profile; the context-mode engine is a regular npm dependency that is fetched automatically, the plugin ships no engine code of its own, and the upstream engine by Mert Koseoğlu (mksglu) remains under Elastic License 2.0 while this repo declares no separate license (NOASSERTION). Operators should know that if all four engine resolution paths (config.enginePath, CONTEXT_MODE_ENGINE, the npm dependency, and the sibling layout) miss, the plugin silently degrades to routing-only with a warning and never breaks profile boot; PreCompact/PostToolUse hooks are not wired, so durable memory is created explicitly through ctx_index; and the bundle row id is context-mode, overridable per profile via $DSH_HOME/profiles/<name>/cordis.patch.yml with storageDir, routing, and per-tool flags such as tools.purge and tools.upgrade.

dsh-context-mode 是面向 DeepSeek Harness(DSH) 的独立 npm 包形态插件,把自己声明为 dsh.bundle 单元,可与上游 context-mode 包解耦发布与安装。它通过 Node 解析直接加载 context-mode 的 build/server.js 引擎模块(与 OpenCode/Kilo 原生适配器使用同一模块),并将 ctx_execute、ctx_execute_file、ctx_batch_execute、ctx_index、ctx_search、ctx_fetch_and_index、ctx_stats、ctx_doctor、ctx_purge、ctx_inspect 等工具以原生 ctx_* 名称注册进 dsh 的 tools 注册中心,绕开 MCP 子进程与 mcp__ 前缀,同时把 SessionStart 的路由拦截逻辑落到 context-mode:routing 系统提示片段上(DSH 无钩子通道),存储默认写入 $DSH_HOME/context-mode。

典型用法是希望把原始数据、命令输出与外部抓取拦在上下文之外、只把摘要写回对话的 DSH 终端用户,以及需要一套持久化 BM25/FTS5 知识库用于跨会话检索的开发者。安装一条命令即可:dsh plugin --profile web add icanfinish11/dsh-context-mode(或日后从 npm 拉取 dsh-context-mode,或本地 dsh plugin --profile web add link:/path),随后在 dsh web 重启并执行 ctx stats 验证。

依赖上,运行端只需 Node.js ≥ 22.5 与已启动的 dsh profile;上游 context-mode 引擎作为常规 npm 依赖自动拉取,本仓库不内嵌或重发布任何引擎源码,所有协议仍为原作者(Mert Koseoğlu / mksglu)的 Elastic License 2.0,本仓库未声明独立许可证。路由降级行为与边界需注意:若四处引擎路径(插件 config.enginePath、CONTEXT_MODE_ENGINE 环境变量、依赖解析、同级 layout)全部失败,插件将自动退化为仅路由模式并打 warning,但绝不阻塞 dsh profile 启动;PreCompact/PostToolUse 等会话连续性钩子未接线,持久化请显式调用 ctx_index;cordis.patch.yml 行 id 为 context-mode,可在 $DSH_HOME/profiles/<name>/cordis.patch.yml 覆写 storageDir、routing 与 tools.purge/tools.upgrade 等开关。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-context-mode

把 icanfinish11/dsh-context-mode 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-context-mode

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.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-venv 下一个 Next dsh-resume-expert →