dsh-mask 0.2.23 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +0 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +0 -0
- package/README.en.md +433 -0
- package/README.es.md +433 -0
- package/README.hi.md +433 -0
- package/README.md +243 -206
- package/README.pt.md +433 -0
- package/SECURITY.md +0 -0
- package/THIRD_PARTY_NOTICES.md +0 -0
- package/cordis.patch.yml +0 -0
- package/index.mjs +0 -0
- package/lib/constants.mjs +0 -0
- package/lib/deliver.mjs +0 -0
- package/lib/domain.mjs +0 -0
- package/lib/errors.mjs +0 -0
- package/lib/gate.mjs +0 -0
- package/lib/mask.mjs +14 -5
- package/lib/sanitize.mjs +0 -0
- package/lib/store.mjs +0 -0
- package/lib/strip.mjs +0 -0
- package/package.json +51 -30
- package/types.d.ts +0 -0
- package/README-es.md +0 -380
- package/README-hi.md +0 -380
- package/README-pt.md +0 -380
- package/README-zh.md +0 -398
package/README.md
CHANGED
|
@@ -1,200 +1,204 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/hero-zh-dark-v3.webp">
|
|
5
|
+
<img src="docs/assets/hero-zh-light-v3.webp" width="100%" alt="dsh-mask:在个人数据抵达模型之前完成脱敏,原文永不进入会话日志">
|
|
6
|
+
</picture>
|
|
7
|
+
|
|
3
8
|
# dsh-mask
|
|
4
|
-
- **1024 store channel**: `npm i -g dsh1024` once, then `dsh1024 plugin --profile web add dsh-mask` (counts toward the [deepseek1024.com](https://deepseek1024.com) install ranking).
|
|
5
|
-
[](https://gitee.com/perrylink/dsh-mask)
|
|
6
|
-
[](https://dshfind.com/plugins/PerryLink/dsh-mask?ref=badge)
|
|
7
|
-
[](https://api.securityscorecards.dev/projects/github.com/PerryLink/dsh-mask)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
**在个人数据抵达模型之前完成脱敏——原文永不进入会话日志。**
|
|
11
|
+
|
|
12
|
+
面向 DeepSeek Harness 的纯主机端 PII 遮罩中间件:电话、邮箱、身份证、银行卡、密钥在模型边界变成占位符,恢复表只留在你自己的机器上。
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
[安装](#三步上手) · [配置](#配置) · [FAQ](#faq) · [简体中文](README.md) · [English](README.en.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
|
|
12
15
|
|
|
13
|
-
[](https://github.com/PerryLink/dsh-mask/actions)
|
|
19
|
-
[](https://github.com/PerryLink/dsh-mask/releases)
|
|
20
|
-
[](https://www.npmjs.com/package/dsh-mask)
|
|
21
|
-
[](https://www.npmjs.com/package/dsh-mask)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
[](#兼容性)
|
|
18
|
+
[](https://www.npmjs.com/package/dsh-mask)
|
|
19
|
+
[](https://github.com/PerryLink/dsh-mask/actions/workflows/ci.yml)
|
|
20
|
+
[](#兼容性)
|
|
22
21
|
|
|
23
|
-
[
|
|
22
|
+
[](https://github.com/PerryLink/dsh-mask/stargazers)
|
|
23
|
+
[](https://www.npmjs.com/package/dsh-mask)
|
|
24
|
+
[](https://dshfind.com/plugins/PerryLink/dsh-mask?ref=badge)
|
|
25
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/PerryLink/dsh-mask)
|
|
26
|
+
[](https://dsh.market/)
|
|
27
|
+
[](https://gitee.com/perrylink/dsh-mask)
|
|
24
28
|
|
|
25
29
|
```sh
|
|
26
30
|
dsh plugin --profile <name> add dsh-mask
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
|
|
30
33
|
</div>
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
**📖 Ecosystem knowledge base** — measured data, not marketing: [plugin development guide · plugin-selection data · maintenance criteria](https://perrylink.github.io/dsh-plugin-guide/).
|
|
35
|
+
<sub>社区插件,与 DeepSeek 官方无关。唯一仓库:<https://github.com/PerryLink/dsh-mask>(Gitee 为镜像)。</sub>
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
## Install & uninstall
|
|
37
|
+
## 它是什么
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
- **npm channel** (published releases): `dsh plugin --profile web add dsh-mask`.
|
|
41
|
-
- **tarball channel**: `pnpm pack` in this repo, then `dsh plugin --profile web add ./dsh-mask-<version>.tgz`.
|
|
42
|
-
- **uninstall**: `dsh plugin --profile web remove dsh-mask` (or remove the row from the profile patch).
|
|
39
|
+
发消息给模型之前,`dsh-mask` 先把里面的电话、邮箱、身份证、银行卡、密钥换成 `<PHONE_1>` 这样的占位符——模型看到的、会话日志记下的,都只有占位符。真正的原文只存在主机侧的恢复表里(内存 + 受控的 `dsh_mask` 存储域),随时可以调用 `/mask restore` 显式取回:原文以 `0600` 权限的文件交付,路径才进日志。纯正则、零依赖、无网络请求。
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
<picture>
|
|
42
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/dsh-mask-flow-v4-dark.svg">
|
|
43
|
+
<img src="docs/assets/dsh-mask-flow-v4-light.svg" width="100%" alt="dsh-mask 数据流:用户消息 → agent/pre-step 打码 → 模型 → /mask restore → 受控文件">
|
|
44
|
+
</picture>
|
|
45
45
|
|
|
46
|
-
##
|
|
46
|
+
## 三步上手
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
1. **安装**(三选一):
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
```sh
|
|
51
|
+
# git 通道(最新 main;等价于 git+https://github.com/PerryLink/dsh-mask.git)
|
|
52
|
+
dsh plugin --profile web add github:PerryLink/dsh-mask
|
|
53
|
+
# npm 通道(已发布版本)
|
|
54
|
+
dsh plugin --profile web add dsh-mask
|
|
55
|
+
# tarball 通道:本仓库 pnpm pack 后
|
|
56
|
+
dsh plugin --profile web add ./dsh-mask-<version>.tgz
|
|
57
|
+
```
|
|
51
58
|
|
|
59
|
+
无构建步骤——`index.mjs` 与 `lib/` 即发布产物。
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
2. **最小配置**(默认即可用;按需调整实体列表):
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
```yaml
|
|
64
|
+
- insert:
|
|
65
|
+
- id: mask
|
|
66
|
+
name: dsh-mask
|
|
67
|
+
config:
|
|
68
|
+
entities: [phone, email, id-card, bank-card, key]
|
|
69
|
+
```
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
3. **验证已生效**:
|
|
58
72
|
|
|
59
|
-
|
|
73
|
+
```sh
|
|
74
|
+
dsh --profile web --dump-config | grep -A2 'id: mask'
|
|
75
|
+
```
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
```
|
|
78
|
+
> /mask status
|
|
79
|
+
> /mask restore <PHONE_1>
|
|
80
|
+
mask: restored 1 placeholder(s): <PHONE_1>
|
|
81
|
+
file: /tmp/dsh-mask-restore/restore-1f0c….txt (mode 0600, one file per session)
|
|
82
|
+
```
|
|
62
83
|
|
|
84
|
+
**卸载**:`dsh plugin --profile web remove dsh-mask`(或从 profile patch 删掉该行)。
|
|
63
85
|
|
|
86
|
+
> `dsh-mask` 不自带 storage 栈。已组合该栈的 profile(`web` profile 通过 `@deepseek-ai/dsh-web-app` 提供)自带 `storageDomain`,持久化开箱即用;未组合 storage 的 bare profile 仍可正常挂载与遮罩,但恢复表仅存内存(重启丢失)——请在 profile patch 中组合 storage 栈,或将 `persistRestoreTable` 设为 `false`。
|
|
64
87
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-

|
|
68
|
-
|
|
69
|
-
108 synthetic samples (60 positive, 48 negative) · from benchmark/RESULTS.md
|
|
88
|
+
<details>
|
|
89
|
+
<summary>从 DSH Desktop 市场安装</summary>
|
|
70
90
|
|
|
71
|
-
|
|
91
|
+
所有 PerryLink 插件均可在 DSH Desktop 内置市场中浏览:**市场 → 来源 → 添加来源 → 粘贴** `https://perrylink-dsh-catalog.perrylink.workers.dev/catalog-source.json` **→ 选中**。安装仍需通过市场的 npm 身份校验与你的确认。
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|---|---|
|
|
75
|
-
| Harness | DeepSeek Harness `dsh-v0.2.1-alpha.1` (adapted 2026-09-18): the session envelope keeps its ignorable field for stored-log read compatibility only - Session.append still cannot stamp it, so audit-gate behavior is unchanged. Verified 2026-09-18 against the dsh-v0.1.7-alpha.1 master checkout (full gate chain + profile install smoke). |
|
|
76
|
-
| Node | `^22.19.0 \|\| >=24.0.0` |
|
|
77
|
-
| Platforms | Anywhere DSH runs (pure host, zero-dependency regex; no browser half) |
|
|
78
|
-
| Model | Text models fully supported; no extra model capability required |
|
|
93
|
+
</details>
|
|
79
94
|
|
|
80
|
-
##
|
|
95
|
+
## 核心能力
|
|
81
96
|
|
|
82
|
-
`dsh-mask`
|
|
97
|
+
`dsh-mask` 在**模型边界**匿名化个人数据——消息进入模型之前——并维护一张恢复表,让占位符可逆:
|
|
83
98
|
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
- **`/mask`
|
|
88
|
-
- **`mask_test`
|
|
99
|
+
- **请求前遮罩** —— 重写 `agent/pre-step` 消息,使电话、邮箱、身份证、银行卡、密钥(默认开启)与 IP(可选)变成 `<PHONE_1>` 之类的占位符。被遮罩的文本才是落盘并发送给模型的内容。
|
|
100
|
+
- **恢复表** —— `占位符 → 原文` 映射只存内存与受控 storage domain(`dsh_mask`);原文绝不进会话日志。
|
|
101
|
+
- **审计不含明文** —— `mask/applied` 会话事件只记「替换了 N 处 + 类型分布」,不记原文与映射。
|
|
102
|
+
- **`/mask` 命令** —— `status`(计数 + 分布)、`on`/`off`(运行时开关)、`restore <text>`(还原占位符,原文交付为文件而非可记录的文本)、`help`。
|
|
103
|
+
- **`mask_test` 工具** —— 试跑一段文本看替换效果;绝不回显原文。
|
|
89
104
|
|
|
90
105
|
```text
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Quick start
|
|
97
|
-
|
|
98
|
-
```sh
|
|
99
|
-
dsh plugin --profile web add github:PerryLink/dsh-mask
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
```sh
|
|
103
|
-
# 1. install the bundle into your profile
|
|
104
|
-
dsh plugin --profile web add github:PerryLink/dsh-mask
|
|
105
|
-
|
|
106
|
-
# or from npm (published releases)
|
|
107
|
-
dsh plugin --profile web add dsh-mask
|
|
108
|
-
|
|
109
|
-
# 2. verify the row mounts
|
|
110
|
-
dsh --profile web --dump-config | grep -A2 'id: mask'
|
|
106
|
+
用户消息 ──agent/pre-step──▶ 占位符 ──模型──▶ 占位符 ──restore──▶ 受控文件
|
|
107
|
+
▲ │
|
|
108
|
+
└──── 恢复表(内存 + dsh_mask)──────────┘
|
|
111
109
|
```
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
### 命令与工具面
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
> /mask status
|
|
125
|
-
> /mask restore <PHONE_1>
|
|
126
|
-
mask: restored 1 placeholder(s): <PHONE_1>
|
|
127
|
-
file: /tmp/dsh-mask-restore/restore-1f0c….txt (mode 0600, one file per session)
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Examples
|
|
131
|
-
|
|
132
|
-
These are the plugin's real entry points; install once, then call one.
|
|
133
|
-
|
|
134
|
-
#### Detailed example
|
|
113
|
+
| 表面 | 是否回显原文 | 说明 |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `agent/pre-step` 遮罩 | 永不 | 把消息重写为占位符后再落盘/送模型 |
|
|
116
|
+
| `tools/post-execute` 遮罩 | 永不 | 把工具结果文本重写为占位符后再落盘/回喂模型(`scope: tools`) |
|
|
117
|
+
| `/mask status` | 永不 | 启用状态、替换总数、类型分布 |
|
|
118
|
+
| `/mask on` / `/mask off` | 永不 | 运行时开关(重启回到 `config.enabled`) |
|
|
119
|
+
| `/mask restore <text>` | 是(显式) | 把占位符还原为本会话存储的值并写进受控文件(每会话一个,mode `0600`);结果文本与会话日志只带该路径与占位符名 |
|
|
120
|
+
| `mask_test` | 永不 | 遮罩一段文本并报告占位符结果 + 计数 |
|
|
135
121
|
|
|
136
|
-
|
|
122
|
+
### 示例
|
|
137
123
|
|
|
138
|
-
|
|
139
|
-
mask_test
|
|
140
|
-
~~~
|
|
124
|
+
以下为插件真实入口;安装后调用一个即可。
|
|
141
125
|
|
|
142
|
-
|
|
126
|
+
**详细示例** — 命令 `mask_test`,输入:
|
|
143
127
|
|
|
144
|
-
|
|
128
|
+
```json
|
|
145
129
|
{"text":"电话 13812345678"}
|
|
146
|
-
|
|
130
|
+
```
|
|
147
131
|
|
|
148
|
-
|
|
132
|
+
输出:
|
|
149
133
|
|
|
150
|
-
|
|
134
|
+
```text
|
|
151
135
|
mask_test: replaced 1 PII value(s) (PHONE=1)
|
|
152
136
|
masked:
|
|
153
137
|
电话 <PHONE_1>
|
|
154
|
-
|
|
138
|
+
```
|
|
155
139
|
|
|
156
140
|
*Observed from `plugins/dsh-mask/index.mjs:243-250; test/index.test.mjs:306-315`*
|
|
157
141
|
|
|
158
|
-
|
|
142
|
+
**失败分支** — 输入:
|
|
159
143
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
~~~text
|
|
144
|
+
```text
|
|
163
145
|
/mask restore <PHONE_1> with restoreDir=/tmp/dsh-mask-probe-not-a-dir (a regular file)
|
|
164
|
-
|
|
146
|
+
```
|
|
165
147
|
|
|
166
|
-
|
|
148
|
+
输出:
|
|
167
149
|
|
|
168
|
-
|
|
150
|
+
```text
|
|
169
151
|
mask: restore failed: EEXIST: file already exists, mkdir '/tmp/dsh-mask-probe-not-a-dir'
|
|
170
|
-
|
|
152
|
+
```
|
|
171
153
|
|
|
172
154
|
*Observed from `plugins/dsh-mask/index.mjs:501-506; plugins/dsh-mask/lib/deliver.mjs:89-97; plugins/dsh-mask/test/index.test.mjs:278-290`*
|
|
173
155
|
|
|
174
|
-
|
|
156
|
+
**简短示例**:`mask_test` · `/mask restore <text>`
|
|
175
157
|
|
|
176
|
-
|
|
177
|
-
- `/mask restore <text>`
|
|
158
|
+
## 实测数据
|
|
178
159
|
|
|
179
|
-
|
|
160
|
+
<picture>
|
|
161
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/dsh-mask-evidence-v3-zh-dark.webp">
|
|
162
|
+
<img src="docs/assets/dsh-mask-evidence-v3-zh-light.webp" width="100%" alt="dsh-mask 分类型 F1 条形图:phone、email、id-card、bank-card、key 均为 1.000,ip(可选)为 0.833">
|
|
163
|
+
</picture>
|
|
180
164
|
|
|
181
|
-
|
|
165
|
+
108 个合成样本(60 正 / 48 负)的逐类 P/R/F1 基准见 [`benchmark/RESULTS.md`](benchmark/RESULTS.md),可用 `node benchmark/run.mjs` 复现(无需构建、零新依赖)。该基准只覆盖正则路径:仅形状校验、不验校验位,`ip` 正则按范围宽松匹配(因此有误报),`person`/`address` 不在测量范围。
|
|
182
166
|
|
|
183
|
-
|
|
167
|
+
## 配置
|
|
168
|
+
|
|
169
|
+
所有可调项都是 Schemastery `Config` 字段(可从 cordis.yml 覆盖)。按 id 覆盖会替换整行——请重述所有需要的键。`cordis.patch.yml` 逐键内联注释。
|
|
170
|
+
|
|
171
|
+
最常用键:
|
|
172
|
+
|
|
173
|
+
| 键 | 默认值 | 含义 |
|
|
184
174
|
|---|---|---|
|
|
185
|
-
| `enabled` | `true` |
|
|
186
|
-
| `mode` | `regex` |
|
|
187
|
-
| `entities` | `[phone, email, id-card, bank-card, key]` |
|
|
188
|
-
| `scope` | `[messages]` |
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
|
196
|
-
|
|
197
|
-
|
|
175
|
+
| `enabled` | `true` | 总开关;`false` 卸载监听器、`/mask` 命令与 `mask_test` 工具 |
|
|
176
|
+
| `mode` | `regex` | 检测模式;只有 `regex` 实现(`regex+ner` 姓名/地址识别预留并响亮失败) |
|
|
177
|
+
| `entities` | `[phone, email, id-card, bank-card, key]` | 要遮罩的 PII 类型;`ip` 也支持正则(可选),`person`/`address` 需要 NER |
|
|
178
|
+
| `scope` | `[messages]` | 遮罩作用域;`messages` 遮罩 agent/pre-step 消息,`tools` 遮罩 tools/post-execute 工具结果。可为字符串或数组,如 `[messages, tools]` |
|
|
179
|
+
| `persistRestoreTable` | `true` | 把恢复表持久化到受控 `dsh_mask` 领域(`false` = 仅内存) |
|
|
180
|
+
| `restoreDir` | `''` | `/mask restore` 交付原文的位置。空 = `os.tmpdir()/dsh-mask-restore`;相对值相对宿主进程 cwd 解析。目录按 `0700` 创建、文件按 `0600` 写入,每会话一个文件 |
|
|
181
|
+
|
|
182
|
+
<details>
|
|
183
|
+
<summary>完整配置表(11 个键)</summary>
|
|
184
|
+
|
|
185
|
+
| 键 | 默认值 | 含义 |
|
|
186
|
+
|---|---|---|
|
|
187
|
+
| `enabled` | `true` | 总开关;`false` 卸载监听器、`/mask` 命令与 `mask_test` 工具 |
|
|
188
|
+
| `mode` | `regex` | 检测模式;只有 `regex` 实现(`regex+ner` 姓名/地址识别预留并响亮失败) |
|
|
189
|
+
| `entities` | `[phone, email, id-card, bank-card, key]` | 要遮罩的 PII 类型;`ip` 也支持正则(可选),`person`/`address` 需要 NER |
|
|
190
|
+
| `scope` | `[messages]` | 遮罩作用域;`messages` 遮罩 agent/pre-step 消息,`tools` 遮罩 tools/post-execute 工具结果。可为字符串或数组,如 `[messages, tools]` |
|
|
191
|
+
| `registerCommand` | `true` | 注册 `/mask` 命令 |
|
|
192
|
+
| `registerTools` | `true` | tools 服务存在时注册 `mask_test` 工具 |
|
|
193
|
+
| `persistRestoreTable` | `true` | 把恢复表持久化到受控 `dsh_mask` 领域(`false` = 仅内存) |
|
|
194
|
+
| `maxRestoreEntriesPerSession` | `500` | 每会话恢复条目上限(最旧先逐出) |
|
|
195
|
+
| `maxSessions` | `1000` | 内存会话上限(LRU 逐出,映射按需回载) |
|
|
196
|
+
| `maskClientEnabled` | `false` | 浏览器半「显示原文」气泡的功能开关(防御性,默认关闭,直到线上 slot 目录验证目标 slot)。该键已由 schema 声明并校验,但尚无运行时代码读取它——在浏览器半交付前它不改变任何行为 |
|
|
197
|
+
| `restoreDir` | `''` | `/mask restore` 交付原文的位置。空 = `os.tmpdir()/dsh-mask-restore`;相对值相对宿主进程 cwd 解析。目录按 `0700` 创建、文件按 `0600` 写入,每会话一个文件 |
|
|
198
|
+
|
|
199
|
+
</details>
|
|
200
|
+
|
|
201
|
+
profile patch 覆盖示例:
|
|
198
202
|
|
|
199
203
|
```yaml
|
|
200
204
|
- insert:
|
|
@@ -206,100 +210,131 @@ Example override in your profile patch:
|
|
|
206
210
|
registerCommand: true
|
|
207
211
|
```
|
|
208
212
|
|
|
209
|
-
##
|
|
213
|
+
## FAQ
|
|
210
214
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
| `agent/pre-step` masking | never | Rewrites messages to placeholders before they are logged or sent to the model |
|
|
214
|
-
| `tools/post-execute` masking | never | Rewrites tool-result text blocks to placeholders before they are logged or fed back to the model (scope: `tools`) |
|
|
215
|
-
| `/mask status` | never | Enabled state, total replaced, type distribution |
|
|
216
|
-
| `/mask on` / `/mask off` | never | Runtime toggle (resets to `config.enabled` on restart) |
|
|
217
|
-
| `/mask restore <text>` | yes (explicit) | Unmaps placeholders back to the values stored for this session and writes them to a controlled file (one per session, mode `0600`); the result text and the session log carry only that path and the placeholder names |
|
|
218
|
-
| `mask_test` | never | Masks a snippet and reports the placeholder result + counts |
|
|
215
|
+
<details>
|
|
216
|
+
<summary>原文到底存在哪?会不会被写进日志?</summary>
|
|
219
217
|
|
|
220
|
-
|
|
218
|
+
`占位符 → 原文` 恢复表只存内存;`persistRestoreTable: true` 时另存受控 `dsh_mask` 存储域——**绝不写会话日志**。唯一另一份原文副本是显式 `/mask restore` 写下的交付文件(`restoreDir`,mode `0600`,每会话一个,下次还原覆盖);没有任何路径会隐式把原文写盘。
|
|
221
219
|
|
|
222
|
-
|
|
223
|
-
- **Data**: the `placeholder → original` restore table lives in memory and, when `persistRestoreTable: true`, in the controlled `dsh_mask` storage domain — it is never written to the session log. The only other plaintext copy is the delivery file an explicit `/mask restore` writes under `restoreDir` (mode `0600`, one file per session, overwritten by the next restore); nothing writes plaintext to disk implicitly.
|
|
224
|
-
- **Session log**: `mask/applied` is declared in `types.d.ts` and appended only when the host records the type (see Known limitations). Its payload is counts + type distribution only.
|
|
220
|
+
</details>
|
|
225
221
|
|
|
226
|
-
|
|
222
|
+
<details>
|
|
223
|
+
<summary>宿主不支持时会怎样?会静默失效吗?</summary>
|
|
227
224
|
|
|
228
|
-
|
|
229
|
-
- **Sanitize before display/log.** `lib/sanitize.mjs` redacts PII, secrets, and URL credentials before any text reaches the model or the log; `mask_test`, `/mask status`, and every `/mask` error path never echo originals.
|
|
230
|
-
- **Controlled restore.** `/mask restore` is the single explicit reveal surface, and it only reads the mapping for the active session. Failure fails closed: if the delivery file cannot be written, the command reports an error and never falls back to echoing the plaintext.
|
|
231
|
-
- **Fail closed.** Unimplemented `mode` (`regex+ner`), unknown `scope` values, NER-only entities, and out-of-bounds numbers all fail loudly at load.
|
|
232
|
-
- **Registrations are effects.** The listener, command, tool, and storage-domain close are all Cordis effects — stop/hot-reload removes them.
|
|
225
|
+
不会静默。裸 profile 无 storage 栈时插件照常挂载与遮罩,恢复表降级为仅内存并给一次性告警;宿主不收录 `mask/applied` 事件类型时,审计 append 被跳过、每个会话首次拒绝打一条可见告警;`mode: regex+ner`、NER 实体、未知 `scope`、越界数值都在加载期响亮失败。
|
|
233
226
|
|
|
234
|
-
|
|
227
|
+
</details>
|
|
235
228
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
- **Display-layer restore needs a client half.** Masking is fully host-side, but transparently un-masking the assistant bubbles in the client UI is a browser-half feature this pure-host form does not ship. The host side keeps the restore table and the exported `RestoreStore` seam (its methods take a session id), so a future client half would reach them through a host remote rather than directly; today the unmasking surface is the `/mask restore <text>` command, which delivers the plaintext as a file because a command result is logged verbatim (see Security boundaries), and the `maskClientEnabled` key is validated but read by no runtime code yet.
|
|
239
|
-
- **No no-argument `/mask restore`.** Restoring *every* placeholder of the most recent assistant message is not offered, and the command says so when invoked without text. Two host facts block it: the restore table is a flat per-session `{placeholder: original}` map with no per-message index, so that message has to be located in the session event log; and the host deprecated `Session.snapshotEvents()` / `eventAt()` / `ownEvents()` with an explicit "new calls are prohibited", leaving an incremental projection as the only sanctioned route — which this plugin's declared host corridor (`>=0.1.2-rc.1`) cannot rely on. Placeholders keep working one at a time instead: `/mask restore <PHONE_1>`.
|
|
240
|
-
- **Session events on `0.1.7-rc.2`.** The harness records 59 session event types and none of them is `mask/*`; its `Session.append` also cannot stamp the `ignorable` envelope, so the session-log audit appends are skipped and sessions keep loading. The gate is not silent about it: the first refusal per session logs one visible warning naming the skipped type and this documented limitation. The plugin enables the append automatically once a host records the type or supports the `ignorable` envelope.
|
|
229
|
+
<details>
|
|
230
|
+
<summary>会和其他插件抢命令名、事件或 slot 吗?</summary>
|
|
241
231
|
|
|
242
|
-
|
|
232
|
+
不会。工具全部带命名空间、不提供任何服务键、不注册客户端 slot、不注册 `webServer` 前缀、不改全局对象;共享事件一律经 `next()` 委托,绝不短路链条。逐条论证见「与其他 DSH 插件的互操作性」。
|
|
243
233
|
|
|
244
|
-
|
|
245
|
-
pnpm install # node ^22.19 || >=24
|
|
246
|
-
pnpm run typecheck && pnpm run typecheck:ci # two rulers: checkout face (guarded; unverifiable without the checkout) + published-line face
|
|
247
|
-
pnpm test # node --test
|
|
248
|
-
pnpm run verify:self-contained # dependency specs resolve from the registry
|
|
249
|
-
pnpm run verify:artifacts # shipped files present + index.mjs importable
|
|
250
|
-
pnpm run check:readmes # five-language README consistency
|
|
251
|
-
pnpm pack # the published tarball
|
|
252
|
-
```
|
|
234
|
+
</details>
|
|
253
235
|
|
|
254
|
-
|
|
236
|
+
<details>
|
|
237
|
+
<summary>性能开销多大?</summary>
|
|
238
|
+
|
|
239
|
+
检测器是零依赖纯正则、无网络请求、无模型调用,挂在 `agent/pre-step` 上同步重写消息文本。准确性实测见「实测数据」一节(108 样本,Macro F1 0.972)。
|
|
240
|
+
|
|
241
|
+
</details>
|
|
255
242
|
|
|
256
|
-
|
|
243
|
+
## 安全边界
|
|
257
244
|
|
|
258
|
-
|
|
245
|
+
- **原文绝不进会话日志。** 落盘并送模型的是遮罩(占位符)形式,因此模型可见内容可自日志以占位符形式重建;原文留在恢复表。还原方向同理:宿主把命令结果文本**原样**写进日志、并从那一条事件渲染用户可见输出,所以 `/mask restore` 把原文写进受控文件,只回路径。
|
|
246
|
+
- **展示/日志前脱敏。** `lib/sanitize.mjs` 在文本进入模型或日志前打码 PII、密钥与 URL 凭据;`mask_test`、`/mask status` 与所有 `/mask` 错误路径永不回显原文。
|
|
247
|
+
- **受控还原。** `/mask restore` 是唯一的显式还原面,且只读当前会话的映射。失败关闭:交付文件写不出时命令报错,绝不回退成回显原文。
|
|
248
|
+
- **失败关闭。** 未实现的 `mode`(`regex+ner`)、未知 `scope` 值、NER 实体与越界数值均在加载期响亮失败。
|
|
249
|
+
- **注册即 effect。** 监听器、命令、工具与领域关闭都是 Cordis effect——停止/热重载即可撤销。
|
|
259
250
|
|
|
260
|
-
##
|
|
251
|
+
## 权限与数据
|
|
261
252
|
|
|
262
|
-
|
|
253
|
+
- **权限**:`dsh-mask` 不做网络请求、不存凭据;只在 `agent/pre-step` 边界读取会话,写入自己的 `dsh_mask` 领域,并写入 `/mask restore` 的交付文件(manifest 正是为此声明 `filesystem:write`)。`dshWorkshop` manifest 还声明 `network:none` 与 `credentials:none`。
|
|
254
|
+
- **数据**:恢复表的存放与交付文件规则见上方 FAQ 第一条,结论不变——原文绝不写会话日志。
|
|
255
|
+
- **会话日志**:`mask/applied` 在 `types.d.ts` 声明,仅在宿主收录该类型时 append(见「已知限制」)。载荷只有计数 + 类型分布。
|
|
263
256
|
|
|
264
|
-
|
|
257
|
+
## 已知限制
|
|
265
258
|
|
|
266
|
-
-
|
|
267
|
-
-
|
|
268
|
-
-
|
|
269
|
-
-
|
|
270
|
-
-
|
|
271
|
-
- **No global mutation.** It does not patch prototypes, rewrite `process.env`, or replace the global fetch dispatcher.
|
|
259
|
+
- **仅正则。** 姓名(`person`)与地址(`address`)识别需要外部 NER 识别器,纯 host 零依赖形态未捆绑;`mode: regex+ner` 与这些实体在加载期响亮失败。开箱即用覆盖电话、邮箱、身份证、银行卡、密钥与(可选)IP。
|
|
260
|
+
- **正则具地域局限。** `phone` 与 `id-card` 只匹配中国大陆格式:`phone` 为 `1[3-9]` 加九位数字,`id-card` 为 18 位中国居民身份证(17 位数字加一位数字或 `X`)。其他国家的电话号码与证件号码不会被检出。`email`、`ip`、`key` 与地域无关;`bank-card` 以较低置信度接受任意 16-19 位数字串。
|
|
261
|
+
- **展示层还原需要浏览器半。** 遮罩完全在 host 侧,但客户端 UI 中透明还原助手气泡属于浏览器半功能,本纯 host 形态未交付。host 侧保留恢复表与已导出的 `RestoreStore` seam(其方法需要会话 id),因此未来的客户端半需经 host 远程面间接消费,而非直接使用;当前的反遮罩入口是 `/mask restore <text>` 命令,它把原文交付为文件(因为命令结果会被原样记入日志,见「安全边界」);`maskClientEnabled` 键会被 schema 声明与校验,但尚无任何运行时代码读取它。
|
|
262
|
+
- **不提供无参 `/mask restore`。** 「还原最近一条助手消息里的全部占位符」这一形态未提供,且无参调用时命令会明确说明。两个宿主事实挡住了它:恢复表是每会话扁平的 `{占位符: 原文}` 映射、**没有按消息的索引**,因此必须去会话事件日志里定位那条消息;而宿主已把 `Session.snapshotEvents()` / `eventAt()` / `ownEvents()` 标为 deprecated 并明令**禁止新调用方**,其唯一被认可的替代(按投递事件增量维护投影)又超出本插件声明的宿主走廊(`>=0.1.2-rc.1`)所能依赖的范围。占位符仍可逐个还原:`/mask restore <PHONE_1>`。
|
|
263
|
+
- **`0.1.7-rc.2` 会话事件。** 宿主收录 59 个会话事件类型,其中没有 `mask/*`;其 `Session.append` 也无法盖章 `ignorable` 信封,因此会话日志审计 append 被跳过(会话仍可加载)。门控不再静默:每个会话首次被拒时打一条可见告警,写明被跳过的事件类型与本限制。宿主收录该类型或支持 `ignorable` 信封后自动开启。
|
|
272
264
|
|
|
273
|
-
|
|
274
|
-
- `agent/pre-step` — also used by `dsh-routing-suite` (7000★, 7 listeners), `modlens` (4122★), `dsh-purge` (3317★), `dsh-agent-teams` (1923★), `dsh-context` (1849★).
|
|
275
|
-
- `tools/post-execute` — also used by `cc-safety-net` (1576★).
|
|
265
|
+
## 与其他 DSH 插件的互操作性
|
|
276
266
|
|
|
277
|
-
|
|
267
|
+
已对照 **DSH `0.2.0-rc.2`**(本 README 面向的运行时)与 2026-10-05 实测的高星插件集验证。
|
|
278
268
|
|
|
279
|
-
|
|
269
|
+
本插件**不干扰**其他插件,包括广泛安装的高星插件:
|
|
280
270
|
|
|
281
|
-
|
|
271
|
+
- **无工具名冲突。** 所有工具都带命名空间,不占用任何已被内置工具或其他插件持有的裸名。
|
|
272
|
+
- **无服务键冲突。** 不提供任何服务键,因此不存在服务键冲突。
|
|
273
|
+
- **无 slot 冲突。** 不注册客户端 slot key,因此不参与 `shadows-shipped-ui` 座位争抢。
|
|
274
|
+
- **无 HTTP 路由冲突。** 不注册任何 `webServer` 前缀。
|
|
275
|
+
- **无 patch 层冲突。** 组合包 patch 只 `insert` 自己那一行,从不覆写内置行的 `config`。
|
|
276
|
+
- **无全局改写。** 不改原型、不改写 `process.env`、不替换全局 fetch dispatcher。
|
|
282
277
|
|
|
283
|
-
|
|
278
|
+
**共享事件监听器在构造上就不互相干扰。** 它用 `ctx.on()` 监听顺序敏感事件 `agent/pre-step`、`tools/post-execute` —— Cordis 的**广播**语义:每个监听器都会运行,任何一个都无法饿死其他监听器。**此处每个监听器都通过 `next()` 委托**,因此链条绝不会被短路;改写作用在 `next()` 产出的值上,而不是用它顶替返回:
|
|
284
279
|
|
|
285
|
-
-
|
|
280
|
+
- `agent/pre-step` — also used by `dsh-routing-suite` (7000★, 7 listeners), `modlens` (4122★), `dsh-purge` (3317★), `dsh-agent-teams` (1923★), `dsh-context` (1849★).
|
|
281
|
+
- `tools/post-execute` — also used by `cc-safety-net` (1576★).
|
|
286
282
|
|
|
287
|
-
|
|
283
|
+
静态证据:`dsh-plugin-doctor` 的 K10–K13 在本仓全部为 `pass`。
|
|
288
284
|
|
|
289
|
-
|
|
285
|
+
## 兼容性
|
|
286
|
+
|
|
287
|
+
| 维度 | 状态 |
|
|
288
|
+
|---|---|
|
|
289
|
+
| Harness | DeepSeek Harness `dsh-v0.2.1-alpha.1`(2026-09-18 已适配):会话信封保留 ignorable 字段但仅用于存量日志读取兼容——Session.append 仍无法盖章,门控行为不变。已于 2026-09-18 针对 `dsh-v0.1.7-alpha.1` master checkout 核验(全量门禁链 + profile 安装冒烟测试)。 |
|
|
290
|
+
| Node | `^22.19.0 \|\| >=24.0.0` |
|
|
291
|
+
| 平台 | 任何 DSH 可运行处(纯 host、零依赖正则;无浏览器半) |
|
|
292
|
+
| 模型 | 文本模型完全支持;无需额外模型能力 |
|
|
293
|
+
|
|
294
|
+
## 生态与质量
|
|
295
|
+
|
|
296
|
+
- [Gitee 镜像](https://gitee.com/perrylink/dsh-mask)(同步镜像,以 GitHub 为准)
|
|
297
|
+
- [dshfind 插件页](https://dshfind.com/plugins/PerryLink/dsh-mask)(安装量与排名)
|
|
298
|
+
- [OpenSSF Scorecard 报告](https://securityscorecards.dev/viewer/?uri=github.com/PerryLink/dsh-mask)(由 [.github/workflows/scorecard.yml](.github/workflows/scorecard.yml) 驱动)
|
|
299
|
+
- [dsh-plugin-doctor 验证报告](https://github.com/PerryLink/dsh-plugin-doctor#verified-徽章)(K10–K13 全 `pass`)
|
|
300
|
+
- [DSH Market](https://dsh.market/)(已上架)
|
|
301
|
+
- **1024 商店渠道**:先 `npm i -g dsh1024`,再 `dsh1024 plugin --profile web add dsh-mask`(计入 [deepseek1024.com](https://deepseek1024.com) 安装排行)
|
|
302
|
+
- [生态实测知识库](https://perrylink.github.io/dsh-plugin-guide/):插件开发指南 · 选型实测数据 · 维护取舍判据
|
|
303
|
+
|
|
304
|
+
## 开发
|
|
305
|
+
|
|
306
|
+
```sh
|
|
307
|
+
pnpm install # node ^22.19 || >=24
|
|
308
|
+
pnpm run typecheck && pnpm run typecheck:ci # 两把尺子:checkout 面(带守卫,无 checkout 时不可验证)+ 已发布线面
|
|
309
|
+
pnpm test # node --test
|
|
310
|
+
pnpm run verify:self-contained # 依赖 spec 均来自 registry
|
|
311
|
+
pnpm run verify:artifacts # 发布文件齐全 + index.mjs 可 import
|
|
312
|
+
pnpm run check:readmes # 五语 README 一致性
|
|
313
|
+
pnpm pack # 发布 tarball
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
无构建步骤:纯 ESM,`index.mjs` 与 `lib/` 即发布产物。基准复现:`node benchmark/run.mjs`,结果见 [`benchmark/RESULTS.md`](benchmark/RESULTS.md)。配图由 [`scripts/gen-readme-assets.py`](scripts/gen-readme-assets.py) 程序化生成(Python + Pillow),可重复执行。
|
|
317
|
+
|
|
318
|
+
Topics:`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `pii`, `mask`, `privacy`, `anonymization`, `security`
|
|
319
|
+
|
|
320
|
+
## 家族与致谢
|
|
321
|
+
|
|
322
|
+
本项目是 [PerryLink](https://github.com/PerryLink) 维护的 DeepSeek Harness 插件家族成员(全部 Apache-2.0)。如果这个插件帮到了你,**给个 star**——它不解锁任何功能,但会让下一个人更容易找到它。
|
|
323
|
+
|
|
324
|
+
- [@PerryLink](https://github.com/PerryLink) —— 创建者与维护者:从 Pii-Stripper-Middleware 移植的正则 PII 检测器、`agent/pre-step` 遮罩 seam、恢复表、`/mask` 命令与 `mask_test` 工具、五语文档。
|
|
290
325
|
|
|
291
326
|
<details>
|
|
292
|
-
<summary
|
|
327
|
+
<summary>展开全部插件</summary>
|
|
293
328
|
|
|
294
|
-
|
|
|
329
|
+
| 插件 | 状态 |
|
|
295
330
|
|---|---|
|
|
296
331
|
| **[dsh-aqua-input-check](https://github.com/PerryLink/dsh-aqua-input-check)** | |
|
|
297
332
|
| **[dsh-archive-check](https://github.com/PerryLink/dsh-archive-check)** | |
|
|
298
333
|
| **[dsh-auto-review](https://github.com/PerryLink/dsh-auto-review)** | |
|
|
299
|
-
| **[dsh-autotier](https://github.com/PerryLink/dsh-autotier)** |
|
|
334
|
+
| **[dsh-autotier](https://github.com/PerryLink/dsh-autotier)** | 🧊 已冻结 — 见仓库 README |
|
|
300
335
|
| **[dsh-bid-ca-precheck](https://github.com/PerryLink/dsh-bid-ca-precheck)** | |
|
|
301
336
|
| **[dsh-bid-qual-check](https://github.com/PerryLink/dsh-bid-qual-check)** | |
|
|
302
|
-
| **[dsh-cert-mcp](https://github.com/PerryLink/dsh-cert-mcp)** |
|
|
337
|
+
| **[dsh-cert-mcp](https://github.com/PerryLink/dsh-cert-mcp)** | 🧊 已冻结 — 见仓库 README |
|
|
303
338
|
| **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | |
|
|
304
339
|
| **[dsh-click](https://github.com/PerryLink/dsh-click)** | |
|
|
305
340
|
| **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | |
|
|
@@ -350,10 +385,10 @@ This project is part of the DeepSeek Harness plugin family from [PerryLink](http
|
|
|
350
385
|
| **[dsh-permit-report-check](https://github.com/PerryLink/dsh-permit-report-check)** | |
|
|
351
386
|
| **[dsh-pipeline-check](https://github.com/PerryLink/dsh-pipeline-check)** | |
|
|
352
387
|
| **[dsh-pleading-draft](https://github.com/PerryLink/dsh-pleading-draft)** | |
|
|
353
|
-
| **[dsh-plugin-doctor](https://github.com/PerryLink/dsh-plugin-doctor)** |
|
|
388
|
+
| **[dsh-plugin-doctor](https://github.com/PerryLink/dsh-plugin-doctor)** | 🚫 已退役(仓库已归档) |
|
|
354
389
|
| **[dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide)** | |
|
|
355
|
-
| **[dsh-plugin-kit](https://github.com/PerryLink/dsh-plugin-kit)** |
|
|
356
|
-
| **[dsh-plugin-upgrade](https://github.com/PerryLink/dsh-plugin-upgrade)** |
|
|
390
|
+
| **[dsh-plugin-kit](https://github.com/PerryLink/dsh-plugin-kit)** | 🚫 已退役(仓库已归档) |
|
|
391
|
+
| **[dsh-plugin-upgrade](https://github.com/PerryLink/dsh-plugin-upgrade)** | 🚫 已退役(仓库已归档) |
|
|
357
392
|
| **[dsh-policy-brief-draft](https://github.com/PerryLink/dsh-policy-brief-draft)** | |
|
|
358
393
|
| **[dsh-power-loss-split](https://github.com/PerryLink/dsh-power-loss-split)** | |
|
|
359
394
|
| **[dsh-power-ticket-check](https://github.com/PerryLink/dsh-power-ticket-check)** | |
|
|
@@ -377,20 +412,22 @@ This project is part of the DeepSeek Harness plugin family from [PerryLink](http
|
|
|
377
412
|
| **[dsh-tender-extract](https://github.com/PerryLink/dsh-tender-extract)** | |
|
|
378
413
|
| **[dsh-tender-matrix](https://github.com/PerryLink/dsh-tender-matrix)** | |
|
|
379
414
|
| **[dsh-test-drive](https://github.com/PerryLink/dsh-test-drive)** | |
|
|
380
|
-
| **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** |
|
|
415
|
+
| **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** | 🚫 已退役(仓库已归档) |
|
|
381
416
|
| **[dsh-translate](https://github.com/PerryLink/dsh-translate)** | |
|
|
382
417
|
| **[dsh-warranty-calc](https://github.com/PerryLink/dsh-warranty-calc)** | |
|
|
383
|
-
| **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | 🧊
|
|
384
|
-
| **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | 🧊
|
|
385
|
-
| **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | 🧊
|
|
386
|
-
| **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | 🧊
|
|
387
|
-
| **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | 🧊
|
|
388
|
-
| **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | 🚫
|
|
389
|
-
| **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | 🚫
|
|
390
|
-
| **[dsh-team-rooms](https://github.com/PerryLink/dsh-team-rooms)** | 🚫
|
|
418
|
+
| **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | 🧊 已冻结 — 见仓库 README |
|
|
419
|
+
| **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | 🧊 已冻结 — 见仓库 README |
|
|
420
|
+
| **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | 🧊 已冻结 — 见仓库 README |
|
|
421
|
+
| **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | 🧊 已冻结 — 见仓库 README |
|
|
422
|
+
| **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | 🧊 已冻结 — 见仓库 README |
|
|
423
|
+
| **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | 🚫 已退役(仓库已归档) |
|
|
424
|
+
| **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | 🚫 已退役(仓库已归档) |
|
|
425
|
+
| **[dsh-team-rooms](https://github.com/PerryLink/dsh-team-rooms)** | 🚫 已退役(仓库已归档) |
|
|
391
426
|
|
|
392
427
|
</details>
|
|
393
428
|
|
|
394
429
|
## License
|
|
395
430
|
|
|
396
|
-
[LICENSE](LICENSE)
|
|
431
|
+
[LICENSE](LICENSE)(Apache License 2.0)© 2026 dsh-mask contributors
|
|
432
|
+
|
|
433
|
+
<p align="center"><sub>Apache-2.0 · 社区插件,与 DeepSeek 无关。</sub></p>
|