按项目控制工具可见性:每一步装配前,会话从工作目录向上最多 32 层查找 `.dsh/tool-gate.json`,据此裁剪交给模型的工具集 —— 支持 allow / deny 名单与 `prefix*` 通配,找不到规则文件时为 off;另有 `tool_gate_status` 工具报告当前模式、规则文件来源与被隐藏的工具。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:xuxue04403/dsh-tool-gate
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。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
按项目门控 DeepSeek Harness 的工具集合:当前项目不需要的工具,其定义不会在每一步随请求下发, 从而缩小每步上下文、加快首个 token、降低长会话成本。
- 规则文件放在项目里:
.dsh/tool-gate.json - 三种模式:
off(默认,零影响)/allow(白名单)/deny(黑名单) - 规则支持
前缀*通配,从会话目录向上查找,子目录继承父目录 - 改规则文件即时生效,不需要重启会话
- 自带
tool_gate_status工具,可随时自查「现在屏蔽了哪些工具」
为什么
dsh 每一步(preStep)都会把「可见且 when 成立」的工具全量装配进请求。第三方插件几乎都不声明
when,于是装多少就每步发多少 —— 插件一多,每步的 tool schema 就把上下文吃掉一大截。
本插件在 ToolsService.resolve()(每步装配的唯一入口)外面包一层,按项目规则裁剪返回的工具集合。
因为拦在装配口而不是注册口,它和「插件是谁、什么时候注册的」无关,不存在顺序问题。
安装
前置:dsh ≥ 0.2.2-rc.0;已有一个 profile(~/.dsh/profiles/<name>)。
两种方式,任选其一。
A. 直接从 GitHub 装(最快,pnpm 会拉仓库并读取里面的 cordis.patch.yml):
dsh plugin --profile quant add github:xuxue04403/dsh-tool-gate
B. 下载 release 里的 zip,解压后:
# 在解压后的插件目录里执行
pwsh -File .\install.ps1 -Profile quant
脚本做三件事:
- 把插件复制到
<profile>/vendor/dsh-tool-gate dsh plugin --profile <profile> add file:vendor/dsh-tool-gate- 把
dsh-tool-gate写进<profile>/package.json的dsh.profile.bundles,位置紧跟@deepseek-ai/dsh-base
为什么不用
npm i:宿主只加载出现在dsh.profile.bundles里的包;直接dsh plugin add只会装成依赖, 图层不生效。且file:依赖指向 profile 之外时会静默不加载,所以必须落在vendor/里。
桌面客户端(DeepSeek Harness Desktop)
桌面端只认 ~/.dsh/profiles/desktop(源码里写死:resolveDesktopPaths() → join(dshHome,"profiles","desktop")),
没有 profile 选择入口,dsh --profile desktop 也会被拒绝(profile "desktop" is managed exclusively by the Electron application)。
所以装到 desktop:
pwsh -File .\install.ps1 -Profile desktop
这一步不起 pnpm,只做:复制到 profiles/desktop/vendor/dsh-tool-gate → 在 profiles/desktop/node_modules
建一个目录联接 → 写进 desktop 的 dsh.profile.bundles。然后完全退出并重开桌面端(插件在启动时加载)。
挂上之后,「按项目自动裁剪工具」就不需要任何命令或切换动作了:
D:\quant-lab\.dsh\tool-gate.json -> 量化项目只下发 fin_*/astock_* 等
D:\IDE\dsh\.dsh\tool-gate.json -> 开发项目去掉 trading_* 等
(没有规则文件的项目) -> off,一切照旧
卸载:pwsh -File .\install.ps1 -Profile desktop -Uninstall。
安装后重启 dsh(补丁层在启动时加载)。想确认装载成功:
$env:DSH_TOOL_GATE_DEBUG='1'
dsh --profile quant # stderr 应出现: [tool-gate] applied, enabled=true, mode=off
使用
在项目根建规则文件:
New-Item -ItemType Directory -Force .dsh | Out-Null
'{"mode":"allow","allow":["fin_*","astock_*","web_fetch","web_search"]}' |
Set-Content .dsh/tool-gate.json -Encoding utf8
{
"mode": "deny",
"allow": [],
"deny": ["todos_*", "market_*"]
}
| 字段 | 说明 |
|---|---|
mode |
off 全放行(默认);allow 只有命中的下发;deny 命中的不下发 |
allow / deny |
工具名数组,支持精确名与 前缀* |
| 找不到规则文件 | 回落到 profile 配置里的兜底规则(默认 off) |
会话中随时自查:
调用
tool_gate_status,看hidden列表。
输出形如:
{
"cwd": "D:\\quant-lab",
"mode": "allow",
"source": "D:\\quant-lab\\.dsh\\tool-gate.json",
"known": 32,
"visible": 8,
"hidden": ["read", "write", "edit", "shell", "subagent", "..."]
}
典型组合
| 场景 | 规则 |
|---|---|
| 量化研究项目 | allow: ["fin_*", "astock_*", "backtest_*"] |
| 日常写代码 | deny: ["trading_*", "market_*", "pet_*"] |
| 只想安静聊天 | allow: ["web_fetch", "web_search"] |
配置项(profile 级)
在 <profile>/cordis.patch.yml 里改 tool-gate 那一行:
- id: tool-gate
name: dsh-tool-gate
config:
enabled: true
file: .dsh/tool-gate.json # 规则文件相对路径
mode: off # 没有规则文件时的兜底
allow: []
deny: []
always: [] # 永不门控的工具
log: false # true = 每次装配打印判定结果
卸载
pwsh -File .\install.ps1 -Profile quant -Uninstall
已知边界
- 只影响「本步下发给模型的工具集合」,不改注册、不改历史会话记录;被屏蔽的工具当步不可调用,放开后立刻恢复。
- 只包住 profile 级
ToolsService;同一 profile 内所有会话共用这套规则(按各自工作目录解析)。 - 每步都重新向上查找并读取规则文件:增删改规则都是即时生效的(只是每次多几十次
stat,可忽略)。
开发
node test/gate.test.mjs # 11 个用例,纯 node,不需要 dsh
pwsh -File .\sync.ps1 # 改完代码同步到 quant / dev / desktop
sync.ps1 里那句 remove + add 是必须的:pnpm 对 file: 依赖是复制且 spec 不变时不会重新复制,
只覆盖 vendor/ 目录不会生效。
License
MIT
链接
同类插件
DayuanJiang/next-ai-draw-io#dsh-plugin★ 36802
dsh 的 draw.io 绘图插件:通过 next-ai-drawio MCP 服务器作图,点回复里的链接在右侧栏打开实时预览,可以手动修改图,AI 的每次修改都是可以恢复的版本。需 Node.js 18+,首次使用由 npx 下载 MCP 服务器。
Tencent/WeKnora#dsh-weknora★ 36302
把 WeKnora 知识库接入 dsh 的四个只读工具:列出知识库、混合检索原文片段、按顺序还原单篇文档,以及直接取用 WeKnora 自己带引用的 RAG 或 ReAct agent 回答(含可续聊的 session id)。
superdesigndev/treg★ 7042
给 Agent 的工具目录:按「要做的事」检索约 2,600 个外部接口(SEO 与 SERP、外链、社交、人物与公司信息补全、广告库、抓取),查看参数与单次调用价格后直接调用,凭据由服务端注入。附带技能,MCP 行在未设置 TREG_TOKEN 前保持禁用。
T-Auto/dsh-ops★ 5074
为 Windows 的 DSH 提供 bash、PowerShell 7 及 Rust 高性能工具,减少 token 消耗。
sixtysevenlf/dsh-blender-plugin★ 1575
让 DSH agent 通过直连 TCP 通道驱动本地 Blender,提供 15 个工具:视口帧、自定义视角渲染、Python 执行、无头与作业卸载、事务回滚,以及 34 个 family / 228 个 op 的规划层。
TencentCloudBase/CloudBase-AI-Toolkit#dsh-plugin★ 1155
把腾讯云 CloudBase 后端接入 DeepSeek Harness——在对话里搭好并部署全栈应用,查询结果渲染为表格卡片(分页、排序、导出 CSV),部署后可预览真实域名,并提供 CloudBase MCP 工具集(`mcp__cloudbase__*`),登录走 device-code 流程。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。