DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-context-mode

p

dsh-context-mode

Manifest valid3

DSH 原生 Cordis 插件:知识库(FTS5)、路由强制、会话记忆、沙箱执行(Think-in-Code)——context-window 减负

hasBundlePatch

dsh-context-mode

这是给 DeepSeek Harness(DSH)的一个小插件。核心只有一句话:让进上下文的原始数据越少越好

它不做花哨的事,只干三件实在的:把大文件和网页索引进本地知识库、把会把窗口撑爆的洪水工具拦下来改道、把数据处理丢进沙箱只带回答案。


它到底做什么?

1. 知识库:索引 + 检索

  • ctx_index:把文件或整个目录切成小块,存进本地 SQLite 知识库(FTS5,支持中文模糊和英文词根)。
  • ctx_search:只返回命中的小片段,不是整本书。默认每次最多回 12000 字节。
  • ctx_fetch_and_index:抓网页转成 markdown 后同样入库,原网页字节不进上下文。
  • ctx_purge:清空知识库(不可逆,想清楚再用)。

2. 路由拦截:洪水别进来

挂在工具执行前,直接挡掉或引导:

  • 硬拦curlwgetinline-fetch 这类确定会拉大文件进上下文的命令,直接拒绝。
  • 软引导:文件超过约 50KB 且不是精确分段读(没有 offset/limit),拒绝并告诉你该用 ctx_indexctx_search
  • 白名单pwdecholswhoami 这些无害命令,零摩擦放行。

3. 沙箱执行:只带答案回来

  • ctx_execute:写一段代码在隔离沙箱里跑,只把 console.log 的结论带回来。原始数据留在沙箱,不进上下文。
  • ctx_execute_file:把一个文件的内容当作输入数据(FILE_SRC),跑分析、统计、过滤,只返回结论。
  • ctx_batch_execute:并行跑多段分析,结果自动入库,同一轮还能直接检索。

沙箱规则简单记住:代码里不能写 require("node:fs")import(沙箱没有模块系统);FILE_SRC 已经是文件完整内容,直接处理,不要再去读文件路径。


安装(一步到位)

cd "$HOME/.dsh/plugins/dsh-context-mode"
git clone https://github.com/pharaohnie/dsh-context-mode.git .  # 如果还没克隆
dsh plugin --profile web add "$HOME/.dsh/plugins/dsh-context-mode"
./relink-dsh-context-mode.sh

然后重启 DSH(UI 点重启,或重启服务进程)。

验证:跑 ctx_doctor,关键项应全是 ✓(记忆捕获、安全基线、子代理守卫默认关闭,显示 ✗ 是正常的,不是故障)。


工具一览

工具一句话作用
ctx_index文件/目录 → 知识库
ctx_search检索,只回片段
ctx_fetch_and_index抓网页 → 知识库
ctx_purge清空知识库
ctx_execute沙箱跑代码,带答案回来
ctx_execute_file文件内容做数据分析
ctx_batch_execute并行分析 + 同轮检索
ctx_doctor自检状态
ctx_stats看节省了多少上下文字节

常用配置(简单版)

大部分开关可用 CONTEXT_MODE_* 环境变量覆盖。几个常用的:

开关默认说明
routingEnabledtrue总开关
maxReadBytesBeforeAsk51200文件超过这个大小会被引导用检索
executeAllowShelltrue沙箱里允许用 shell 语言
memoryCapturefalse会话记忆捕获(隐私考虑默认关)
securityEnabledfalse安全基线(默认关,避免打扰)

完整键值看 src/config.ts,每个都有注释。


快速验证

  1. 安装后重启 DSH。
  2. 运行 ctx_doctor:关键项(tools、systemPrompt、FTS5、知识库、门禁)应为 ✓。
  3. 运行 node scripts/smoke.ts:纯逻辑回归,不需要 DSH 运行时,直接跑。
  4. 检查 curl http://127.0.0.1:3080/dsh-market/installeddsh-context-mode 应显示 live True

常见问题(简洁版)

现象原因修复
not installed插件目录的 node_modules 链接坏了重新执行 dsh plugin --profile web add
duplicate loader entry同时在 bundles 和 cordis.patch.yml 注册了插件保留 bundles 登记,删除 cordis.patch.yml 里的手动 insert 行
ERR_MODULE_NOT_FOUNDnode_modules 指向了旧的 DSH npx 缓存./relink-dsh-context-mode.sh

这插件不做什么

  • 不压缩已在上下文里的内容(只在入口引导)。
  • 不声称省了 98% 字节(ctx_stats 把两个口径并列:精确测量 + 估算下界,不混着报)。
  • 不是数据沙箱(沙箱是资源隔离,不承诺程序绝对读不到宿主文件)。

运行要求

  • Node ≥ 24(node:sqlite 自带 FTS5,直接加载 .ts,不需要预构建)。
  • DSH v0.1.1-rc.2(或兼容版本)。
  • 知识库默认在 ~/.context-mode/content,多进程共享时用 WAL 模式防写锁。

许可证

MIT。源码即入口:package.jsonmain 指向 src/index.ts,无构建产物(dist/ 已移除)。发布到 npm 前需要预构建并切换入口(pnpm run build 已就绪,发布路线待定)。

Versions

Latest versionPublishedSize
0.1.0
0.1.1
0.1.2
0.1.3
0.2.0
0.2.1
0.2.2
0.3.0
0.3.1
0.3.2
0.3.3
0.4.0
0.5.0
0.5.1
0.5.2
0.5.3

Comments

Loading…

Similar plugins

dsh-context-mode

by icanfinish11

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

Sessions & MessagesManifest valid

0

JavaScript

Sep 9, 2026

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

by dsh-plugins

A version‑aware adapter registry that decouples third‑party Cordis plugins from dsh’s internal service names, paths, and RPC internals. 基于版本感知适配器注册表,为 dsh Cordis 插件提供运行时兼容层,使第三方插件与内部服务名、模块路径及 RPC 细节解耦

Manifest valid

3

TypeScript

Sep 7, 2026

dsh plugin --profile web add @dsh-plugin/dsh-loader

by zdjmrq

DSH 用户插件管理器:在 设置→插件 统一管理插件目录散件、运行树插件与 npm 插件包——挂载/卸载/启用/停用(cordis.patch.yml 补丁层 + HMR 热生效)

Manifest valid

3

MIT

JavaScript

Aug 18, 2026

dsh plugin --profile web add dsh-pluginmanager

by Anionex

deepseek harness对话和代码状态回退插件 | DSH — rewind conversation and workspace state, powered by a persistent Change Ledger

Tools & CapabilitiesTerminal & ClientsSessions & MessagesManifest valid

117

BSD-3-Clause

JavaScript

Sep 14, 2026

dsh plugin --profile web add @anionex/dsh-turn-rewind

Cross-session memory for the model: full-text search all past sessions (SQLite FTS5 via ctx.sessionQuery) and bring the strongest matching excerpts back into the current context.

Memory & ContextManifest valid

0

dsh plugin --profile web add dsh-plugin-recall

by liceses

把 DSH Web 左侧栏的「工作区」重做为文件系统树双模式。核心原则: 工作区 = 目录强绑定——会话的 cwd 就是它所在的目录,环境真正隔离。

Manifest valid

7

MIT

JavaScript

Sep 8, 2026

dsh plugin --profile web add dsh-workspace-tree