前言¶
DeepSeek Harness (DSH) 采用插件化架构,模型在执行任务时默认使用 bash 或 PowerShell。dsh-nushell-only 是一个 Profile Bundle,它通过接管 DSH 的 Shell 执行层,将所有 Shell 执行强制转换为 Nushell,并配合提示词教学,防止模型输出 Bash 或 PowerShell 语法。
功能介绍¶
此插件主要包含四个层面的修改:
-
接管执行层
插件禁用 DSH 内置的bash-sandbox和pwsh-sandbox,替换为自定义的dsh-nushell-only/executor。所有通过ctx.shell的调用(包括模型工具、后台任务、Hook 桥接等)都会变成nu --no-config-file -c "<command>"。参数配置(如超时、输出上限、spill 文件)沿袭第一方实现,仅替换了执行命令。 -
强制守卫
执行器内置守卫机制,拒绝模型切换到其他 Shell(如bash -c、sh -c、cmd /c、pwsh -Command、wsl等)。默认开启此功能,可通过配置项关闭或设置白名单。 -
教学层
提供nushell-rules和nushell-guide。插件会将模型看到的工具描述和command参数说明改写成 Nushell 方言,并附带语法手册和 Bash/PowerShell 对照表,每次装配时会带上探测到的 Nushell 版本号。 -
方言预检与纠错
在执行前拦截常见的 Bash/PowerShell 习惯(如2>&1、2>$null、$env:VAR、Get-Content、foreach等),给出具体的 Nushell 写法建议。执行失败时,会根据 Nushell 的实际错误码追加提示。
安装与启用¶
执行以下命令安装插件:
dsh plugin --profile web add dsh-nushell-only
安装完成后,重启该 Profile。
配置与验证¶
若 Profile 中已存在旧的 dsh-nushell 插件,必须先卸载以避免冲突:
dsh plugin --profile web remove dsh-nushell
安装后,可以通过以下命令验证配置是否生效:
dsh --profile web --dump-config | grep -n "nushell"
配置选项包括:
- enforceNushellOnly: false:关闭强制守卫。
- foreignShellAllowlist:设置允许调用其他 Shell 的白名单。
注意事项¶
- 版本适配:插件适配 DSH
0.2.0-rc.2。 - 运行时要求:Node.js 版本需满足
>=22.19.0。 - 依赖关系:安装器会按
peerDependencies校验运行时版本,不匹配时会拒绝安装。
结语¶
dsh-nushell-only 适合希望统一 Shell 生态或从零开始培养模型 Nushell 习惯的开发者。通过接管执行层和提示词层,它强制模型使用 Nushell,减少了环境差异带来的错误。
目录页:dsh-nushell-only - SkillHub
源码:YMRwithNoworry/dsh-nushell-only - GitHub