dsh-stream-rules
按需注入规则而不浪费上下文,opencode-stream-rules 的 DSH 移植版。
jiesou
@jiesou
⬇ 2
★ 4
main
安装
dsh plugin --profile web add github:jiesou/dsh-stream-rules
需要可复现安装时,可在仓库后追加 #commit 固定提交。
按需注入规则而不浪费上下文,opencode-stream-rules 的 DSH 移植版。
该插件未提供要点说明,请参考仓库 README。
cordisdeepseek-harnessdshdsh-pluginguardrailstream-rules
- 安装并启动 DeepSeek Harness:
npx @deepseek-ai/dsh web - 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
- 用 dsh plugins list 确认已安装,必要时重启 Harness 生效
插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。
| 代码仓库 | github.com/jiesou/dsh-stream-rules |
| 许可证 | MIT |
| 主要语言 | main |
| 下载量 | 2 |
| GitHub 星标 | 4 |
| 最近推送 | 2026-08-14 |
| 收录日期 | 2026-09-19 |
| 分类 | 开发与运行时 |
事实信息来自公开插件目录快照(2026-10-01),介绍文案由本站再加工。
以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。
# dsh-stream-rules
[简体中文](README.zh.md)
Inject rules when needed, without wasting context.
[图片: -6336866371853030306_121]
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 rule fires at most once per session (per agent), mirroring the original's `notified` dedup.
## Install
From npm (prebuilt, recommended):
```sh
dsh plugin --profile add @jiesou/dsh-stream-rules
```
Or from GitHub (runs `prepare` to build on install):
```sh
dsh plugin --profile add github:jiesou/dsh-stream-rules
```
Or add the row to your profile's `cordis.patch.yml`:
```yaml
- id: stream-rules
name: '@jiesou/dsh-stream-rules'
```
## After installing
You need to write the rules in your own `.js` file. This plugin won't work by default until you edit the rules.
1. Locate the plugin's path:
```
$DSH_HOME/profiles//node_modules/@jiesou/dsh-stream-rules
```
where `$DSH_HOME` defaults to `~/.dsh`.
2. Write rules:
```sh
mv rules/rules.js.example rules/rules.local.js
```
- Files starting with `_` are skipped.
- To point at a different rules directory: `config.rules`:
```yaml
- id: stream-rules
name: '@jiesou/dsh-stream-rules'
config:
rules: /path/to/your/rules
```
- A rule with `reject: true` will only be rejected on the first toolcall; subsequent attempts by the agent will be allowed. This provides steering while avoiding overly restricting the model (e.g., allowing `pip install` if it's already in a container).
## Writing rules
```js
// rules/rules.local.js
export default [
{
match: (v) =>
v.includes('pip') &&
v.includes('install') &&
!v.includes('uv pip') &&
!v.includes('uvx'),
reject: true,
prompt: 'Use `uvx` or `uv venv` + `uv pip` instead of `pip install` directly',
},
{
match: (v) => v.includes('curl') && v.includes('api.github.com'),
prompt: 'Prefer using `gh` cli over `curl https://api.github.com/...`. gh offers more requests limits.',
},
{
match: (v) => v.includes('pdf'),
prompt: 'Use the `markitdown` skill to read PDF files.',
},
// add your rules here
]
```
| field | required | description |
| -------- | -------- | -------------------------------------------------------------------- |
| `match` | ✅ | `(v: string) => boolean`; every tool call is flattened to a string and matched |
| `prompt` | ✅ | The prompt for steering |
| `reject` | | If `true`, prevent the tool call first, instead of just steering |
## Implementation notes
- A single `src/index.ts` (~60 lines).
- Uses DSH's `tools/pre-execute` waterfall (`deny`) and `agent.inject()` (steering), the documented native extension points. No core changes, no monkey-patching.
数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。