Momojie-S/dsh-workspace-env

Plugin插件 Native原生 ⭐ 2 MIT Dev Workflow开发与代码工作流

DSH插件:为shell子进程提供按工作区注入.env文件的功能

Project Overview项目介绍

This repository hosts a native DeepSeek Harness (DSH) plugin that adds workspace-level environment variable injection for PowerShell tool calls in DSH. It is packaged as a DSH bundle with a valid DSH manifest, and can be installed directly via DSH's built-in plugin manager. Every time a pwsh command is invoked via DSH's shell service, the plugin automatically reads the .env file from the current workspace root and injects its key-value pairs into the child process environment. This enables automatic environment switching when switching between projects, with no extra configuration or changes required from the DSH agent.

The plugin follows standard .env file conventions, so you can write comments starting with #, leave empty lines, and use variable references like ${PATH} to expand existing environment values. Keys starting with the DSH_* prefix are automatically ignored to avoid conflicting with DSH's internal managed variables. Workspace .env variables take highest priority over system environment variables and any DSH-injected variables of the same name, except for the ignored DSH_* variables. Changes to the .env file take effect immediately after saving, because the file is re-read on every command invocation, so you do not need to restart DSH to apply updates.

The plugin has a minimum DSH version requirement of 0.1.0-rc.6, and has been tested and confirmed working up to DSH version 0.1.5-rc.1. It only supports Windows PowerShell at this time, and does not cover bash-based command execution paths. It is released under the open source MIT license, and can be installed by running the dsh plugin --profile web add github:Momojie-S/dsh-workspace-env command in your terminal. After installation completes, you will need to restart DSH for the plugin to take effect. You can verify the installation by running dsh web --dump-config | Select-String workspace-env to check that the plugin configuration layer is loaded correctly.

这是一款针对DSH开发的原生组合插件,作用是在调用pwsh工具时,自动将当前工作区根目录下 .env 文件中定义的环境变量注入到子进程中,实现了工作区级别的环境变量隔离,切换项目时会自动切换对应环境,整个过程对DSH agent完全透明无感知。该插件支持变量展开、同名覆盖、注释跳过等常见.env特性,安装完成后即可直接使用。

开发者只需要在当前工作会话的根目录放置符合规范的 .env 文件,就可以让所有 pwsh 调用自动读取该文件中的配置。每次调用命令都会重新读取文件,修改配置后无需重启 DSH 即可立即生效。对于需要不同环境变量配置的多项目开发场景,这款插件可以有效避免不同项目之间环境变量互相干扰,降低环境配置的管理成本。

该插件要求 DSH 版本不低于 0.1.0-rc.6,目前已验证兼容至 0.1.5-rc.1,仅支持 Windows 平台的 PowerShell,暂未覆盖 bash 环境。项目采用 MIT 许可证开源,可通过 dsh plugin 命令直接从 GitHub 源码或压缩包安装,安装完成后重启 DSH 即可生效。开发者也可通过源码直连的方式进行本地开发调试。

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 momojie-s-dsh-workspace-env-0.1.0.tgz

把 Momojie-S/dsh-workspace-env 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-workspace-env

npm 包名:@momojie-s/dsh-workspace-env

DSH 插件:pwsh 工具每次调用时,自动把当前 workspace 目录下的 .env 注入子进程环境变量——workspace 级环境变量隔离,切项目自动切 env,agent 无感知。

环境要求

  • DSH >= 0.1.0-rc.6(已验证至 0.1.5-rc.1:.env 注入实测正常。依赖 shell 服务的 spawnSpec 内部方法,升级 DSH 后建议重跑验证)
  • Windows pwsh(bash 链路未覆盖)

用法

workspace 根目录(session cwd)放一个 .env:

GH_TOKEN=gho_xxx
QUOTED="value with spaces"   # 成对单/双引号自动去除
PATH=D:\mytools;${PATH}      # ${VAR} 引用父环境,PATH 前置追加
# # 开头是注释;空行、无 = 的行跳过
  • .env 每次命令调用现读,改完立即生效,无需重启
  • DSH_* 前缀的 key 一律忽略(DSH 管理变量有自己的通道)
  • 同 key 覆盖:workspace .env 优先级最高,赢过系统环境变量、DSH 注入的一切同名变量(DSH_* 除外)
  • ${VAR} 引用:展开自父环境(系统变量 + DSH 注入)+ 同文件中更早定义的变量;未定义展开为空串。覆盖是整体替换,要追加就用引用:PATH=D:\tools;${PATH}

安装

本插件是组合包(dsh.bundle),用 dsh plugin 安装进 profile,自动追加配置层,无需手编 patch:

# GitHub(私仓需 git 凭据;pnpm ≥10 首次 add 会提示授权构建,按提示把包键
# 写进 ~/.dsh/profiles/web/pnpm-workspace.yaml 的 allowBuilds 后重新 add)
dsh plugin --profile web add github:Momojie-S/dsh-workspace-env

# 或 tarball(pnpm pack 产物,无授权要求)
dsh plugin --profile web add momojie-s-dsh-workspace-env-0.1.0.tgz

验证层就位后重启 DSH:

dsh web --dump-config | Select-String workspace-env   # 应看到 "# == dsh-workspace-env" 层
开发模式:源码直连(改代码 → 重启验证)

编译 npm install && npm run build,profile 的 cordis.patch.yml 手动加行(name 用 file:/// URL 指向 lib/index.js):

- insert:
    - id: workspace-env
      name: file:///D:/code/workspace/deepseek-harness-101/plugins/dsh-workspace-env/lib/index.js
      disabled: !!js process.platform !== 'win32'

独立追加行,不替换 pwsh-sandbox——文件沙箱能力完整保留(patch 也禁止 id override 改 name)。

配置

无。

验证

workspace 放 .env 写 WS_ENV_TEST=hello,让 agent 跑:

pwsh: echo $env:WS_ENV_TEST

输出 hello 即生效;切到无 .env 的目录同命令输出空,即隔离生效。


设计文档见 docs/design/overview.md;跨插件开发方法论见合集仓库 docs/development-guide/dsh-plugin-development.md。

← 上一个 Prev dsh-pet-shura 下一个 Next dsh-openai-codex →