前言¶
在 DeepSeek Harness(DSH)里跑智能体时,项目约定通常写在 AGENTS.md 或 CLAUDE.md 里,DSH 会加载这些文件。但很多仓库里还有另一套规则:有人加了 .cursor/rules/testing.mdc,有人维护 .github/copilot-instructions.md,某段时间试过 Windsurf 时留下了 .windsurfrules。这些文件对各自工具有意义,DSH 默认不会读,于是模型可能不知道「我们用 Vitest 不用 Jest」或「不要改旧 migration」,尽管规则已经写在仓库里。
下面介绍社区插件 dsh-load-agent-rules(维护者 acus9345):它扫描这些常见 AI 工具的规则文件,按各工具原本的语义交给模型,无需你手工转换或复制。
这是什么¶
dsh-load-agent-rules 是 DeepSeek Harness 插件,分类上属于模型推理相关能力:在会话中把 Cursor、GitHub Copilot、Windsurf、Cline、Kiro、Roo Code、Gemini CLI、JetBrains Junie 等工具使用的规则文件发现并注入上下文。插件在 SkillHub 目录 与 GitHub 分发,许可证为 MIT,当前包版本为 0.2.3(以仓库 package.json 为准)。
会读取哪些文件¶
插件按工具约定扫描路径,嵌套目录也会处理。下表来自官方 README。
| 工具 | 规则文件 |
|---|---|
| Cursor | .cursor/rules/**/*.mdc、.cursorrules |
| GitHub Copilot | .github/copilot-instructions.md、.github/instructions/*.instructions.md |
| Windsurf | .windsurf/rules/*.md、.windsurfrules |
| Cline | .clinerules(文件或目录) |
| Kiro | .kiro/steering/*.md |
| Roo Code | .roo/rules/*、.roorules |
| Gemini CLI | GEMINI.md |
| JetBrains Junie | .junie/guidelines.md |
同一内容常以不同文件名或 symlink 重复出现;插件会去重,并与 DSH 已加载的 AGENTS.md、CLAUDE.md 比对,去掉完全相同的内容。
规则如何进入模型上下文¶
各工具对「何时生效」的定义不同,插件尽量保留原意,而不是把所有规则一次性塞进 prompt。
始终生效的规则 在会话开始时写入上下文一次。包括 Cursor 的 alwaysApply: true、Copilot 主说明文件、Windsurf 的 always_on、Kiro 的 inclusion: always,以及 .cursorrules 这类纯文本文件。会话中若规则文件变更,或上下文压缩导致规则丢失,会再次发送。
按文件匹配的规则 在智能体首次读或改匹配路径的文件时附加,只附加一次,不会在每次触碰文件时重复注入。例如 Cursor 的 globs: "*.tsx"、Copilot 的 applyTo: "src/db/**"、Kiro 的 fileMatch、Windsurf 的 glob。位于 packages/web/.cursor/rules/ 下的规则仅在该子树内生效。
仅带描述、需模型自行判断的规则(如 Cursor 的 agent requested、Windsurf 的 model_decision)会以名称和描述列出;模型可通过 project_rule 工具在认为相关时打开。仅手动触发的规则也会出现在该列表中。
首次请求中,上下文大致会包含已加载的 always-on 规则片段,并提示还有更多文件级规则与可按需读取的条目,例如:
These are the project rules written for this repository. Follow them like the rest of your instructions.
<rule name=".cursor/rules/style.mdc">
Use tabs for indentation. Prefer named exports.
</rule>
More project rules are available. File-scoped rules are added automatically the first time you read or edit a matching file.
Read any of them with the `project_rule` tool when it is relevant to your task:
- .cursor/rules/react.mdc (applies to *.tsx): React conventions
- .github/instructions/db.instructions.md: Database migration conventions
安装与启用¶
DSH 按 profile 维护插件列表;你用的每种运行方式都要单独安装。官方安装命令如下(web 对应 dsh web 的浏览器界面):
dsh plugin --profile web add dsh-load-agent-rules
若用脚本或 CI 跑 DSH,将 web 换成 headless;若通过编辑器集成使用,换成 acp。安装后在下一次会话生效。移除命令:
dsh plugin --profile web remove dsh-load-agent-rules
本地调试插件时,README 说明可先构建 tarball 再安装(示例包名为 dsh-load-agent-rules-0.2.0.tgz,版本以你 npm pack 产出为准):
git clone https://github.com/acus9345/dsh-load-agent-rules
cd dsh-load-agent-rules
npm install
npm pack
dsh plugin --profile web add ./dsh-load-agent-rules-0.2.0.tgz
配置¶
可在 DSH 侧栏 Plugins 中点开 dsh-load-agent-rules,修改后 Save;除 toolName 外多数项在下一次 tool call 生效,toolName 变更需重启。
也可在 ~/.dsh/profiles/<profile>/cordis.patch.yml,或全局 ~/.dsh/cordis.patch.yml 中增加片段;未写的键保持默认:
- id: load-agent-rules
config:
sources: [cursor, copilot, windsurf, cline, kiro, roo, gemini, junie] # drop any you don't want
maxBaselineBytes: 48000 # budget for always-on rules; the rest are listed instead
maxAttachBytes: 24000 # budget for rules attached on one file touch
maxFileBytes: 200000 # skip rule files bigger than this
toolName: project_rule # '' to not register the tool
touchTools: [read, write, edit, str_replace_editor]
maxBaselineBytes 控制 always-on 规则的字节预算;超出部分不会静默丢弃,而是以列表形式提示,由模型通过工具读取。单文件超过 maxFileBytes 的规则会被跳过。
适用场景与注意¶
适合已经在仓库里为 Cursor、Copilot、Windsurf 等维护规则、又希望在 DSH 里复用同一套约定的团队。插件不替代 AGENTS.md / CLAUDE.md,而是补齐 DSH 默认不扫描的路径。
DSH 生态强调「一切皆插件」;SkillHub 为社区目录,与 DeepSeek / 幻方无官方从属关系。插件以当前 DSH 进程权限读取仓库与配置,安装前建议查看 源码与 MIT 许可证,自行评估是否纳入工作流。问题与建议可在 GitHub Issues 反馈。
结尾¶
经过上面的步骤,DSH 可以直接沿用仓库里为其他 AI 编码工具写好的规则,并按 glob、always-on 等语义注入上下文。dsh-load-agent-rules 减少重复维护多套说明的成本。目录页:https://www.skillhub.cn/plugins/acus9345/dsh-load-agent-rules;仓库:https://github.com/acus9345/dsh-load-agent-rules。