dshbase

插件目录 / Developer / dsh-rules-paths

dsh-rules-paths

已验证 · 实测可装 Temoa

✓ 持续维护 基于 7 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

1Stars
0Forks
0未关闭 issue
JavaScript语言
2026-08-15最近推送
跨平台平台

功能简介

Claude Code风格路径:DeepSeek Harness(DSH)的规则注入。

✅
我们的评价
可用 — 实测通过,早期项目

Claude Code风格路径:DeepSeek Harness(DSH)的规则注入。 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-rules-paths

Claude Code-style paths: rule injection for DeepSeek Harness (DSH): when the model successfully reads a file that matches a rule's paths: glob, the rule body is injected into the model context at the next step boundary. It follows the official @deepseek-ai/dsh-agent-instructions mechanics (tools/result hook, agent.inbox.nextStep inbox, agent/pre-step folding, SHA-1 dedup, byte budget).

Features

  • Path rules 锟斤拷 a rule file declares paths: glob patterns; a successful read of a matching file injects the rule body at the next step boundary.
  • Global rules 锟斤拷 a rule without paths (or with no frontmatter at all) is injected into the first entering step of the session, independent of any file read (like AGENTS.md).
  • Project rules 锟斤拷 optional scan of <projectRoot>/.dsh/rules and <projectRoot>/.claude/rules (Claude Code convention), keyed on the .git project root.
  • Dedup & budget 锟斤拷 each rule is injected once per session unless its content changes (SHA-1 digest 锟斤拷 replace); the rendered message never exceeds maxBytes and reports Rules budget 锟斤拷 when rules are dropped or truncated.
  • Guidance, not authority 锟斤拷 injected content is a user-role message that does not override system, developer, or direct user instructions; literal </system-reminder> is escaped.

Install

Requires DSH 0.1.0-rc.x (Web profile).

From GitHub

dsh plugin --profile web add git+https://github.com/Temoa/dsh-rules-paths.git

pnpm pins the package by commit with a full integrity hash. Because the package declares dsh.bundle.patch (cordis.patch.yml), the reconciler appends it to the profile's dsh.profile.bundles automatically 锟斤拷 the plugin mounts at the PROFILE level and rules apply to every session on that profile, no preset edit needed.

To scope the rules to one agent preset instead, add this row to a user preset (a copy of standard):

- id: rules-paths
  name: '@temoa/dsh-rules-paths'
  config:
    rulesDir: "~/.dsh/rules"
    rulesDirProject: true

From a local checkout

dsh plugin --profile web add ./dsh-rules-paths

After changing plugin code, fully restart the harness 锟斤拷 the module is cached per process URL; preset config is re-read per session mount, but the plugin file is not re-imported. Rule files themselves never need a restart. Never edit the shipped presets (standard/code/minimal/cordis); add the preset row above to a copy instead.

Uninstall

dsh plugin --profile web remove @temoa/dsh-rules-paths

Restart dsh after removing. The hook is torn down with the plugin; rule files under ~/.dsh/rules and the project rule directories are left untouched.

How it works

Rules live in ~/.dsh/rules/*.md (configurable via rulesDir), one rule per file:

---
paths:
  - "**/*.dart"
  - "lib/**/*.ts"
description: Dart conventions (optional, metadata only)
---

Rule body: guidance the model follows after reading a matching file.

On every successful read (and once at session start for global rules), the plugin:

  1. Lists the configured rule directories 锟斤拷 the user-level rulesDir, plus <projectRoot>/.dsh/rules and <projectRoot>/.claude/rules when rulesDirProject is on.
  2. Matches the read path against each rule's paths globs, against both the absolute path and the cwd-relative path (Windows \ normalized to /), so **/*.dart matches both D:/lab/proj/lib/main.dart and lib/main.dart. Rules without paths (or without frontmatter) are treated as global.
  3. Renders the matched bodies into a single user-role message 锟斤拷 SHA-1 dedup per session, unchanged rules never re-sent, changed ones sent as replace 锟斤拷 bounded by maxBytes, then folds it into the entering agent/pre-step right after the last claimed message.

paths present but neither a string nor a list skips the file with a warning; files over maxSourceBytes are skipped. Rule bodies are untrusted input: text only, delimiters escaped, never executed. No file watcher: rule edits take effect at the next reconciliation (global) or the next successful read (path rules).

Key Default Meaning
rulesDir ~/.dsh/rules User-level rules directory (~ expands)
maxBytes 65536 Byte budget per injected message
maxSourceBytes 1048576 Max bytes read per rule file (larger files skipped)
triggerTools ["read"] Tool names whose successful executions trigger matching
rulesDirProject false Also scan <projectRoot>/.dsh/rules and <projectRoot>/.claude/rules

Repository layout

dsh-rules-paths/
锟斤拷锟斤拷锟斤拷 package.json        # dsh.bundle.patch manifest
锟斤拷锟斤拷锟斤拷 cordis.patch.yml    # composition layer: appends the plugin to profile bundles
锟斤拷锟斤拷锟斤拷 lib/
锟斤拷   锟斤拷锟斤拷锟斤拷 index.js        # Host half: rule loading, matching, injection
锟斤拷   锟斤拷锟斤拷锟斤拷 types/index.d.ts
锟斤拷锟斤拷锟斤拷 test/
锟斤拷   锟斤拷锟斤拷锟斤拷 index.mjs       # 50-assertion test suite
锟斤拷锟斤拷锟斤拷 README.md
锟斤拷锟斤拷锟斤拷 README.zh.md
锟斤拷锟斤拷锟斤拷 LICENSE

Development

npm install   # fetches the devDependencies (peers + js-yaml + picomatch)
npm test      # node test/index.mjs 锟斤拷 50 assertions

Tests cover: config validation, frontmatter parsing, budget rendering (omit/truncate/escape), message construction, dedup + replace, zero injection, global rules, project rules (.dsh/rules + .claude/rules), and the pre-step fold position.

License

MIT

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-rules-paths」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:Temoa/dsh-rules-paths

Headless(CLI)profile:

dsh plugin --profile headless add github:Temoa/dsh-rules-paths

实测报告

验证通过:从 GitHub 源码完成 L1 安装 + L2 加载 + L3 运行(dsh 0.1.0-rc.6)。

使用场景

扩展 agent 的编码能力面——给它一个新工具、工作流或集成,让它接手以前做不了的开发任务。

适合谁

想让 dsh 在真实代码库上像队友一样干活的开发者——能改、能跑、能验证,而不只是回答问题。

二次开发建议

工具/命令面就是缝:暴露更多 SDK 能力、加更聪明的上下文接线,或收紧改代码与验证之间的循环。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7797 个插件 →