
jiesou/dsh-stream-rules
40Last commit Aug 14, 2026
dsh-stream-rules DSH plugin
dsh-stream-rules is a DSH plugin that lets you define custom rules triggered by tool calls. When a rule matches, it injects a steering notice or denies the first call, allowing precise control over agent behavior. The plugin is lightweight (~60 lines) and uses DSH's native extension points.
How to install the dsh-stream-rules DSH plugin
dsh plugin --profile <name> add @jiesou/dsh-stream-rulesThis source command needs manual review. Copying does not run it.
dsh-stream-rules DSH plugin data source
dsh-stream-rules DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-stream-rules DSH plugin can do
- Match tool calls by flattened string (name + arguments) using a custom function
- Inject a SYSTEM NOTICE steering message before the agent retries the same point
- Optionally reject the first tool call (deny) while allowing subsequent attempts
- Each rule fires at most once per session, preventing repeated interference
- Load rules from a local `.js` file with flexible configuration path
Where the dsh-stream-rules DSH plugin fits
- Force agent to use `uvx` or `uv pip` instead of raw `pip install`
- Prefer `gh` CLI over `curl` for GitHub API calls to increase rate limits
- Recommend `markitdown` skill when the agent tries to handle PDF files
- Block insecure commands like `curl | bash` on the first attempt
- Enforce company-specific tool conventions without modifying the agent core
Who the dsh-stream-rules DSH plugin is for
- DSH users who want to fine-tune agent tool usage without rebuilding the model
- Developers and security teams implementing behavioral policies for AI agents
dsh-stream-rules DSH plugin limitations
- Only works within DSH environment; requires the plugin to be installed and configured
- Rules are based on string matching of tool calls, which may not cover complex patterns
- No built-in hot reload; rule file changes require restarting the agent
- Default config does nothing – users must write their own rules file after installation
dsh-stream-rules DSH plugin: from the repository README
Quoted from the jiesou/dsh-stream-rules README, the upstream source of the dsh-stream-rules DSH plugin. Copyright remains with the original authors.
Inject rules when needed, without wasting context. <img height="500" alt="-6336866371853030306_121" src="https://github.com/user-attachments/assets/09a5b140-bfcc-4401-895d-af9280b44709" /> You can write custom streaming rules for the agent. These rules are injected only as a steering notice after a pattern match, then agent retry from the same point. This allows you to control the boundaries of agent behavior, without wasting context. Port of my [jiesou/opencode-stream-rules](https://github.com/jiesou/opencode-stream-rules) to DSH. Similar to oh-my-pi's "Time-traveling stream rules", but with a very simple and compact code implementation. ## How it works A rule fires on a tool call (tool name + serialized arguments) when its `match` returns true: - **default** — injects a `SYSTEM NOTICE` steering message into the agent via `agent.inject()` (DSH's non-waking "queue model-facing context for the next pre-step"). The agent retries from the same point, now knowing the rule. - **`reject: true`** — denies the FIRST tool call (`{ kind: 'deny' }`); later attempts are allowed. Steering without over-restricting, e.g. letting `pip install` through when it's already in a container. Each
Read the full READMERepository license: MIT
dsh-stream-rules DSH plugin questions
How do I install dsh-stream-rules?
You can install it via npm: `dsh plugin --profile <name> add @jiesou/dsh-stream-rules`. Alternatively, install from GitHub: `dsh plugin --profile <name> add github:jiesou/dsh-stream-rules`. After installation, you must edit the rules file to make the plugin active.
The plugin doesn't do anything after installation – why?
By default, the plugin ships with an example rules file that is disabled. You need to locate the plugin's directory (usually `~/.dsh/profiles/<name>/node_modules/@jiesou/dsh-stream-rules`), rename `rules/rules.js.example` to `rules/rules.local.js`, and then write your own rules. The plugin will only start matching once a valid `.local.js` file exists.
Can I use environment variables in the rules file?
The rules file is a plain JavaScript module that exports an array of rule objects. You can use any valid JavaScript inside it, including `process.env` or other Node.js globals, as long as the file is executed in the DSH plugin context. However, note that the `match` function receives a string, so you must design your matching logic accordingly.
How do I debug why a rule isn't firing?
Check that the rule file is loaded by looking at the plugin's log output. Common issues: the file name must end with `.local.js` (files starting with `_` are skipped), the `match` function must return `true` for the tool call, and the rule hasn't already fired in the current session. You can also add temporary `console.log` statements inside the `match` function to see what strings are being matched.
Can I reload rules without restarting the agent?
Currently, the plugin does not support hot-reloading. You must restart the DSH agent (or the profile) for changes to the rules file to take effect. This is a known limitation mentioned in the plugin's documentation.