Ndsanes/dsh-rules

Plugin插件 Native原生 ⭐ 3 NOASSERTION Docs & Writing文档与写作

OMP rules port for DeepSeek Harness: rulebook, always-apply injection, rule:// addressing, and time-traveling stream rules that interrupt violating model output

Project Overview项目介绍

dsh-rules is a native cordis plugin built specifically for DeepSeek Harness, distributed as the npm package @ndsanes/dsh-rules and registered through the dsh plugin --profile <name> add @ndsanes/dsh-rules command. It targets the Open Mod Protocol (OMP) rule format, discovering Markdown rule files from the workspace's .omp/rules directory, the user rules folder, the omp-plugins pluginRoots tree, the agents directories, plus foreign directories such as <cwd>/.cursor/rules, <cwd>/.windsurf/rules, the nearest .clinerules, and .github/instructions/*.instructions.md. Identity is the rule name alone, so the merge keeps the first rule to claim it in priority order, which is why <cwd>/.cursor/rules/style.md defeats a same-named ~/.cursor/rules/style.md. Operators must also remove any stale link: dependency or dsh.profile.bundles entry under an old package name before installing, because the loader resolves bundle rows by current name and a leftover entry causes a bare import failed boot error that the plugin cannot diagnose.

The plugin injects alwaysApply rules and the rulebook directly into the system prompt so the model can pull individual rule bodies on demand, then enforces **time-traveling stream rules** that interrupt violating model output mid-turn before it lands on the user. It ships a browser half that renders the same rule editor twice — once on the Plugins page under this plugin's own row, once as a tab inside Settings → Plugins — where fixed-vocabulary fields such as interruptMode use dropdowns so a typo cannot slip through; an unrecognised value silently falls back to the profile default of always. Workflow suits teams that want OMP conventions plus Cursor, Windsurf, Cline and GitHub instruction files to be governed by one consistent harness-wide layer, and the bundled src/builtin-rules/ directory holds 27 MIT-licensed defaults for TypeScript, Go and Rust that override OMP's own copy under identical names. The repo also provides helper scripts: scripts/audit-rules.ts to dump what the plugin parsed from a real project, scripts/render-prompt.ts to mount the plugin on a real DSH system-prompt service and print the assembled prompt without making a model call, and scripts/verify-interrupt.sh to run one prompt twice against a live DSH — once with an interrupting rule, once with a warning-only twin — so the transcript diff is the evidence.

First-run caveats are concrete: discovery is asynchronous, so the very first prompt assembly after a late mount renders without rule layers while the build runs, and the first tool call waits on the same waterfall, though a violating call is still blocked. The rule tool distinguishes "still being discovered" from "no rules exist" so a stale session does not look broken. Development follows a dev → main branch flow where the Release workflow publishes via npm Trusted Publishing using a short-lived OIDC credential scoped to one run, so no token is stored in the repository; configuration happens once on npmjs.com with user Ndsanes, repository dsh-rules, workflow filename release.yml. Build commands are pnpm install, pnpm test (vitest), pnpm typecheck, pnpm build, and after editing anything under src/builtin-rules/ the maintainer must run pnpm run embed:rules so the bundler, which cannot import Markdown as text, regenerates src/generated/builtin-rules.ts. Offline coverage is provided by tests/interrupt-loop.spec.ts, which mounts a real AgentLoop, SessionStore, LlmRuntime and tool registry through the DSH test kit and asserts abort, <system-interrupt> retry, the <system-reminder> path for interruptMode: never, and that repeatMode: once spends the rule, all under the MIT license.

dsh-rules 是为 DeepSeek Harness 开发的 OMP 规则插件,安装方式为运行 dsh plugin --profile <name> add @ndsanes/dsh-rules,必要时在 cordis.patch.yml 中添加该条目并重载 profile。它会自动发现 .omp/rules、~/.cursor/rules、~/.windsurf/rules、.clinerules、.github/instructions 以及 omp-plugins 各 pluginRoots 子目录下的所有 Markdown 规则文件,并按优先级合并同名规则。

插件将 alwaysApply 规则与 rulebook 注入系统提示,使模型按需加载具体规则体,并在模型流式输出违反规则时通过 TTSR 机制实时中断。它还附带浏览器端配置页,出现在 Plugins 页面与 Settings → Plugins 中,方便编辑 interruptMode、globs、condition、astCondition、question、scope 等字段。该项目主要面向需要在 DSH 内部集中管理多来源编码规则的开发者与团队。

运行时无外部模型依赖,规则编译在 pnpm build 时完成并嵌入产物;内置 27 条 MIT 规则(TypeScript、Go、Rust)随插件一起发布。首次启用时若 profile 已存在旧包名或 dsh.profile.bundles 条目,必须先清除,否则会出现仅显示 import failed 的引导失败。许可证为 MIT。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
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 @ndsanes/dsh-rules

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

READMEREADME

dsh-rules

简体中文

OMP rules for DeepSeek Harness.

Discovers rule files from every convention OMP supports, injects the always-apply and rulebook layers into the system prompt, lets the model load a rule body on demand, and enforces time-traveling stream rules that interrupt violating model output mid-turn.

Install

dsh plugin --profile <name> add @ndsanes/dsh-rules

Then add the row to the profile's cordis.patch.yml if it is not already applied by the package's own bundle patch, and reload the profile.

If the profile already carries this plugin under a different package name — a stale link: dependency or a dsh.profile.bundles entry — remove it from both dependencies and dsh.profile.bundles before adding. The loader resolves a bundle row by the current package name, so a leftover entry points at a module the profile no longer has, and the boot reports only import failed. Nothing on the plugin side can diagnose that.

Rule files

A rule is a Markdown file with YAML frontmatter:

---
description: Read before writing a database migration.
globs: "Database/**/*.surql"
condition: "DEFINE (FIELD|TABLE|INDEX)"
scope: "tool:edit(*.surql), tool:write(*.surql)"
interruptMode: always
---

The migration body.
Field Meaning
description Required for the rulebook listing.
alwaysApply Injects the whole body into the system prompt.
globs Path gate; a TTSR rule needs at least one matching candidate path.
condition Regex triggers (legacy ttsr_trigger also accepted).
astCondition ast-grep structural triggers, checked on tool arguments.
question Natural-language question answered by a judge model.
scope text, thinking, tool, tool:<name>(<glob).
agents Agent-name globs; main and sub are reserved.
interruptMode never | prose-only | tool-only | always.

In the rule editor, a field with a fixed vocabulary — interruptMode today — is a dropdown listing exactly the accepted values, so the value cannot be misspelled. That matters because an unrecognised interruptMode is not rejected: it falls back to the profile default, and the default is always. The dropdown's first option means "inherit the profile default", and choosing it removes the line from the file. An empty value would parse as unrecognised and land on the same default it was meant to escape.

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-irmia-devkit 下一个 Next dsh-map-tools →