返回目录
模型与 MCP 插件

dsh-ops-conventions

HeliosTangDev/dsh-ops-conventions

在动手前确定性注入操作约定(配合 OpenViking 技能使用),闲聊零成本

Stars
0
Forks
0
Issues
0
更新
5 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:HeliosTangDev/dsh-ops-conventions

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-ops-conventions(操作约定门铃)

在 AI 动手前把「你的操作约定清单」确定性地注入一次,并可选地硬拦截写操作,解决「约定记了,但干活时不提就不用」的问题。

插件本身不含任何个人约定:它只做「提醒 + 拦截 + 配置」。规则内容全部来自你自己的 INDEX.md(以及可选的补充文件)。

它做什么

  • 注入门铃:每个会话、每个约定版本注入一次,内容 = read <你的 INDEX.md> 并执行清单 + 可选补充文本;约 1 行,不改 VERSION 不会重复刷屏。
  • 版本变化再提醒:改约定目录里的 VERSION 文件后,下一轮(任何轮次)会重新注入。
  • 可选硬拦截:本会话还没 read 过 INDEX.md 时,拒绝写类工具(write/edit/…,可加 pwsh/bash/cmd 等);读过后本会话放行。
  • 可选待办门:配置 todoFile 后,还要求先跑一次 todoCheckCmd 校验器(防止报过时待办)。
  • 可选维护报告摘要:配置 maintReport 后,报告里有 Issues 就注入一条摘要。
  • 可选结构门:配置 structGates 后,写某个区域前必须先跑该区域的结构检查器。
  • 注入日志:每次注入/拦截都写日志,生效与否可核对。

安装

方式一:安装脚本(推荐)

git clone https://github.com/HeliosTangDev/dsh-ops-conventions.git
cd dsh-ops-conventions
node install.mjs                                  # 默认装到 ~/.dsh/profiles/desktop
node install.mjs /path/to/profile                 # 指定 profile
node install.mjs /path/to/profile --uninstall     # 卸载

方式二:自己加依赖

在 profile 的 package.json 里加:

"dsh-ops-conventions": "https://github.com/HeliosTangDev/dsh-ops-conventions/releases/latest/download/dsh-ops-conventions.tgz"

然后在该 profile 目录执行 pnpm install,重启 DSH。

方式三:市场

在 dsh-m 市场里搜索 dsh-ops-conventions 安装。

配置

在 profile 的 cordis.patch.yml 里追加(所有字段都可选,不配也能用):

- id: dsh-ops-conventions
  name: "dsh-ops-conventions"
  config:
    enabled: true                            # 总开关:false = 保持加载但零行为(不做注入/拦截/扫描),改后重启
    skillsDir: "D:\\my-conventions"          # 你的约定目录(里面放 INDEX.md + VERSION)
    # bellExtra: "额外的提醒文本"              # 直接追加一行文本
    # bellExtraFile: "D:\\my-conventions\\BELL.txt"  # 或指向文件(每次注入现读,改文件不用重启)
    # enforce: false                          # 只提醒、不拦截
    # blockedTools: ["write","edit","multi_edit","apply_patch","notebook_edit","pwsh","bash"]
    # todoFile: "D:\\my-work\\tasks\\OPEN.md"
    # todoCheckCmd: "powershell -NoProfile -ExecutionPolicy Bypass -File D:\\tools\\todo_check.ps1"
    # maintReport: "D:\\my-work\\tasks\\MAINT-LATEST.md"
    # structGates:
    #   - id: docs
    #     pathRe: "docs[/\\\\]"               # 命中这些路径时……
    #     checkRe: "docs_check\\.py"          # 这条命令就是该门检查器
    #     checker: "python D:\\tools\\docs_check.py"
    # 可选:现场状态行(宿主版本 / 维护报告 / 待办条数),默认关闭
    # status: true
    # statusTodoJson: "D:\\my-work\\todo.json"       # 读条目数用
    # hostVersionFile: "D:\\tools\\host_version.txt" # 宿主版本缓存(由你自己的脚本写)
    # asarCandidates: ["C:/apps/DSH/resources/app.asar"]
    # 可选:只读状态工具 ops_status(agent 可直接调用查看状态),默认关闭
    # statusTool: true
    # memoryDir: "D:\\my-memory\\memories"           # 统计记忆库 .md 数量与最近更新时间
    # todoLastFile: "D:\\my-work\\todo_last.txt"     # 上次校验器输出(可选)
    # 可选:版本引用核对(上一条回复写了非现场版本时警告),默认关闭
    # versionWarning: true
    # versionWarnFile: "D:\\my-work\\VERSION-WARN.md"
    # installedProfileDirs: ["C:/Users/me/.dsh/profiles/desktop"]
    # 可选:回复合规扫描(在下一轮检查上一条回复,命中注入警告并落文件),默认关闭
    # replyWarnFile: "D:\\my-work\\VERSION-WARN.md"
    # replyChecks:
    #   - id: no-next-time
    #     pattern: "下次注意"
    #     message: "不许用「下次注意」结案"
    #   - id: status-needs-time        # pattern 命中后,require 不命中才算违规
    #     pattern: "bell=v\\d+"
    #     require: "@\\d{1,2}:\\d{2}"
    #     message: "报状态要带命令、采样时间与数据年龄"
    # replyCheckBlock: true           # 违规后本轮拒绝写类工具(连续两轮自动解除)
    # 可选:窄工具 ops_run(只跑白名单里的脚本),默认关闭
    # narrowTool: true
    # narrowConfigFile: "D:\\my-work\\tools-run.json"  # 白名单文件,改它不用重启
    # narrowRoot: "D:\\my-work\\tools"                 # 白名单文件没写 rootDir 时的兜底根目录
  disabled: false

窄工具(ops_run,默认关闭)

只解决一件事:让 agent 在不放开任意执行的前提下,跑你指定的那几个脚本。

  • 调用方只能给 id 和参数;路径、cwd、解释器全部来自白名单文件,不接受任意 path/args/cwd。
  • 参数必须逐项命中该条目的 allowedArgs(字面量白名单,不做通配);未知 id / 未授权参数直接拒。
  • 执行永远 shell: false,cwd 固定为 rootDir,有 timeoutMs 与 maxOutputBytes,超时/截断如实上报。
  • 每次调用写一行审计到插件日志(narrow run id=… exit=… timeout=… duration=…)。

白名单文件格式(仓库里 tools-run.example.json 可照抄):

{
  "rootDir": "D:\\my-work\\tools",
  "scripts": [
    {
      "id": "todo-check",
      "path": "D:\\my-work\\tools\\todo_check.ps1",
      "launcher": ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File"],
      "allowedArgs": ["-Json"],
      "timeoutMs": 60000,
      "maxOutputBytes": 20000
    }
  ]
}

约束:path 必须是绝对路径、不得含 ..、必须落在 rootDir 之内;launcher 是固定前缀(跑 .ps1 常用上面那串),不会拼进任何调用方参数。不要把解释器、路径或 cwd 做成可传参——那样等于通用执行器,一个提示注入就能当后门。

最小约定目录

D:\my-conventions\
  INDEX.md     # 你的清单入口(写清“做什么事读哪份清单”)
  VERSION      # 一个数字;改它 = 让门铃重新注入

INDEX.md 示例:

# 操作约定索引

| 要做的事 | 读这份 |
|---|---|
| 写/改脚本 | ops-scripts/SKILL.md |
| 改完验证 | ops-check/SKILL.md |

不配置会怎样

  • 使用插件包自带的 skills/ 示例清单(会提示你去换成自己的目录);
  • 只拦截 write/edit/multi_edit/apply_patch/notebook_edit;
  • 其余可选功能(待办门/维护摘要/结构门)全部关闭。

验证生效

Get-Content "$env:USERPROFILE\.dsh\ops-conventions\ops-conventions.log" -Tail 5

应看到 plugin loaded skillsDir=...、inject vN chars=...;被拦截时应看到 guard deny ...。

卸载

node install.mjs --uninstall

或从 profile package.json 删除依赖、node_modules/dsh-ops-conventions,并删掉 cordis.patch.yml 里对应条目,然后重启。

边界

  • 这是「提醒执行器」,不是安全边界:它可以挡住误操作,但不能保证模型一定执行清单。
  • 注入/拦截都在本机,不联网、不收集数据。
  • 适配 DSH 0.2.x(Node 22 / 24),MIT 许可。

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。