omdsh-dev/dsh-tool-regex
DSH 正则工具插件:测试匹配/提取捕获组/安全替换/静态解释正则(不执行代码),零依赖,注册 regex 工具
Project Overview项目介绍
This is a native DSH plugin that provides regex processing capabilities for DeepSeek Harness agents. It supports four core actions: test a regex pattern against input, find all matches with full capture group details, perform safe regex replacement, and statically explain a regex pattern without execution. The plugin can be installed directly from the public GitHub repository using the DSH CLI command dsh plugin --profile <profile> add github:omdsh-dev/dsh-tool-regex. You can also build it locally with npm pack to generate a tarball, then install the plugin via that local file.
The plugin is built with multiple layers of protection against ReDoS (regular expression denial of service) attacks. It runs matching operations in a worker thread with a hard 1000ms timeout, enforces size limits on input, pattern, replacement, and output, and the explain action never constructs a RegExp instance at all. It is intended for DSH agents that need to reliably work with regular expressions on untrusted input, avoiding the errors that come from calculating regex results manually and the overhead of spawning external bash processes.
This plugin has zero runtime dependencies and requires only a DSH 0.1.5-rc.1 or newer environment, which provides the required peer dependencies automatically. It is released under the permissive MIT open source license. After installation, you can verify the plugin is correctly registered by running dsh --profile <profile> --dump-config | grep tool-regex, and you can run a functional test with dsh run "use regex tool to check if d+ matches abc123". All operations enforce explicit size limits to prevent resource exhaustion, with clear error messages returned for any invalid input or out-of-bounds requests.
这是一款专为 DSH 开发的原生正则工具插件,提供正则测试匹配、提取捕获组、安全替换、静态解释四大核心功能。它的差异化能力是 explain 动作:可以静态解析正则结构并生成人类可读的解释,全程不执行正则匹配,天然免疫 ReDoS 灾难性回溯攻击。它解决了大语言模型手工计算正则结果错误率高、现有方案需要额外启动进程的开销问题。
面向需要使用正则处理文本的 DSH 代理场景,典型工作流是通过调用 regex 工具,传入动作类型、正则模式、目标文本等参数,获取结构化的 JSON 结果返回。它设置了多层 ReDoS 防线,包括 worker 硬超时、输入长度上限、资源大小限制,所有边界错误都被捕获并返回清晰提示,不会阻塞宿主进程。
本插件零额外运行时依赖,仅需要 DSH 0.1.5-rc.1 及以上版本环境,遵循 MIT 许可开源。可以通过 dsh plugin add 命令直接从 GitHub 仓库安装,也可以本地打包后通过 tarball 安装,安装后可以通过 dsh --dump-config 验证安装结果。各操作都有明确的大小限制,超出限制会直接拒绝,避免资源浪费。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-tool-regex(omdsh-dev/dsh-tool-regex)
仓库:https://github.com/omdsh-dev/dsh-tool-regex
本站详情页:https://www.yhbd.top/plugins/omdsh-dev-dsh-tool-regex/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 MIT · ⭐ 3 · 最近提交 2026-09-10 · 主语言 TypeScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- 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 github:omdsh-dev/dsh-tool-regex
把 omdsh-dev/dsh-tool-regex 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-tool-regex
DSH 正则工具插件 —— 测试匹配、提取捕获组、安全替换、静态解释正则含义(不执行任何代码)。零依赖、纯函数。
动机
模型经常需要验证用户给的 pattern、从日志/文本中提取字段、做文本替换。"心算"正则结果错误率极高,且无法给用户展示可验证的过程。现有替代是起 bash 进程跑 node -e 或 python——进程开销 + 模型现写脚本的正确性风险。内置 grep 只能做文件域搜索,无法对任意文本测试/提取/替换/解释。
本插件提供确定性正则工具,其中 explain 是差异化能力:静态解析 pattern 结构并给出人读解释,不执行匹配,天然免疫 ReDoS。
安全模型(ReDoS 多层防线)
JS 正则的灾难性回溯是真实威胁(如 (a+)+$ 配合超长输入)。防线:
- worker 硬超时:test/find/replace 在可终止的 worker 线程内同步执行,1,000ms 预算到期
worker.terminate()并返回regex: execution timed out——灾难性回溯不再能阻塞宿主进程(工具管道的timeoutMs对同步阻塞体是协作式,仅靠它不够;worker 内会再次执行全部上限校验) - 输入长度上限:64,000 字节(UTF-8)——超限在入口直接拒绝,不进入回溯
- 资源上限:pattern ≤ 16KB、replacement ≤ 16KB、输出 ≤ 1MB、匹配数 ≤ 1,000(limit 钳制)
- explain 零执行:只做静态 tokenizer,不构造
RegExp实例,任何 pattern 都即时返回
⚠️ 工具描述与 README 均明确警告模型:不要对不可信的大输入使用无锚点的嵌套量词 pattern(如
(a+)+、(.*)*)。
其余边界:无效 pattern 捕获 SyntaxError 报错(含位置信息);无效/重复 flag 逐字符校验;replace 使用 String.replace 字符串替换路径(JS 原生 $-语义,无 new Function、无 eval)。
工具声明
注册 regex 工具(@deepseek-ai/dsh-tool-regex,row id tool-regex),统一输出 JSON 文本字符串。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
action |
string | ✅ | test / find / replace / explain |
pattern |
string | ✅ | 正则(JavaScript 语法,不含外围 /);≤ 16KB |
input |
string | 待匹配文本(test/find/replace 必需);≤ 64KB | |
flags |
string | 如 "gi";支持 g i m s u y d v,需唯一且合法 |
|
replacement |
string | replace 的替换文本,支持 $1/$2/$<name>/$$;≤ 16KB |
|
limit |
integer | find 最大报告匹配数,默认 50,上限 1,000 |
Actions
| action | 功能 | 输出示例 |
|---|---|---|
test |
判断是否匹配(整串语义由模型自行用 ^...$ 表达) |
{"matched":true} |
find |
全部匹配:index / 完整匹配 / 编号捕获组 captures / 命名组 groups(无 g 自动补 g) |
[{"index":0,"match":"a@b","captures":["a","b"],"groups":{"name":"a"}}] |
replace |
全局安全替换($1/$<name>/$$),返回结果与替换次数 |
{"result":"world hello","replaced":1} |
explain |
静态解析 pattern → 人读节点序列(不执行匹配;节点数 ≤ 4,096) | [{"kind":"escape","text":"\\d","meaning":"A digit [0-9]"}] |
示例
regex { action: "find", pattern: "(\\w+)@(\\w+)", input: "a@b x c@d" }
→ [{"index":0,"match":"a@b","captures":["a","b"],"groups":null},{"index":6,"match":"c@d","captures":["c","d"],"groups":null}]
regex { action: "replace", pattern: "(\\w+) (\\w+)", input: "hello world", replacement: "$2 $1" }
→ {"result":"world hello","replaced":1}
regex { action: "explain", pattern: "\\d{4}-\\d{2}" }
→ [{"kind":"escape","text":"\\d","meaning":"A digit [0-9]"},{"kind":"quantifier","text":"{4}",...},...]
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
Minglink/dsh-infinite-gen-4
kenryu42/cc-safety-net
hyhmrright/brooks-lint
toby-bridges/api-relay-audit
hashgraph-online/hol-guard
SeaOf0/dsh-redteam-model
howmp/dsh-pentest
saya-ch/dsh-mobile