
Momojie-S/dsh-workspace-env
30Last commit Aug 14, 2026
dsh-workspace-env DSH plugin
dsh-workspace-env is a DSH plugin that reads a `.env` file from the workspace root and injects its variables into every `pwsh` tool call. Environment changes take effect immediately without restarting the agent. It supports variable references (`${VAR}`), ignores `DSH_*` prefixed keys, and gives workspace `.env` top priority over system and injected variables.
How to install the dsh-workspace-env DSH plugin
dsh plugin --profile web add github:Momojie-S/dsh-workspace-envCopying does not run this command. Review the repository and version before installing the dsh-workspace-env DSH plugin.
dsh-workspace-env DSH plugin data source
dsh-workspace-env DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-workspace-env DSH plugin can do
- Reads `.env` file from workspace root on each command invocation
- Supports `${VAR}` references to parent environment and earlier definitions in the same file
- Ignores keys with `DSH_*` prefix to avoid conflict with DSH managed variables
- Workspace `.env` keys override system and DSH injected variables of the same name
- Strips surrounding single/double quotes from values automatically
- Supports comments (lines starting with `#`) and blank lines
Where the dsh-workspace-env DSH plugin fits
- Isolate API tokens per project without leaking to other workspaces
- Switch environments automatically when changing workspace directory
- Inject custom PATH or other variables without modifying global system settings
- Debug quickly by editing the `.env` file and instantly seeing changes in the next tool call
Who the dsh-workspace-env DSH plugin is for
- DSH users who run `pwsh` tools and need per-workspace environment isolation
- Developers managing multiple projects with different environment configurations
dsh-workspace-env DSH plugin limitations
- Only supports Windows PowerShell (pwsh); bash workflow is not covered
- Requires DSH `0.1.0-rc.6` or compatible (depends on `spawnSpec` internal method of shell service)
- Must be installed in a profile that uses `pwsh-sandbox`; file sandboxing capability is preserved via patch
dsh-workspace-env DSH plugin: from the repository README
Quoted from the Momojie-S/dsh-workspace-env README, the upstream source of the dsh-workspace-env DSH plugin. Copyright remains with the original authors.
> npm 包名:`@momojie-s/dsh-workspace-env` DSH 插件:`pwsh` 工具每次调用时,自动把当前 workspace 目录下的 `.env` 注入子进程环境变量——workspace 级环境变量隔离,切项目自动切 env,agent 无感知。 ## 环境要求 - DSH `0.1.0-rc.6`(已验证。依赖 shell 服务的 `spawnSpec` 内部方法,升级 DSH 后建议重跑验证) - Windows pwsh(bash 链路未覆盖) ## 用法 workspace 根目录(session cwd)放一个 `.env`: ```bash 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: ```bash # 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: ```bash dsh web --dump-config | Select-String workspace-env # 应看到 "# == dsh-workspace-env" 层 ``` <details><summa
Read the full READMERepository license: MIT
dsh-workspace-env DSH plugin questions
How do I install dsh-workspace-env?
You can install it via `dsh plugin --profile web add github:Momojie-S/dsh-workspace-env`. If the repository is private, you need git credentials. Alternatively, use a tarball from `pnpm pack` with `dsh plugin --profile web add <tarball>`. After installation, restart DSH and verify with `dsh web --dump-config | Select-String workspace-env` to see the configuration layer.
Does it work on Linux or macOS?
No, dsh-workspace-env currently only supports Windows pwsh. The README explicitly states that bash workflow is not covered. If you use Linux or macOS, you may need to look for alternative approaches.
How do I configure the .env file?
Place a `.env` file in the workspace root directory (the session cwd). The format is simple: each line contains KEY=VALUE. You can use quotes around values (they will be stripped), comment lines starting with `#`, and reference other variables with `${VAR}`. For example: `GH_TOKEN=gho_xxx` or `PATH=D:\mytools;${PATH}`.
Can I change the .env file and see the changes immediately?
Yes. The plugin reads the `.env` file on every command invocation, so you can edit the file and the next `pwsh` command will use the new values. No need to restart the agent or reload the workspace.
What if I have a variable with the same name in both system environment and workspace .env?
The workspace `.env` value takes highest priority. It overrides system environment variables and any DSH-injected variables (except those with `DSH_*` prefix, which are ignored entirely). If you want to append instead of override, use reference syntax: `PATH=extra;${PATH}`.