模式匹配自动注入 steering rules,不占系统上下文 - Inject rules when needed, without wasting context. Similar to oh-my-pi's "Time-traveling stream rules", but with a very simple and compact code implementation.
安装
dsh plugin --profile web add github:jiesou/dsh-stream-rulesGitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试
安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗
安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。
README
按需注入规则,不浪费上下文。
你可以为 agent 编写自定义的流式规则(streaming rules)。
规则只在模式匹配后作为一条 steering notice 注入,然后 agent 会从同一个位置重试。 这样你就能控制 agent 的行为边界,同时不浪费上下文。
由我的 jiesou/opencode-stream-rules 移植到 DSH。 与 oh-my-pi 的 "Time-traveling stream rules" 类似,但代码实现非常简单紧凑。
工作原理
当规则在某个工具调用(工具名 + 序列化后的参数)上 match 返回 true 时,该规则触发:
- 默认 — 通过
agent.inject()向 agent 注入一条SYSTEM NOTICEsteering 消息(DSH 的"非唤醒"机制,为下一次 pre-step 排队模型可见上下文)。agent 会从同一位置重试,此时它已经知道了这条规则。 reject: true— 拒绝第一次工具调用({ kind: 'deny' });之后的尝试会被放行。在不至于过度限制的前提下进行 steering,例如在容器内已经允许pip install通过时。
每条规则在每个会话(每个 agent)中最多触发一次,与原始版本的 notified 去重逻辑一致。
安装
从 npm 安装(预构建产物,推荐):
dsh plugin --profile <name> add @jiesou/dsh-stream-rules
或从 GitHub 安装(安装时会运行 prepare 构建):
dsh plugin --profile <name> add github:jiesou/dsh-stream-rules
或者在你 profile 的 cordis.patch.yml 中添加一行:
- id: stream-rules
name: '@jiesou/dsh-stream-rules'
安装之后
你需要自己编写 .js 规则文件。在编辑之前,这个插件默认不会做任何事。
- 找到插件的路径:
$DSH_HOME/profiles/<name>/node_modules/@jiesou/dsh-stream-rules
$DSH_HOME 默认是 ~/.dsh。
- 编写规则:
mv rules/rules.js.example rules/rules.local.js
- 以
_开头的文件会被跳过。 - 可以用
config.rules指向其他规则目录:
- id: stream-rules
name: '@jiesou/dsh-stream-rules'
config:
rules: /path/to/your/rules
- 带
reject: true的规则只在第一次工具调用时拒绝;之后 agent 重试会被放行。既做了引导又不过度限制(例如在容器里时允许pip install)。
编写规则
// 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
]
| 字段 | 必填 | 说明 |
|---|---|---|
match |
✅ | (v: string) => boolean;每次工具调用都会被扁平化为字符串并匹配 |
prompt |
✅ | 用于 steering 的提示语 |
reject |
若为 true,则先阻止第一次工具调用,而不仅仅是 steering |
实现说明
- 单个
src/index.ts(约 60 行)。 - 使用 DSH 的
tools/pre-executewaterfall(deny)和agent.inject()(steering),这些都是官方文档记载的原生扩展点。没有改动核心,没有 monkey-patching。
原始 README: https://github.com/jiesou/dsh-stream-rules/blob/main/README.zh.md ↗
同类插件
查看全部 →
dsh-anchored-standard
两阶段 DeepSeek Harness 预设:先 Minimal 对齐的 bootstrap,再切完整 Standard 工具(Project2 98/99)

PicGo-Core
极致的图片上传引擎,CLI 与 API 双支持

awesome-deepseek-harness
DeepSeek Harness(DSH)及其优秀社区插件的精选指南。

awesome-deepseek-harness
DeepSeek Harness (DSH)生态系统:来自dsh-external/hub和公共dsh-plugin主题的精选插件、工具和基础设施。

AI-Novel-Writer
本地优先 AI 小说创作工作台,提供 Windows/macOS 桌面版与 DeepSeek Harness 插件开发预览,支持角色、大纲、章节蓝图、审稿修稿和本地模型。

mcp-for-stata
MCP-for-Stata:把 Stata 集成进你的 agent