Preface¶
When running shell commands in DeepSeek Harness (DSH), child processes inherit the host process’s environment by default and do not automatically execute .envrc in the project root directory. If you use direnv locally to manage variables like API_BASE and toolchain paths, commands executed by the agent often miss this environment, leading to misdiagnosis as code or script issues during troubleshooting. dsh-direnv resolves direnv based on the “session workspace” on the DSH side, merges the results of direnv export json into the environment variables of every command, and routes through the DSH approval channel when .envrc is unapproved, rather than exposing unauthorized content to the model.
The following introduces the plugin’s positioning, capabilities, and installation configuration. Facts are subject to the GitHub Repository README.
What is this¶
dsh-direnv (npm package name @snylonue/dsh-direnv) is published by maintainer snylonue, categorized as a client plugin, with the summary “direnv support for DeepSeek Harness”. The current package version is 0.4.0, licensed under MIT.
The plugin only supports DSH 0.2.1-rc.2; earlier host version ranges have been removed. Development and integration testing target this host version. The direnv snapshot is bound to the workspace at session creation time and does not switch with subsequent working_directory changes or the cwd of individual commands; reloads and approvals always target this fixed workspace.
Core Features¶
Environment Injection¶
| Behavior | Description |
|---|---|
| Injection | Merges the result of direnv export json on the workspace into child process environment variables |
| Scope | The workspace is fixed by the calling agent’s session cwd |
| Session Start Prompt | Injects a snapshot into the model at session start: explains whether workspace direnv is active and which variable names are injected (values are not shown); workspaces without .envrc remain silent |
| Load after Approval | direnv_allow is executed via the DSH approval channel, followed by direnv allow only after approval |
Only the resolved environment is read during command execution; if direnv resolution fails during the startup phase, the error is logged, but does not prevent session start.
Model Context at Session Start¶
Upon session creation, the plugin resolves the workspace once and queues a model-facing context via agent/created and agent.inject() before the first turn. The model knows the direnv status without needing to run a command first. Example when active (from README):
[dsh-direnv] The workspace direnv environment is active.
[dsh-direnv] /home/me/proj/.envrc injects 3 variable(s) into every command the agent runs:
[dsh-direnv] API_BASE, PROJECT_TOOLCHAIN, RUST_LOG
[dsh-direnv] Values are applied to each command's environment and are deliberately not shown here.
Workspaces that are blocked, denied, or failed will use actionable text consistent with the command side, facilitating direct model calls to direnv_allow. A new message is sent after compact or resume. Session creation waits for this resolution to complete before entering the first turn; setting sessionContext to false turns off this message, but the workspace is still resolved.
Behavior with Unapproved .envrc¶
An unapproved .envrc does not cause command failure, nor does it leak file content; commands run without the direnv environment. If notifyOnBlocked: true is configured, a prompt is appended to the command result’s stderr, for example:
[dsh-direnv] This command ran WITHOUT the workspace direnv environment.
[dsh-direnv] /home/me/proj/.envrc is not approved, so native direnv refused to load it.
[dsh-direnv] Call the direnv_allow tool to ask the user to approve this workspace:
[dsh-direnv] direnv_allow
[dsh-direnv] Workspace: /home/me/proj
The model can call direnv_allow (with an optional reason) to allow the user to approve the current session workspace; the host runs direnv allow in the workspace without reading or previewing the .envrc content.
Explicit Reload¶
At startup, direnv status --json and direnv export json are run on the fixed workspace and the results are awaited. After environment changes, an explicit reload via a model-facing tool is required:
direnv_reload # reload the calling session workspace
Installation and Activation¶
The DSH ecosystem follows the “everything is a plugin” approach; the community directory is on SkillHub. It has no official affiliation with DeepSeek / High-Flyer; please check the source code and license yourself before installing.
-
Confirm that direnv is installed on the local machine and that the DSH version is 0.2.1-rc.2.
-
Install from npm using the web profile (command from README):
dsh plugin --profile web add @snylonue/dsh-direnv
- Restart DSH after installation for the plugin to take effect.
Uninstall:
dsh plugin --profile web remove @snylonue/dsh-direnv
Configuration¶
Add or adjust the following fragment in the Cordis plugin line (disabled: true is written outside the plugin line, not within config, used to disable the provider and its dependent adapters and tools):
- id: direnv
name: dsh-direnv
config:
executable: direnv # bare PATH name or absolute path
probeTimeoutMs: 10000 # budget for one direnv run
notifyOnBlocked: false # opt in to append actionable notices to results
sessionContext: true # inject the workspace's direnv variables at session start
| Field | Default Value | Meaning |
|---|---|---|
executable |
direnv |
The direnv executable; must be in PATH or an absolute path |
probeTimeoutMs |
10000 |
Timeout limit (milliseconds) for a single direnv status --json or direnv export json |
notifyOnBlocked |
false |
When true, appends actionable prompts to command result stderr |
sessionContext |
true |
When true, injects workspace direnv variable names or failure reasons at session start |
Typical Usage¶
-
Place
.envrcin the project root and complete editing using direnv locally first; open a session in DSH with that directory as the session cwd. -
If the session start context or
notifyOnBlockedprompt indicates unapproved status, the model callsdirenv_allow, and the user confirms via the DSH approval channel; the host executesdirenv allowin the workspace. -
After modifying
.envrcor direnv status, calldirenv_reloadto re-resolve the current session workspace and update the injected environment.
Use Cases and Notes¶
Suitable for developers who already use direnv in their repositories and want the shell commands executed by the DSH agent to share the same set of workspace variables as the local terminal.
Please confirm before use: the executable points to an available direnv; the probe timeout can be adjusted via probeTimeoutMs. The plugin runs direnv and child processes with the current DSH process privileges; please read the GitHub Source Code and the MIT license before installation and activation. The icon uses the direnv logo (Peter Waller, CC BY 4.0).
Conclusion¶
dsh-direnv aligns the session workspace with direnv: it informs the model of variable names at startup, injects the environment on the command side, and routes through user approval when unapproved without leaking .envrc content. Directory page: SkillHub - dsh-direnv; Source code and full documentation: github.com/snylonue/dsh-direnv.