总览Overview
一、观察:把会话事件变成“摩擦”1. Observe: from session events to friction
插件订阅 DSH 的会话事件,先归一化成与版本无关的“观察”(一次工具调用及其结果、一条用户消息、一轮的开始和结束),再交给 16 个判断点。因为判断点读的是归一化后的数据,同一套判断既能跑在实时会话上,也能跑在磁盘上存着的历史会话上。The plugin subscribes to DSH's session events and first normalizes them into version-independent observations (a tool call with its result, a user message, the start and end of a turn), which 16 detectors then read. Because detectors read normalized data, the same detectors run on a live session and on a session stored on disk.
每个发现带一个签名,它去掉路径、行号、时间戳,只留下能认出“这是同一个坑”的事实,比如 bash:command-not-found:python。签名让一个麻烦可以跨会话计数。Every finding carries a signature. Paths, line numbers and timestamps are stripped, and what is left is the fact that identifies the same pothole, such as bash:command-not-found:python. A signature is what lets a trouble be counted across sessions.
二、决策:值不值得改,什么时候改2. Decide: whether to change, and when
一个发现不等于一个决定。触发策略把它和适配库里已有的东西放在一起权衡:A finding is not a decision. The trigger policy weighs it against what the library already knows:
| 规则Rule | 默认值Default | 作用Effect |
|---|---|---|
| 动手门槛Threshold to act | 0.6 | 严重程度低于它的只记录Anything less severe is only recorded |
| 历史加成Boost from history | +0.15 每次,至多each, up to +0.4 | 以前的会话见过同一个签名,门槛相应降低Earlier sessions with the same signature lower the bar |
| 每次会话上限Per-session limit | 4 | 一次嘈杂的会话不会把 Harness 改得面目全非One noisy session cannot reshape the harness |
| 修订条件Revision | 2 | 装着适配的会话里又出现这么多次,就重写它Recurrences, in sessions that had it mounted, before it is rewritten |
| 扩大范围Widening | 2 | 在这么多个工作区碰到,就从工作区升级为全机Workspaces that met it before it applies machine-wide |
大多数麻烦在下一步模型请求之前处理;“没验证就要收工”这一类在这一轮结束的边界上处理。Most trouble is answered before the next model request. Ending a turn on unverified edits is answered at the boundary where the turn would stop.
三、改写:让会话里的模型写 Harness 代码3. Rewrite: the session's model writes harness code
插件向会话当前的模型发一次单独的请求:一份适配 API 的说明,加上这次发现的证据(哪些调用、怎么失败的、用户说了什么)。模型回一段 JavaScript。这次请求不进入会话日志,记在适配库的审计记录里。The plugin sends one separate request to the session's current model: a description of the adaptation API plus the evidence of this finding (which calls, how they failed, what the user said). The model replies with a piece of JavaScript. The request stays out of the session log and is recorded in the library's audit trail.
被校验关打回的版本会连同原因一起发回去重写,默认最多两次。还是不行,就用内置模板生成一个保守的版本。A version the gate rejects is sent back together with the reasons, twice at most by default. If that fails too, a built-in template produces a conservative version.
四、校验与挂载4. Validate and mount
静态Static
长度上限;不许出现
require、import、process、eval、网络访问。A length limit; norequire,import,process,evalor network access.加载Load
能编译,调用了
define(),确实注册了东西,声明的能力都用到了。It compiles, callsdefine(), registers something, and uses every capability it declares.重演Replay
把触发它的那几次调用回放给它,它必须有所动作。什么都不做的代码过不了这一关。The calls that triggered it are replayed to it, and it has to act. Code that does nothing stops here.
回归Regression
把本次会话里成功的调用回放给它,它不许拒绝、拦截或改写其中任何一个,也不许拦
command -v这类查看环境的命令。The calls that succeeded in this session are replayed, and it must not refuse, block or rewrite any of them, nor commands that only inspect the environment, such ascommand -v.权限Permission
用到改写结果、新增工具、执行命令这三种能力的,默认搁置,等人批准。An adaptation that rewrites results, adds a tool or runs commands is held for a person's approval by default.
通过之后,适配装进独立的 node:vm 上下文,和宿主之间只隔着一个传 JSON 字符串的桥,拿不到宿主对象。每次调用有同步和异步两重超时。它在下一次模型请求之前生效,同时告诉模型 Harness 刚刚改了什么。After the gate, the adaptation is mounted in its own node:vm context. Only a bridge that passes JSON strings connects it to the host, so it cannot reach host objects. Every call has a synchronous and an asynchronous timeout. It takes effect before the next model request, and the model is told what the harness just changed.
五、沉淀与共享5. Keep and share
每台机器有一个适配库(默认在 $DSH_HOME/rsi):每个适配一个目录,带版本历史;ledger.jsonl 记每次摩擦、挂载、生效和出错,audit.jsonl 记系统做过的每个决定。Every machine has one library (in $DSH_HOME/rsi by default): one directory per adaptation with its version history; ledger.jsonl records every friction, mount, effect and fault, and audit.jsonl every decision the system took.
- 新适配是
candidate,在后来的会话里起过作用且没出过错,转为active。A new adaptation is acandidate. Once it has acted in later sessions without faults it becomesactive. - 处理函数抛错不影响它所挂的那次工具调用。累计三次,上一版重新上岗;没有上一版就
quarantined。A handler that throws never affects the tool call it is attached to. After three faults the version before it goes back to work; with no earlier version it isquarantined. - 核心指标是二次命中率:装上之前和之后,有多大比例的会话还会遇到这个麻烦。The central metric is the second-hit rate: the share of sessions that still meet the trouble, before and after the adaptation.
- 项目层的适配转正后写进
.dsh-rsi/adaptations/。别的机器认的是文件内容的哈希:dsh-rsi trust之前不运行,文件变了要重新接受。A promoted project-layer adaptation is written to.dsh-rsi/adaptations/. Other machines go by the hash of a file's content: nothing runs beforedsh-rsi trust, and a changed file has to be accepted again.
六、回退:坏了怎么办6. Going back: when a change is wrong
一个会改自己的 Harness,必须改得回去。能做到这一点,靠的是三条设计上的性质:Harness 自己的代码从不被改动,适配只是运行时挂上去的脚本;每个版本都留在磁盘上,编号不会用第二次;Harness 运行的东西每变一次,timeline.jsonl 里就多一行,记下改了什么、谁改的、以及改完之后的完整状态。A harness that changes itself has to be able to change back. Three properties of the design make that possible: the harness's own code is never touched, an adaptation being a script mounted at run time; every version stays on disk, and a version number is never used twice; and whenever what the harness runs changes, one line goes into timeline.jsonl with what changed, who changed it and the whole state it left behind.
Harness 自己撤回What the harness takes back by itself
| 出了什么问题What goes wrong | 会发生什么What happens |
|---|---|
| 适配的代码抛错或超时,累计三次Its code throws or runs out of time, three times | 如果它是一次重写,上一版重新上岗;没有更早的版本才隔离。If it is a rewrite, the version before it goes back to work. Only with no earlier version is it quarantined. |
| 适配拦下调用,模型却一再坚持It refuses calls and the model keeps making them | 同一轮里拦了两次之后,下一个它要拦的调用放行一次。调用成功,说明适配错了,或者它知道的事实已经过时,于是撤回;调用失败,说明拦得对。After two refusals in one turn, the next call it would refuse is let through once. If the call works, the adaptation was wrong or what it knew is out of date, and it is taken back. If the call fails, the refusals were right. |
| 适配没拦住麻烦,或者从不起作用It does not stop the trouble, or never acts | 前者重写,后者在 20 个会话之后退役。The first is rewritten; the second is retired after 20 sessions. |
放行试探只用于在本机、从失败的调用里学出来的适配:它们主张的是“这个调用在这里会失败”,这是一个可以用真实调用检验的事实。代表用户要求的拦截、来自项目 Harness 或导入包的拦截,绝不会被放行。被撤回的版本连同原因一起记下,下次模型为同一个原因写适配时会看到它错在哪,同一段代码不会被接受第二次。The check applies only to adaptations learned on this machine from a call that failed. What they claim, "this call fails here", is a fact that a real call can test. A refusal that stands for something the user asked for, or that came from a project harness or an imported pack, is never set aside. A version that was taken back is remembered with the reason: the next time the model writes for the same cause it is shown what went wrong, and the same script is not accepted twice.
用户撤回What the user can take back
| 撤回什么What | 在会话里In a session | 在终端里In a terminal |
|---|---|---|
| 最近装上的那一样The last thing put to work | /rsi undo | dsh-rsi undo |
| 一个适配,回到更早的版本One adaptation, to an earlier version | dsh-rsi rollback <id> [--to n] | |
| 整个 Harness,回到某一代The whole harness, as at a generation | dsh-rsi timeline, dsh-rsi restore <n> | |
| 全部:原版 HarnessEverything: the stock harness | /rsi off | dsh-rsi off |
这些操作都在正在运行的会话的下一次工具调用之前生效,什么都不删。恢复本身也是一代,所以回退也能被撤回。项目 Harness 的文件属于仓库:在自己的机器上回退只是让它们不在这里运行,替所有人撤回要靠删掉文件并提交。All of these take effect in running sessions before their next tool call, and none of them deletes anything. A restore is itself a generation, so going back can be taken back too. The files of a project harness belong to the repository: going back on one machine stops them from running there, and taking one back for everyone means removing the file and committing.
安全模型Safety model
| 能力Capability | 做什么What it does | 级别Tier |
|---|---|---|
annotate steer prompt | 在工具结果后、下一步之前、系统提示词里补充信息Add information after a tool result, before a step, or to the system prompt | 自动automatic |
deny ask block | 拒绝一次调用、要求先经批准、把结果改成带纠正意见的错误Refuse a call, require approval first, turn a result into an error with a correction | 自动automatic |
verify | 条件不满足时不让这一轮结束Keep a turn from ending while a condition is not met | 自动automatic |
rewrite tool exec | 替换结果文本、注册新工具、通过 Harness 的 shell 执行命令Replace result text, register a tool, run commands through the harness's shell | 需批准needs approval |
node:vm 的隔离防的是写错和随手滥用,不是对抗恶意代码的边界。接受别人仓库里的 .dsh-rsi/ 之前,请先读一遍。
This is not a security sandbox. No capability can allow what the harness would refuse, and that is guaranteed by design. The node:vm isolation, however, guards against mistakes and casual misuse, not against malicious code. Read another repository's .dsh-rsi/ before you accept it.
接入 DSH 的位置Where it plugs into DSH
| DSH 扩展点DSH extension point | DSHRSI 用它做什么What DSHRSI does there |
|---|---|
session/event | 观察;界面的只读视图也由它折叠而来Observation; the UI's read model is folded from the same events |
tools/pre-execute | 在工具调用执行前拒绝或要求批准Refuse a tool call, or require approval, before it runs |
tools/post-execute | 在结果后附说明、拦截、改写Annotate, block or rewrite a result |
agent/pre-step | 生成并挂载适配;在下一次请求前加说明Generate and mount adaptations; add notes before the next request |
agent/turn-stopping | 没验证时不让这一轮结束Keep a turn open while nothing was verified |
| 系统提示词与工具注入System prompt and tool injection | 常驻提示词段、新增工具Standing prompt sections, new tools |
| 会话投影、斜杠命令、界面插槽Session projections, commands, UI slots | RSI 徽标、状态条、/rsiThe RSI badge, the status pill, /rsi |
没有摩擦、没有挂载任何适配时,插件对模型完全不可见:系统提示词、工具列表和消息逐字节不变,有端到端用例守着。With no friction and nothing mounted, the plugin is invisible to the model: system prompt, tool list and messages are unchanged byte for byte, and an end-to-end test guards that.
路线图Roadmap
下面分成“已经有的”和“打算做的”。打算做的是计划,不是承诺,也没有日期。Split into what exists and what is planned. Planned means intended, with no promise and no date.
- 完整闭环:观察、决策、改写、校验、挂载、沉淀、共享The full loop: observe, decide, rewrite, validate, mount, keep, share
- 三层,项目专属的 Harness,导出与导入Three layers, a harness per project, export and import
- Web 界面里的徽标、状态条和
/rsiBadge, status pill and/rsiin the Web UI - 四个基准上和原版 DSH 的逐题对照评测A task-by-task evaluation against stock DSH on four benchmarks
- 在每题自带环境、同仓库多题的基准上评测(SWE-bench Verified、Terminal-Bench),那里才有反复出现的麻烦Evaluation on benchmarks with per-task environments and many tasks per repository (SWE-bench Verified, Terminal-Bench), where trouble does recur
- 更多模型的实测Live runs with more models
- 在真实的桌面 App 里验证;自动化的浏览器测试Verification in the real desktop app; automated browser tests
- 让判断点的阈值也从账本里学,同时保持校验关不可被修改Detector thresholds learned from the ledger, with the gate kept out of reach