鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

dsh-safe-delete

工具守卫将 agent 执行的 rm 目标移入 macOS 废纸篓而非直接删除,shell 感知词法器覆盖复合与伪装命令;设置页通用设置中可随时关闭。

安全权限
访问 GitHub
文档README

dsh-safe-delete

Every rm an agent runs becomes a recoverable move to the macOS Trash.





One global guard on the tools registry — ctx.tools.guard() —— no tool, prompt, or core changes

A DeepSeek Harness host-side plugin that makes agent-issued rm commands recoverable: targets are moved to the macOS Trash instead of deleted, across GUI sessions, automation runs, headless bridges, and subagents. One switch in Settings → General turns it off — disabled, commands run with native DSH behavior.

Capabilities

  • Recoverable deletion — an rm in command position is denied and rewritten to /usr/bin/trash -v; the model receives a report of exactly what was moved, so nothing silently disappears.
  • Every session, one guard — registers once on the DSH tools registry; GUI chats, scheduled automations, headless bridges, and subagents are all covered with zero per-session wiring.
  • Shell-aware interception — quote-preserving lexer catches sudo rm, /bin/rm, env/nice-prefixed rm, VAR=x rm, and xargs rm inside compound commands (&&, ||, ;, |).
  • Fail-safe by design — constructs that could hide an rm ($(...), backticks, subshells, heredocs, eval, nested sh -c) are denied with guidance instead of rewritten; a failed trash is reported, never retried as real deletion.
  • Runtime switch — toggle in the web GUI (Settings → General → Safe Delete) or via POST /safe-delete/config; the state persists across restarts in $DSH_HOME/storages/safe-delete.json.

How it works

The plugin installs one guard on the DSH tools registry. Every bash tool call is scanned before execution:

▼
mermaid
复制代码
flowchart LR A["bash tool call"] --> B{"rm in command<br/>position?"} B -- "no" --> C["native execution"] B -- "yes" --> D{"switch on?"} D -- "off" --> C D -- "on" --> E{"safely<br/>rewritable?"} E -- "no: subshell, eval,<br/>heredoc, backticks" --> F["deny with guidance,<br/>nothing runs"] E -- "yes" --> G["run trash -v, deny the<br/>original, report targets"]

Intercepted calls are denied and re-executed as trash by the guard itself, so quoting and globs survive:

▼
text
复制代码
[dsh-safe-delete] intercepted `rm` — the targets were MOVED TO TRASH (recoverable), not deleted. Original command denied. Targets: build/ dist trash: build/ → .Trash/build/

Plain non-rm commands pass through untouched; commands that merely mention rm (echo rm, grep "rm " log) are ignored. rm flags (-f, -r, …) are stripped rather than honored: trash moves whole directories natively.

Scope and limits

CoveredNot covered
Commandsrm, sudo rm, absolute-path rm, xargs rm — simple and compoundfind -delete, unlink, git clean, language runtimes' own file APIs
Guaranteeintercepted at the guard layer, before executionthe guard is an accident-prevention net for the most common destructive verb, not a sandbox

sudo rm is intercepted before sudo ever runs, but trashing files that require root can still fail — trash errors are reported verbatim.

Install

▼
bash
复制代码
dsh plugin --profile web add github:NattoCB/dsh-safe-delete

Restart the DSH web process — host-side bundles and their patches load at process start. On boot the plugin logs rm guard active once.

Configuration

SurfaceHow
Web GUISettings → General → Safe Delete — the switch takes effect on the next bash call, no reload
HTTPGET /safe-delete/config → { "enabled": bool }; POST /safe-delete/config with { "enabled": bool }
File$DSH_HOME/storages/safe-delete.json — { "enabled": bool }

Default: enabled. A missing or corrupt state file also resolves to enabled — installing the plugin expresses the intent to have the guard, and a corrupt file never silently downgrades protection.

Development

▼
bash
复制代码
npm test # node --test: lexer, rewrite matrix, guard contract, switch store/API

The lexer/rewriter is exported as exports._internals so tests exercise the real code paths (analyzeCommand, tokenize, splitSegments, makeGuard, ConfigStore, handleConfigRequest).

License

MIT — part of the awesome-dsh-plugin ecosystem.

安全权限

快捷安装

复制到终端去安装插件

dshplugin--profilewebaddgithub:NattoCB/dsh-safe-delete

温馨提示

装插件等于在本机跑第三方代码,权限与你相同,能读文件、用凭据、访问网络,工具审批管不到。请只装可信来源,并尽量锁定 commit。

站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
零感AI零感AI
墨得问题墨得问题
dsh 插件推荐
cc-safety-net
执行前守卫,在工具调用运行前拦截破坏性 Git 与文件系统命令,以及对 SSH 密钥、.env 等机密文件的访问。
dsh-workspace-write-plus
增加工作区修改++权限档,文件工具仍锁在工作区,可用通配符放行 Git Bash 等程序以跳过 Windows 进程沙箱。
user-management
用户管理:给 dsh web 加登录门禁,未登录访问弹登录/注册页,首个注册者自动成为管理员;管理员可管理用户/角色,带登录与访问审计。
dsh-security-guard
DSH 插件安全卫士:28 条规则静态扫描、风险评分、白名单/黑名单、本地 Web 仪表盘与 DSH 内风险弹窗。
dsh-route-fence-linter
审计 profile 内所有插件 HTTP 路由的浏览器信任围栏:插件路由在 Web 服务器的最长前缀匹配中优先,因此缺少围栏的路由会被静默暴露;逐条给出文件与行号级别的证据。