jiesou/dsh-stream-rules 预览 preview

jiesou/dsh-stream-rules

模式匹配时自动注入规则,仅在需要时注入,不浪费上下文。类似oh-my-pi的“时间旅行流规则”,但代码实现极为简洁紧凑。

Project Overview项目介绍

dsh-stream-rules is a native DSH plugin that injects custom steering rules only when a matching tool call pattern is detected, so it doesn’t waste precious context window space on pre-loaded rules. It was ported from the opencode-stream-rules repository specifically for DSH, and offers two types of rule behavior. The default behavior injects a system steering notice and has the agent retry from the current point, while the reject mode blocks the first matching tool call but allows subsequent retries for flexible steering. Installation can be done via three different methods: prebuilt npm package, direct install from GitHub, or manual entry in your profile’s cordis.patch.yml.

After you install the plugin, it will not work out of the box because you need to add your own custom rules. First, you have to navigate to the plugin’s installation directory in your DSH profile, which by default lives under ~/.dsh/profiles/<your-profile-name>/node_modules/@jiesou/dsh-stream-rules. Then you can rename the example rules file from rules.js.example to rules.local.js, and edit it to add your own custom rules following the existing template. If you want to store your rules in a different directory, you can update the plugin config to point to your custom rules path.

This plugin requires DSH version between >=0.1.0-rc.6 and <0.2.0, and Node.js version ^22.19.0 or >=24.0.0, and works with both web and headless DSH profiles. Each rule is configured to fire at most once per agent session, to avoid duplicate notifications and redundant steering. The entire plugin is only around 60 lines of code in a single source file, and uses DSH’s official native extension points without any core patching. It is released under the open-source MIT license, so you can modify and redistribute it freely.

这是一款专为 DeepSeek Harness (DSH) 开发的原生插件,核心功能是在工具调用匹配自定义规则模式后,注入对应提示引导代理调整行为,不会提前占用对话上下文空间。它支持两种规则模式:默认注入引导提示让代理从当前点重试,或是拒绝首次违规工具调用,后续尝试则放行,在限制行为的同时保留操作灵活性。用户可通过 npm 预编译包、GitHub 源码或直接修改配置文件三种方式完成安装。

插件默认不会生效,安装完成后用户需要自行编写自定义规则文件。典型流程是先找到插件在 DSH 配置目录下的安装路径,复制示例规则文件并重命名为规则配置文件,再按照给定的 JS 格式编写自己的匹配规则与提示内容。如果你需要将规则存放在其他自定义目录,也可以通过插件配置项指定规则路径。这款插件适合想要规范 DSH 代理行为、避免不必要上下文浪费的开发者使用。

该插件要求 DSH 版本在 0.1.0-rc.6 到 0.2.0 之间,Node.js 版本需为 22.19.0 或更高,兼容 web 与 headless 两种配置文件。每条规则在每个会话中最多触发一次,避免重复提示。插件代码精简,仅约 60 行,使用 DSH 官方提供的扩展接口实现,无需修改核心代码,采用 MIT 许可开源免费使用。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @jiesou/dsh-stream-rules

把 jiesou/dsh-stream-rules 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-stream-rules

简体中文

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 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 when its match returns true, against:

  • the tool call — tool name + flattened arguments (numbers included, e.g. timeoutMs), before dispatch.
  • the settled result — after dispatch, the tool's content, status markers ([timed out after 600000ms], [exit code: 1], …) and error text join the match string, so rules describing outcomes (a crash, a full disk, a timeout) can match there too. Matching after dispatch can only steer, never deny.

On a match:

  • default — injects a SYSTEM NOTICE steering message into the agent (pre-dispatch via agent.inject(), post-dispatch as additionalContexts on the tool result — 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):

dsh plugin --profile <name> add @jiesou/dsh-stream-rules

Or from GitHub (runs prepare to build on install):

dsh plugin --profile <name> add github:jiesou/dsh-stream-rules

Or add the row to your profile's cordis.patch.yml:

- 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.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-survey 下一个 Next dsh-voice →