DeepSeek Harness 插件

powershell-fix

DeepSeek Harness (DSH) host-layer plugin: detects and auto-fixes Windows PowerShell command syntax mistakes — bash constructs, broken line continuations, pasted prompts, CRLF pollution — then(英文原文)

跳到安装方式

来源信息

GitHub 仓库
GuTianshuo/powershell-fix
最近更新
2026年8月19日
分类
工具与能力
GitHub stars
1
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/GuTianshuo/powershell-fix
插件名:powershell-fix
作者:GuTianshuo

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

powershell-fix

A host-layer plugin for DeepSeek Harness (DSH) that detects and auto-fixes Windows PowerShell command syntax mistakes before they burn a tool-call round-trip — then executes the corrected command through the host shell seam, under the normal sandbox/approval policy.

AI agents (and humans) frequently paste bash-flavored commands into a Windows terminal. This plugin gives the agent one tool — powershell_fix — that checks, repairs, and runs such commands safely.

What it fixes

Line hygiene (the most frequent real-world breakage)

problemfix
CRLF / stray \r from copy-pastenormalized to LF
pasted shell prompts (PS C:\> , C:\> , $ on every line)stripped
trailing whitespace after a continuation char (invisible breakage)removed
bash \ line continuationPowerShell backtick
missing continuation before a -Parameter linebacktick inserted
dangling backtick before an empty lineremoved
unbalanced quoteswarned (never blindly rewritten)

bash → PowerShell semantics

| bash | PowerShell | |---|---| | export NAME=value | $env:NAME='value' (same-command $NAME refs rewritten to $env:NAME) | | unset NAME | if (Test-Path Env:NAME) { Remove-Item Env:NAME } (guarded; inline-in-chain supported) | | > /dev/null, 2> /dev/null, &> /dev/null | > $null, 2> $null, *> $null | | a && b / a || b | kept on PowerShell 7+; split into if ($?) { … } on Windows PowerShell 5.1 (engine auto-detected) | | ls -la path | Get-ChildItem path -Force | | rm -rf x | Remove-Item x -Recurse -Force | | mkdir -p a/b/c | New-Item -ItemType Directory -Force … | | touch f | timestamp update or New-Item -ItemType File | | grep [-r] [-v] pat f… | Select-String (recursion via Get-ChildItem -Recurse) | | which x / command -v x | (Get-Command x -ErrorAction SilentlyContinue).Source | | head -n N f / tail -n N f / tail -f f | Get-Content -TotalCount N / -Tail N / -Wait | | sed, awk, chmod, bare $PATH-style env refs | warned with PowerShell equivalents (never blindly rewritten) |

Correct PowerShell passes through unchanged (no-op guarantee, covered by regression tests). The fixer is idempotent: fix(fix(x)) === fix(x).

Safety

  • Execution goes through the host ctx.shell seam — the same sandbox, approval, and timeout policy as the built-in pwsh tool. This plugin adds no privilege.
  • A built-in execution gate refuses to auto-execute semantically destructive commands even after fixing them: root-target recursive deletes (rm -rf /, Remove-Item C:\ -Recurse), Format-Volume, Clear-Disk, Set-ExecutionPolicy, del /s|/q, and environment/system persistence writes (setx, [Environment]::Set*, New-ItemProperty, Set-ItemProperty, reg add).
  • execute: false (or autoExecute: false config) gives a dry-run: fix only, no execution.

Install (host layer — available to every session)

The package declares dsh.bundle.patch, so installing it into a profile adds it to the profile's layer stack automatically — no agent-preset line needed:

dsh plugin --profile web add file:/path/to/powershell-fix

Reconciling notices the dsh.bundle declaration and appends powershell-fix to dsh.profile.bundles; the bundled cordis.patch.yml inserts the plugin row at the host layer. Restart the harness, and every session on that profile gets:

  • tool powershell_fix
  • a system-prompt section teaching native PowerShell syntax and when to call the tool

> Note: pnpm file: dependencies copy lib/*.js — after editing the source, delete node_modules/powershell-fix in the profile and re-run the add command ("Already up to date" is misleading).

Tool contract

// powershell_fix({ command, shell?, execute?, description? })
{
  "ok": true,
  "platform": "win32",
  "shell": "powershell51",          // auto-detected engine: pwsh | powershell51
  "original": "export A=1 && echo $A",
  "fixed": "$env:A='1'; if ($?) { echo $env:A }",
  "changed": true,
  "fixes": [{ "rule": "ENV_EXPORT", "notes": ["…"] }],
  "warnings": [{ "rule": "BARE_VAR", "note": "…" }],
  "execution": { "mode": "auto", "exitCode": 0, "stdout": "…", "stderr": "…" }
  // execution.mode: auto | dry-run | skipped-dangerous | aborted
}

Config (cordis row / dsh.bundle defaults): autoExecute (default true), timeoutMs (default 60000).

Development

Zero runtime dependencies (engine is pure JS); peer deps @deepseek-ai/dsh-tools and @deepseek-ai/schemastery resolve from the host.

node --test                          # unit tests (engine, 57 assertions)
node acceptance/mount_check.mjs <profile_web_dir>   # mount + live-path check
node acceptance/real_pwsh_e2e.mjs    # fixed commands executed by the real engine

中文说明

DSH host 层插件:在 Windows 终端上自动检测并修复 PowerShell 命令语法错误(bash 语法、续行符错误、粘贴带入的提示符与 CRLF),修复后经宿主 shell 缝隙执行——沙箱/审批策略与内置 pwsh 工具完全一致,危险命令只修复不执行。声明 dsh.bundle.patch,装入 profile 即对所有会话生效,无需改任何 preset。

License

MIT