前言¶
DeepSeek Harness(DSH)里不少配置习惯写在 $DSH_HOME/.env,改完往往还要自己重启进程、或在 Windows / macOS 上再改一遍用户环境变量,终端里才一致。手工编辑文件、对照 process.env 和系统设置,步骤分散,也容易漏改。下面介绍社区插件 dsh-custom-env(维护者 ownduck,分类 admin-security):在 Settings → Environment 里对 .env 做增删改,保存后立刻作用到当前 Host,并在 Windows / macOS 上同步到用户级环境(新开终端生效);Linux 不支持向 OS 用户环境同步,但仍可管理文件并热更新 Host。
这是什么¶
dsh-custom-env 是社区 DSH 插件,不是 DeepSeek 官方产品。npm 包名为 @woosau/dsh-custom-env,源码仓库 ownduck/dsh-custom-env,许可证 MIT。它解决的核心问题是:把 $DSH_HOME/.env 的维护收拢到设置页,并与当前 Host 的 process.env、以及 Windows / macOS 的用户环境变量对齐(在插件支持范围内)。
核心功能¶
资料中明确列出的能力如下。
- Settings 页 CRUD:在 Settings → Environment 编辑
$DSH_HOME/.env;文件不存在时会创建。 - 热应用:点击 Confirm 写入
.env后,值立即应用到当前 Host 的process.env。 - OS 同步:Confirm 后同步到 Windows / macOS 用户环境;新开终端才能看到 OS 侧变化。Linux 不支持用户环境同步。
- 引导变量拦截:拒绝写入 bootstrap 名(如
PATH、DSH_*、XDG_*等),与 harness 从.env加载引导变量的规则一致;不宜把PATH等放进.env,普通应用配置名更合适。名称含KEY/SECRET/TOKEN的项仍按既有 harness 策略对模型可见 shell 做脱敏。 - dsh command 面板:展示用户 PATH 上的
dsh与启动本 Host 的 launcher 是否一致;不一致时出现 Install(Windows 写用户Path;macOS 写/usr/local/bin/dsh符号链接)。Linux 仅展示状态,无 Install。无卸载按钮。
依赖原生模块 koffi;从 GitHub 安装时,profile 的 pnpm-workspace.yaml 里可能需要 allowBuilds.koffi: true 后重试 add;npm 安装通常带预编译二进制,可跳过该步。引擎要求:dsh >= 0.2.0,Node ^22.19.0 || >= 24.0.0。
安装与启用¶
安装前需已有可用的 DSH,且 dsh 在 PATH 上(CLI 或 Desktop 捆绑 CLI)。按使用方式选 profile:desktop(Electron)或 web(浏览器 UI)。Desktop 若因 profile 的 package.json 出现 EPERM,需先关闭 Desktop / VertaxWork 再执行 plugin add。
Desktop(推荐)
dsh plugin --profile desktop add @woosau/dsh-custom-env
从 GitHub 安装:
dsh plugin --profile desktop add github:ownduck/dsh-custom-env
安装后重启 Desktop,打开 Settings → Environment。
Web
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
dsh plugin --profile web add @woosau/dsh-custom-env
dsh --profile web --dump-config
GitHub:
dsh plugin --profile web add github:ownduck/dsh-custom-env
dump-config 输出中应出现 # == dsh-custom-env / @woosau/dsh-custom-env 层及 custom-env 插件行。重启 DSH Web 并对浏览器硬刷新。
卸载 / 重装
dsh plugin --profile desktop remove @woosau/dsh-custom-env
dsh plugin --profile desktop add @woosau/dsh-custom-env
(Web 将 --profile desktop 换成 --profile web。)
社区插件也可在 SkillHub 目录页 查看条目;目录站与 DeepSeek / 幻方无官方从属关系,安装命令仍以仓库 README 为准。
典型用法¶
- 打开 Settings → Environment。
- 在页面上以 draft 方式编辑:Confirm 会写入
$DSH_HOME/.env并更新 Host / OS(Windows、macOS);Cancel 只撤销输入、不写盘。 - Confirm 后,各行可能显示重启提示——新增项会标为 added;相对 Host 启动时已修改的项还提供 Restore(写回 Host 启动时的值)。
- 若要 OS 侧完全生效,需重启 DSH 或新开终端;Host 重启后提示与 Restore 会清除。
- 在 dsh command 区域对比 PATH 与预期;仅在出现 Install 时再点击。Install 后需新开终端;插件不会调用 Desktop 的
app.relaunch。
Windows 上 Install 会把预期 bin 目录 prepend 到用户 Path(注册表),所有权键为 Software\dsh-custom-env\Command。macOS 上 Install 会写 /usr/local/bin/dsh → 预期 launcher,可能与 Desktop「Manage dsh Command…」共用同一路径。Linux 仅状态展示。
适用场景与注意¶
适合需要在 DSH 图形设置里统一管理 .env、并希望 Confirm 后立即影响当前 Host、且在 Windows / macOS 上顺带更新用户环境变量的开发者。若你主要在 Linux 上只靠 .env + Host 热应用、不依赖 OS 用户环境同步,插件仍可用,但不要期待 Linux 上的 Install / OS sync。
社区插件以当前 dsh Host 进程权限运行,会读写 $DSH_HOME/.env 并在 Windows / macOS 上改用户环境或注册表;安装前应阅读 源码与 LICENSE,确认符合本机安全策略。DSH 生态强调「一切皆插件」;选用第三方插件时自行评估维护者与更新频率(仓库星标等以 GitHub 页面为准)。
结尾¶
dsh-custom-env 把 $DSH_HOME/.env 放进 Settings → Environment,保存即写盘、热更新 Host,并在 Windows / macOS 同步用户环境,同时提供 dsh 命令路径对比与有条件的一键 Install。条目见 SkillHub:ownduck/dsh-custom-env,细节与更新以 GitHub:ownduck/dsh-custom-env 为准。