xiayuhkust/dsh-toolbelt--packages-script-exec ↗★ 0
dsh-plugin-script-exec
run_script tool for DeepSeek Harness: write multi-line scripts to a temp file and execute, avoiding Windows inline-quoting pitfalls.
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗dsh-plugin-script-exec
给 DeepSeek Harness 增加 run_script 工具:脚本先写入临时文件再执行(pwsh / python / node),执行后删除。
背景:Windows 上内联传递多行脚本(pwsh -Command、python -c)在含引号、中文时频繁因转义失败报错,agent 往往要试错多次。落盘执行从根上绕开转义问题。ps1 文件写入时附带 UTF-8 BOM(PowerShell 5.1 对无 BOM UTF-8 按 ANSI 解码)。
执行走 ctx.subprocess,与内置 pwsh 工具同一沙箱与审批策略,不新增权限面。
安装
dsh plugin --profile web add dsh-plugin-script-exec
cordis.patch.yml:
- id: script-exec
name: dsh-plugin-script-exec
config:
timeoutMs: 120000
maxOutputChars: 30000
状态
v0.1,已实测。
实测记录(2026-08-15,dsh 0.1.0-rc.6 / deepseek-v4-flash / Windows 11):
- headless 会话中执行含中文与嵌套引号的 pwsh 脚本
Write-Output '中文测试:他说"你好"'; Write-Output (1+1),run_script 正确回传 stdout(中文与引号完整保留、1+1=2),退出码 0; - python / node 分支同样跑通。
实现注记:
- 本插件零 dsh import。dsh 0.1.0-rc.6 的加载器不为第三方插件的内部 import 解析 host 内部包(如 dsh-tools),故手工构造 ToolDefinition 对象而非 import defineTool;
- 执行走
ctx.shell.resolve→ctx.shell.run;其 stdout/stderr 是CollectedOutput对象({text, truncated, spillPath?}),需取.text(联调时踩过[object Object]坑,已修)。
已知待改进:不拦截脚本正文内的间接文件读取(如 python open() 读敏感文件),需与 secret-guard v0.2 的脚本正文扫描协同。