Introduction¶
When using DSH (DeepSeek Harness) in Windows environments, models often get stuck on quote escaping when writing PowerShell commands. Paths containing spaces, Chinese characters, special symbols (such as $, %), or nested quotes can easily cause command execution to fail or produce unexpected behavior. The dsh-pwsh-quoting-guard plugin introduces a structured data-passing mechanism to remove the escaping burden from the “command string” layer, ensuring data is passed accurately.
Plugin Overview¶
Name: dsh-pwsh-quoting-guard
Maintainer: fengbai2233
Category: admin-security
License: MIT
This plugin provides two tools: pwsh_script and run_argv. They pass parameters through structured arrays to avoid complex quote escaping performed by the model, while pinning UTF-8 encoding to ensure stable behavior under executors such as Windows PowerShell 5.1.
Installation and Enablement¶
Use the following command to add the plugin to the specified profile:
dsh plugin --profile web add dsh-pwsh-quoting-guard
After installation, restart dsh web so the plugin combination takes effect.
Tool Description¶
The plugin provides two core tools for different scenarios.
pwsh_script¶
Passes data structurally through $DSH_ARGS, delivering the script body as a single element to avoid quote escaping.
* Parameters:
* script (string, required): PowerShell script body.
* args (string[]): Parameter list, bound sequentially starting at $DSH_ARGS[0].
* Features: Zero runtime dependencies, pins UTF-8 encoding, and supports the cwd parameter.
run_argv¶
Passes arguments directly as argv, completely bypassing shell parsing. It is suitable for executing native programs with faithful parameter preservation.
* Parameters:
* program (string, required): Executable file name or absolute path.
* args (string[]): Argument vector.
* cwd (string): Working directory; defaults to the session workspace.
Usage Examples¶
Example 1: Read a path containing special characters
{
"script": "(Get-Content -LiteralPath $DSH_ARGS[0] -Raw).Trim()",
"args": ["E:\\deepseekwork\\插件\\.dsh-tmp\\$100 %TEMP% it's dir\\sample file.txt"]
}
Example 2: Run node in a specified directory and preserve arguments faithfully
{
"program": "node",
"args": ["-e", "console.log(process.cwd(), process.argv.slice(1))", "a\\\"b'c"],
"cwd": "E:\\deepseekwork\\插件\\.dsh-tmp\\$100 %TEMP% it's dir"
}
Working Principle¶
- Structured isolation:
pwsh_scriptpasses the script body as a singleargvelement to PowerShell via-Command; data is delivered through the$DSH_ARGSarray, so the model does not need to worry about escaping. - Shell-free:
run_argvdirectly invokesctx.subprocess.spawn; arguments are not parsed or expanded by a shell, ensuring they are passed in their original form. - Environment alignment: Injects environment variables such as
NO_COLORandPAGER, and handles sandbox permissions to ensure output formatting remains consistent with standard tools.
Known Limitations¶
- No background tasks:
pwsh_scriptdoes not supportrun_in_background. For long-running tasks, use the officialpwshtool instead. - Line number offset: If an argument value contains newline characters, script line numbers may shift.
- Prompt segment uniqueness: Prompt segment names must be unique within the same layer to avoid plugin tree loading failure caused by duplicate names.
- Hard dependency: The
injectdeclaration is hard;['subprocess', 'tools']must be declared to access the related context.
Troubleshooting¶
- Tool not visible: Check whether
dsh webhas been restarted. - Startup failure: If the error says
cannot get property "tools" without inject, check whetherinjectis declared correctly. - Duplicate name error: Check whether the plugin is installed in both the profile and preset.
Conclusion¶
dsh-pwsh-quoting-guard solves the most troublesome escaping problem in PowerShell command-line argument passing on Windows through structured tool interfaces. For scenarios requiring complex path handling or native program execution, it significantly reduces retries and token waste caused by quoting errors.
- GitHub: https://github.com/fengbai2233/dsh-pwsh-quoting-guard
- Catalog: https://www.skillhub.cn/plugins/fengbai2233/dsh-pwsh-quoting-guard