PerryLink/dsh-mask
DeepSeek Harness 的 PII 脱敏中间件:在数据到达模型前,将姓名、电话、邮箱、身份证号、银行卡号、密钥和地址等敏感信息匿名化为占位符,并在显示层恢复;恢复表仅保存在内存及受控存储域中,绝不记录明文,并暴露 /mask 工具及 mask_test 工具。
项目介绍Project Overview
dsh-mask 是 DeepSeek Harness 的 PII 脱敏中间件,在消息进入模型前用正则把手机、邮箱、证件、银行卡、密钥等替换为占位符,并在显示层还原;适用于需避免明文进入会话日志的场景。注意:仅实现 regex 模式,人名/地址 NER 未实现。
dsh-mask is a PII masking middleware for DeepSeek Harness. It rewrites messages before they reach the model, replacing phones, emails, ID cards, bank cards, keys, and optional IPs with placeholders, then restores them at the display layer. Use it when plaintext personal data must stay out of session logs. Caveat: only regex detection is implemented; NER-based person/address masking is reserved and fails loudly.
请帮我了解并安装插件:【dsh-mask】【https://github.com/PerryLink/dsh-mask】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add dsh-mask
把 PerryLink/dsh-mask 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-mask
PII masking middleware for DeepSeek Harness — anonymize personal data before it reaches the model, restore it at the display layer.
Phones, emails, ID cards, bank cards, keys, and more become placeholders at the model boundary; the plaintext never enters your session log.
Compatibility
| Surface | Status |
|---|---|
| Harness | DeepSeek Harness 0.1.1-rc.2 |
| Node | ^22.19.0 || >=24.0.0 |
| Platforms | Anywhere DSH runs (pure host, zero-dependency regex; no browser half) |
| Model | Text models fully supported; no extra model capability required |
What you get
dsh-mask anonymizes personal data at the model boundary — before a message reaches the model — and keeps a restore table so placeholders can be mapped back to the originals at the display layer:
- Request-time masking —
agent/pre-stepmessages are rewritten so phones, emails, ID cards, bank cards, keys, and IPs (each opt-in) become<PHONE_1>-style placeholders. The masked text is what gets logged and sent to the model. - Restore table — the
placeholder → originalmap lives only in memory and a controlled storage domain (dsh_mask); the plaintext never enters the session log. - Audit, not plaintext — the
mask/appliedsession event records only "replaced N values + type distribution", never the original text or the mapping. /maskcommand —status(counts + distribution),on/off(runtime toggle),restore <text>(unmap placeholders),help.mask_testtool — run a snippet through the detector and see the placeholder result; it never reveals the original values.
user message ──agent/pre-step──▶ placeholders ──model──▶ placeholders ──restore──▶ display
▲ │
└──────── restore table (memory + dsh_mask) ────────┘
Quick start
# 1. install the bundle into your profile
dsh plugin --profile web add "github:PerryLink/dsh-mask#main"
# or from npm (published releases)
dsh plugin --profile web add dsh-mask
# 2. verify the row mounts
dsh --profile web --dump-config | grep -A2 'id: mask'
Then tailor the entity list in your profile patch:
- insert:
- id: mask
name: dsh-mask
config:
entities: [phone, email, id-card, bank-card, key]
> /mask status
> /mask restore <PHONE_1>
Install & uninstall
- git channel (latest
main):dsh plugin --profile web add "github:PerryLink/dsh-mask#main"(equivalent to installing fromgit+https://github.com/PerryLink/dsh-mask.git). No build step —index.mjsandlib/are the shipped artifacts. - npm channel (published releases):
dsh plugin --profile web add dsh-mask. - tarball channel:
pnpm packin this repo, thendsh plugin --profile web add ./dsh-mask-<version>.tgz. - uninstall:
dsh plugin --profile web remove dsh-mask(or remove the row from the profile patch).
Configuration
All tunables are Schemastery Config fields (changeable from cordis.yml). An id-targeted override replaces the whole row — restate every key you need. cordis.patch.yml documents each key inline.
| Key | Default | Meaning |
|---|---|---|
enabled |
true |
Master switch; false unregisters the listener, the /mask command, and the mask_test tool |
mode |
regex |
Detection mode; only regex is implemented (regex+ner for name/address recognition is reserved and fails loud) |
entities |
[phone, email, id-card, bank-card, key] |
Which PII types to mask; ip is also regex-capable (opt-in), person/address require NER |
scope |
[messages] |
Masking surface(s); messages masks agent/pre-step messages, tools masks tool-result text on tools/post-execute. Accepts a string or an array, e.g. [messages, tools] |
registerCommand |
true |
Register the /mask command |
registerTools |
true |
Register the mask_test tool when the tools service is present |
persistRestoreTable |
true |
Persist the restore table to the controlled dsh_mask storage domain (false = memory only) |
maxRestoreEntriesPerSession |
500 |
Per-session restore entry cap (oldest evicted first) |
maxSessions |
1000 |
In-memory session cap (least-recently-used evicted, mapping reloaded on demand) |
maskClientEnabled |
false |
Feature flag for the browser half "reveal" bubble (defensive; off by default until the live slot catalog verifies the target slot) |
Example override in your profile patch:
- insert:
- id: mask
name: dsh-mask
config:
entities: [phone, email, id-card, bank-card, key, ip]
persistRestoreTable: false
registerCommand: true
Tools & surfaces
| Surface | Reveals plaintext | Notes |
|---|---|---|
agent/pre-step masking |
never | Rewrites messages to placeholders before they are logged or sent to the model |
tools/post-execute masking |
never | Rewrites tool-result text blocks to placeholders before they are logged or fed back to the model (scope: tools) |
/mask status |
never | Enabled state, total replaced, type distribution |
/mask on / /mask off |
never | Runtime toggle (resets to config.enabled on restart) |
/mask restore <text> |
yes (explicit) | Unmaps placeholders back to the values stored for this session |
mask_test |
never | Masks a snippet and reports the placeholder result + counts |
Permissions & data
- Permissions:
dsh-maskperforms no network requests and stores no credentials; it only reads the session at theagent/pre-stepboundary and writes its owndsh_maskstorage domain. ThedshWorkshopmanifest declaresnetwork:noneandcredentials:none. - Data: the
placeholder → originalrestore table lives in memory and, whenpersistRestoreTable: true, in the controlleddsh_maskstorage domain — this is the only place plaintext PII is stored, and it is never written to the session log. - Session log:
mask/appliedis declared intypes.d.tsand appended only when the host records the type (see Known limitations). Its payload is counts + type distribution only.
Security boundaries
- Plaintext never enters the session log. The masked (placeholder) form is what gets logged and sent to the model, so model-visible content is reconstructable from the log in placeholder form; the originals stay in the restore table.
- Sanitize before display/log.
lib/sanitize.mjsredacts PII, secrets, and URL credentials before any text reaches the model or the log;mask_testand/mask statusnever echo originals. - Controlled restore.
/mask restoreis the single explicit reveal surface, and it only reads the mapping for the active session. - Fail closed. Unimplemented
mode(regex+ner), unknownscopevalues, NER-only entities, and out-of-bounds numbers all fail loudly at load. - Registrations are effects. The listener, command, tool, and storage-domain close are all Cordis effects — stop/hot-reload removes them.
Known limitations
- Regex only. Name (
person) and address (address) recognition needs an external NER recognizer, which the pure-host zero-dependency form does not bundle;mode: regex+nerand those entities fail loudly at load. The PII types covered out of the box are phone, email, ID card, bank card, key, and (opt-in) IP. - 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 restore table and
restore()are the complete host-side seam a client plugin would consume, and/mask restorecovers interactive needs today. - Session events on
0.1.1-rc.2. The harness does not yet recordmask/*event types, and itsSession.appenddoes not stamp theignorableenvelope, so on rc.2 the session-log audit appends are skipped (sessions keep loading); the plugin enables them automatically once a host records the types or supports theignorableenvelope.
Development
pnpm install # node ^22.19 || >=24
pnpm run typecheck && pnpm run typecheck:ci # tsc --checkJs against the published rc.2 peers
pnpm test # node --test
pnpm run verify:self-contained # dependency specs resolve from the registry
pnpm run verify:artifacts # shipped files present + index.mjs importable
pnpm run check:readmes # five-language README consistency
pnpm pack # the published tarball
There is no build step: pure ESM, index.mjs and lib/ are the shipped artifacts.
Benchmark
The PII benchmark (per-type P/R/F1 over 108 synthetic samples) is published in benchmark/RESULTS.md; regenerate it with node benchmark/run.mjs (no build step, zero new dependencies).
Topics
dsh, dsh-plugin, deepseek-harness, deepseek, cordis, pii, mask, privacy, anonymization, security
Contributors
- @PerryLink — creator and maintainer: the regex PII detector ported from Pii-Stripper-Middleware, the
agent/pre-stepmasking seam, the restore table, the/maskcommand andmask_testtool, and the five-language docs.
PerryLink DSH Plugin Family
This project is one of the DeepSeek Harness plugins maintained by PerryLink. If this one helps you, the others likely will too:
| Plugin | One-liner |
|---|---|
| dsh-mask | PII masking middleware: anonymize at the model boundary, restore at the display layer |
| dsh-mcp-panel | Read-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors |
| dsh-doublecheck | Engineering-discipline guard: requirements grill, test gates, adversary review |
| dsh-background-agents | Durable background child agents with a Web UI sidebar, messaging and interrupt |
| dsh-lsp-actions | LSP diagnostics, formatting, completion, code actions and rename over language servers |
| dsh-output-styles | Claude Code outputStyles-equivalent runtime style switching |
| dsh-checkpoint-rewind | Claude Code /rewind-equivalent: snapshots, session forks, one-shot restore |
| dsh-permission-rules | Claude Code-style declarative allow/deny/ask permission rules with audit |
| dsh-auto-review | Second-model auto-review on the approval chain, fail-closed by default |
| dsh-memento | Approval-gated cross-session memory: ctx.memory seam + SQLite + memory tool |
| dsh-skill-pack-security | Security-audit skill pack: secret scan, dependency and supply-chain review |
| dsh-session-pin | Pin sessions in the Web sidebar with durable ordering |
| dsh-composer-history | Terminal-style input history for the web composer: arrows, Ctrl+R search |
| dsh-github | GitHub PR/issues integration for DSH, every write gated by approval |
| dsh-plugin-guide | Plugin-development knowledge base as an on-demand agent skill |
| dsh-claude-move | Migrate Claude Code sessions, memory, skills and CLAUDE.md into DSH |
License
LICENSE (Apache License 2.0) © 2026 dsh-mask contributors
nexu-io/open-design
freestylefly/awesome-gpt-image-2
anywhere-labs/dsh-desktop
walkinglabs/learn-harness-engineering
awesome-dsh-plugin/awesome-dsh-plugin
MemTensor/MemOS