← 返回列表
C

@jiesou/dsh-stream-rules

v0.1.6 · 4 天前发布

Inject rules when needed, without wasting context. DSH port of opencode-stream-rules.

dshdsh-plugindeepseek-harnessrulesguardrailjust-in-timestream-rules

README

@jiesou/dsh-stream-rules

按需注入规则,不浪费上下文。

<img height="500" alt="-6336866371853030306_121" src="https://github.com/user-attachments/assets/09a5b140-bfcc-4401-895d-af9280b44709" />

你可以为 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 NOTICE steering 消息(DSH 的"非唤醒"机制,为下一次 pre-step 排队模型可见上下文)。agent 会从同一位置重试,此时它已经知道了这条规则。

  • reject: true — 拒绝第一次工具调用({ kind: 'deny' });之后的尝试会被放行。在不至于过度限制的前提下进行 steering,例如在容器内已经允许 pip install 通过时。
  • 每条规则在每个会话(每个 a

    查看完整 README →

    版本兼容矩阵

    DSH 版本状态说明
    dsh@0.1.0-rc.6 ✅ 兼容 cordis patch ✅
    dsh@0.1.0 ✅ 兼容 标准 patch ✅
    dsh@0.2.0 ⚠️ 待验证 待实测(API 可能在变)
    dsh@0.3.0+ ❓ 未知 尚未发布

    💡 兼容矩阵每周末自动跑实测,欢迎 PR 修正

    元数据

    License
    MIT
    npm
    @jiesou/dsh-stream-rules
    Repo
    git+https://github.com/jiesou/dsh-stream-rules.git
    Engines
    {}
    Weekly DL
    13
    Monthly DL
    0
    dsh.bundle
    {"bundle":{"patch":"./cordis.patch.yml"}}