dsh-ops-guard: Enforce aria2 for downloads and Everything for filename search at the pre-execute layer

Introduction

When running agents in DeepSeek Harness (DSH), there are two common types of rules that are “written in skills but not followed at runtime”: large file downloads should use the local aria2 engine, and file searches by path should use Everything instead of the built-in glob. Prompts are merely suggestions, and the model may still use curl -o, wget -O, or built-in glob, resulting in inferior speed and observability. Below is an introduction to the community plugin dsh-ops-guard (maintainer BeiWay1145, category admin-security), which transforms the above suggestions into runtime rulings on tools/pre-execute.

What is this

dsh-ops-guard is a DSH plugin that listens to the cordis tools/pre-execute hook (waterfall mode) to intercept and handle shell and glob executions before they actually run:

Guard Rule Alternative Channel
Download Guard Large file downloads must use aria2 Bundled script aria2-dl.cjs → aria2-next (Motrix Next)
Search Guard File searches by path must use Everything Everything resident IPC (\\.\PIPE\Everything IPC)

Both share the same interception point, but the handling after interception differs, which is the core of the plugin’s design:

  • Download Guard: Refuses execution and provides a copyable aria2 command in the rejection reason (downloads have side effects, so the guard cannot execute on behalf of the model).
  • Search Guard: Refuses execution of built-in glob, but directly returns the query results from Everything in the rejection reason (read-only query; the guard calculates via IPC within the DSH process and returns the result).

Repository: https://github.com/BeiWay1145/dsh-ops-guard
Community Directory Page: https://www.skillhub.cn/plugins/BeiWay1145/dsh-ops-guard

Why Runtime Guards are Needed

Downloads: Shell Commands and aria2 Scripts are Indistinguishable in Form

The README records that for the same ~4.76 GB image, the aria2-next channel measured approximately 11.78 MB/s, while the bypass channel using node single-connection https measured approximately 0.13 MB/s, with inconsistent resume capabilities as well. As long as the agent has download.cjs at hand, executing node download.cjs in the shell looks identical to using aria2-dl.js. There is no mechanism to distinguish them at the prompt level, so it is necessary to reject curl -o, wget -O, and similar disk-writing downloads at pre-execute.

Search: Built-in glob Works, but Models Have No Incentive to Switch to Everything

When the kernel glob is available, the model has no reason to actively use Everything. Rules must be enforced at runtime; the guard answers using the index when IPC is available. The cost is mainly IPC round-trips (the Everything process is already resident), rather than starting ripgrep/glob to traverse the directory tree every time. The data in bench/scope-latency.mjs from the README shows that under various search scopes, the guard has lower median latency compared to built-in glob (e.g., for the whole disk path D:\VibeCoding, the magnitude difference is recorded as approximately 68 times in the README). Everything is a filename index, not a content index; newly created files may have an indexing delay of about a few seconds, and content search needs to be explicitly enabled by the user—so the guard only intercepts glob, not grep.

Interception Rules and Allowed Boundaries

Cases that will be Intercepted

Rule Trigger Action
curl-output curl -o / -O Reject + aria2 command
wget-output wget -O Reject + aria2 command
invoke-webrequest-outfile Invoke-WebRequest -OutFile Reject + aria2 command
bits-transfer Start-BitsTransfer Reject + aria2 command
glob Built-in glob tool Reject + Actual search results

Examples that must be Allowed

  • curl https://api.x/data: Output to stdout, no disk writing.
  • Invoke-RestMethod and similar requests that do not write to disk.
  • Non-shell tools, grep (content search still uses built-in tools).
  • The rejection reason will explain that grep was not intercepted to prevent the model from taking a detour.

When the IPC or Everything is unavailable, the search guard will fallback to a “give command” mode (searchDenialMessage) to avoid rendering search completely ineffective due to the guard itself.

Installation and Activation

Official installation command (from README):

cd ~/.dsh && dsh plugin --profile <your-profile> add "dsh-ops-guard@github:BeiWay1145/dsh-ops-guard"

Restart DSH after installation to take effect. The search guard requires Everything (including es.exe) to be running locally; the download guard requires the aria2-next engine (built into Motrix Next) to be running locally. The bundled script communicates with it via JSON-RPC and does not depend on aria2c.exe.

The plugin runs with the permissions of the current DSH process; please review the repository source code and the MIT license (package.json version 0.1.0, requires Node >= 20) before installation.

Typical Usage

Intercepted Download: Switch to aria2-dl based on Rejection Reason

After interception, the model will see a description similar to: downloads must use local aria2, providing the absolute path of the bundled script (resolved via import.meta.url), and the URL is automatically extracted from the blocked command. It can be used directly in the terminal:

node scripts/aria2-dl.cjs <url> --out=<filename> [--dir=<directory>] [--no-wait]
node scripts/aria2-dl.cjs --status <gid>
node scripts/aria2-dl.cjs --list

Environment variables (documented in README):

Variable Default Description
ARIA2_RPC_PORT 16800 Engine RPC port
ARIA2_RPC_TIMEOUT_MS 15000 RPC timeout
ARIA2_DOWNLOAD_DIR User Downloads directory Default save directory

If the engine is not started, the script will explicitly report an error instead of failing silently.

Intercepted glob: Results are Already in the Rejection Reason

The search guard will not let the model run glob again; the rejection text includes the match count, path list, IPC latency, and example es.exe commands if necessary. If a different query is needed, use the same pattern language as Everything according to the prompt.

Working Principle (Brief)

Model requests glob("**/*.md", path: "D:/proj")
    ↓
tools/pre-execute hook triggered
    ↓
Search guard queries via Everything IPC → Gets results
    ↓
Returns { kind: 'deny', reason: '<Rejection description + actual results>' }
    ↓
Built-in glob is not executed, model reads results directly

The download path is similar: pre-execute can only allow/deny/ask/cancel and cannot rewrite the call, so the download side adopts “Rejection + complete alternative command”.

Use Cases and Known Limitations

Suitable for: Teams or individuals who want to unify large file downloads to Motrix Next / aria2-next within DSH sessions and enforce filename searches via Everything IPC; consistent with the “everything is a plugin” DSH ecosystem, the plugin comes from the community directory SkillHub and has no official affiliation with DeepSeek / High-Flyer.

Notes:

  • It cannot block downloads inside commands (e.g., urllib inside python script.py); curl -o in terminals outside DSH is unaffected.
  • The Everything IPC protocol is not public; version changes may cause the guard to fall back to “give command” mode.
  • Newly written files to disk may not be found briefly; continue to use grep for content search.

Conclusion

dsh-ops-guard converges aria2 downloads and Everything file searches from “skill suggestions” into enforced policies at pre-execute, distinguishing side-effect operations from read-only queries using “Rejection + Command” and “Rejection + Result” handling. For installation or issues, see the GitHub Repository and SkillHub Directory Page.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye