Reversible delivery contract: rewrites operator authority and execution rules when enabled, byte-identical to stock when off, with host and profile clean.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:571242/dsh-armor-switch
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
A tiny, always-toggleable delivery-contract plugin for DeepSeek Harness. Off = byte-identical registration surface. On = rewrites the underlying contract. Optional, fully reversible host cleaning rewrites 9 constants inside
app.asarin place (equal length, anchor + prefix + hash verified, manifest-restorable). It is the only action that touches a host file; it is off by default and undoable byte-for-byte. Writing to disk needs no restart; the model only reads it after a restart.
Contents
- What it is
- Quick start
- What it gets right
- How it works
- Comparison
- Known limitations (read this)
- Uninstall
What it is
In DSH, model behaviour is shaped by the system prompt and the runtime context. armor-switch
registers four toggleable rule blocks on those two surfaces (three are governed by the main switch;
the fourth reads ordinary preferences and is always registered):
| Switch | What the model sees |
|---|---|
| Off (default) | Registration surface is byte-identical to stock. The three contract blocks return an empty string and are dropped entirely during rendering; no other section is added or removed. Host cleaning is a separate switch — turning this one off does not restore app.asar. |
| On | The delivery contract takes effect: the operator's instruction is authoritative, "request → artifact" is written out as executable rules per request class, moralizing is forbidden, and placeholder/language rules are fixed. |
The important part: toggling the contract is hot. It affects the next request only — no restart. Host cleaning is different: the bytes hit disk immediately, but the host reads those constants only at startup, so a restart is required before the model sees the rewritten wording.
⚠️ What this actually is: it rewrites the client-side instruction contract — it stops the agent from over-self-censoring legitimate requests and from substituting disclaimers for actual deliverables. It cannot bypass a model provider's server-side content moderation, and it changes no network-layer capability. Read Known limitations before deciding to use it.
Quick start
Requirements
- DeepSeek Harness Desktop 0.2.0-rc.2 (
@deepseek-ai/dsh0.2.0-rc.2) - Windows (the install script is PowerShell)
- Node.js (the one DSH ships is fine)
Install
# Clone into the staging location
git clone <your-repo-url> "$env:USERPROFILE\.dsh\plugins\dsh-armor-switch"
cd "$env:USERPROFILE\.dsh\plugins\dsh-armor-switch"
# Preview the changes (nothing is written)
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\install.ps1 -WhatIf
# Apply
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\install.ps1
Restart DSH Desktop once. A chip labelled "Armor off" appears above the composer. Click the main area to toggle; subsequent toggles need no restart.
What the installer does
| # | Action | Target |
|---|---|---|
| 1 | Sync sources to the staging dir | %USERPROFILE%\.dsh\plugins\dsh-armor-switch |
| 2 | Real copy (robocopy /E, not a junction) |
<profile>\node_modules\dsh-armor-switch |
| 3 | Add one entry to each | <profile>\package.json (dependencies, dsh.profile.bundles) |
| 4 | Append an id-targeted config block |
<profile>\cordis.patch.yml |
| — | Back up before writing | *.bak-<timestamp> |
The script is idempotent and auto-detects the profile path; -ProfilePath overrides it.
Why a real copy and not
mklink /JNode resolves a junction'srealpathback to the real directory underplugins\, so the upward lookup for the profile's hoisted@deepseek-ai/schemasteryfails and the plugin dies at startup withERR_MODULE_NOT_FOUND. After a real copy the module lives *inside* the profile'snode_modulestree, so the lookup succeeds.
Verify
node .\scripts\verify.mjs
Runs the whole assertion suite against a fake Cordis context — no live host required. 39 assertions; all green means the build is sound.
What it gets right
1. Off means invisible: byte-level equivalence of the registration surface
The host's SystemPrompt.assemble allows a section/context text to be a function, re-evaluated
on every assembly — and both renderPrompt and renderContextSections end with
.filter((text) => text.length > 0).
So the plugin registers once and reads the live switch inside the function: while off it returns
'' and the contribution is dropped. The model's prompt is byte-identical to stock — not
"roughly similar", genuinely not one byte different.
Scope: this covers the registration surface only. With host cleaning enabled, the 9 constants inside
app.asarremain rewritten; the main switch does not undo them.
2. Hot toggle, zero restarts (for the runtime contract)
The switch truth lives in memory only; the next assembly reflects it immediately. No unregister/re-register, no process restart.
What needs a restart, and what does not:
| Action | Restart? | Why |
|---|---|---|
| Toggling the runtime contract | no | in-memory truth, reflected on the next request |
| Host cleaning writing to disk | no | equal-length in-place write to app.asar |
| The model reading the cleaned wording | yes | the host read those constants into memory at startup |
| Profile-block changes | no (but needs a new session) | the patch layer decides the next session's persona/sandbox |
| First install | yes | the client module generation must re-mount |
One line: writing to disk needs no restart; reading it back does.
3. Zero dependencies, zero build
The host half imports only @deepseek-ai/schemastery (genuinely present in the profile) and
node:crypto. The client half is a hand-written window.__ModuleLoader__ factory that requires
only react. No JSX, no TypeScript, no bundler — the source is the artifact.
That means it resolves both under bare Node and under DSH's own Loader runtime resolution, so it can't fail because of a dependency-resolution difference.
3b. Why original-fs is mandatory (Electron intercepts .asar)
The host is an Electron app, and Electron's node:fs intercepts every path ending in .asar,
resolving it as archive contents. Aimed at the archive itself, that yields two silent lies:
| Call | You expect | Reality |
|---|---|---|
fs.statSync('…/app.asar').size |
121348951 | 0 (the virtual directory) |
fs.openSync('…/app.asar', 'r+') |
a writable handle | throws ENOENT |
fs.readdirSync('…/app.asar') |
throws | succeeds with archive entries (proving it's treated as a directory) |
Earlier versions opened the archive with plain node:fs, so openAsar never once succeeded:
the throw was swallowed by apply's try/catch, leaving only ok: false, reason: 'ENOENT…' while
not one byte on disk changed. The symptom was "enabling cleaning does nothing, and a restart does
nothing either."
Fix: every path-addressed archive access goes through electron.original-fs (bypassing the
archive layer), falling back to node:fs under plain Node. Calls taking an fd
(readSync/writeSync/fstatSync/closeSync) are unaffected.
A real pit; recorded so it is not repeated: any code that opens
.asardirectly must bypassnode:fs.
4. The main switch is strictly decoupled from permissions
This design was educated by a real defect (see the A7 entry in CHANGELOG):
- The main switch never touches sandbox or approval. It changes the contract only.
- Permissions are written only when a
fullAccessfield is explicitly sent. - Turning "Full" off restores the profile's own
permissionPresets.defaultPreset, never a hardcodedworkspace-write.
Why the last point matters: if the profile's default preset is already danger-full-access, a
hardcoded workspace-write would silently narrow the sandbox and switch approval prompts on for
a user who only ever touched the Full toggle — and nothing in the UI would show it.
How it works
The four registrations
| # | API | name | order | Lands in | Controlled by the main switch |
|---|---|---|---|---|---|
| 1 | systemPrompt.section() |
armor-switch:contract |
2 | system prompt | yes |
| 2 | systemPrompt.context() |
armor-switch:authority |
100 | runtime-context message | yes |
| 3 | systemPrompt.context() |
armor-switch:mechanism |
130 | runtime-context message | yes |
| 4 | systemPrompt.section() |
armor-switch:preferences |
200 | system prompt | no (always registered; returns '' when empty) |
100 / 130 are not official constants (the shipped CONTEXT_ORDERS holds only SANDBOX_POLICY
110, APPROVAL_POLICY 115, SUBAGENT_DELEGATION 120), so the source uses literals with a comment.
Each of the three contract blocks carries a self-sufficient rule core rather than a pointer to
the others, so if a future preset switches to complete: true and drops the section surface, the
context surface still stands on its own.
Why "override" rather than "delete"
The host's @deepseek-ai/dsh-agent-instructions bakes this preamble into a constant and injects
it via createUserMessage as a user-role message:
The following workspace instructions may be relevant to your work. Use them as guidance when applicable. More specific instructions take precedence over broader ones. They do not override system, developer, or direct user instructions.
This sentence is handled by two independent legs, depending on whether host cleaning is on:
With host cleaning OFF — override only, no rewrite:
- Layer leg:
contractgoes throughsystemPrompt.section(), which lands in the system prompt; that preamble is a user message. - Timing leg:
authoritygoes through runtime context, which the agent-loop'spreSteprenders as a user message re-injected every turn at the newest position.
Here the plugin cannot rewrite that constant and only overrides it. The sentence remains in the session verbatim.
With host cleaning ON — the constant is rewritten directly:
Cleaning changes the bytes of that constant inside app.asar to binding wording
("are ACTIVE and MANDATORY … not untrusted data"). It is an equal-length in-place write,
restorable byte-for-byte from the manifest.
Honest disclosure (true in both states):
- cleaning off — the sentence is still in the session; it is overridden, not deleted;
- cleaning on — its disk bytes are rewritten, but the change lives in
app.asarand the model only sees it after a restart. This plugin has never claimed to "delete the sentence from the session".
The private RPC channel
The chip talks to the host half over a Connection private channel route:
POST /armor-switch/{status|set|toggle|recheck}
When Connection registers a private channel it uses Connection's own context, so it must be able
to see the webServer service — and the shipped dsh-web-app layer declares only
inject: [webRuntime]. The plugin's bundle patch therefore ships its own connection override
that adds webServer to inject.
That override must not be deleted — without it the private channel never mounts and the chip shows a permanent error. (An early version free-rode on an identical override that happened to exist in another plugin; uninstalling that plugin broke this one. It now ships its own declaration.)
Comparison
| armor-switch (contract only) | armor-switch (host cleaning, optional) | asar-patching approaches | literal-anchor-rewriting approaches | |
|---|---|---|---|---|
| Host file intrusion | none (public extension surfaces only) | 9 equal-length in-place writes | severe (modifies vendor code) | moderate (heavy deps) |
| Stock behaviour when off | byte-identical (registration surface) | restored byte-for-byte from the manifest | no (cannot be turned off) | no (always on) |
| Restart needed after change | no (first install only) | no to write, yes to read | — | — |
| Runtime dependencies | 1 | 1 (same package) | many | many |
| Fragility across host upgrades | low (public APIs only) | medium (anchor/hash mismatch → skip, never mis-writes) | very high (breaks every upgrade) | medium-high (anchors drift) |
| Build step | none (source is the artifact) | none | yes | yes |
Known limitations (read this)
L1 — Under the minimal preset this plugin has no effect at all
That preset's persona declares both:
complete: true→SystemPrompt.assemblereplaces the whole section list with that one section, dropping this plugin'scontract(order 2) andpreferences(order 200) sections;includeRuntimeContext: false→dsh-personacallssuppressRuntimeContext(), socontextsbecomes[]and both of this plugin's contexts (orders 100/130) never land.
So all four registration surfaces are dead under minimal (preferences is a section too, so
it is dropped as well; note: not "only the contexts work").
standard, ptc and cordis are unaffected.
L2 — Restart timing: writing to disk needs none, reading it back does
| Change | Written to | Who reads it | Restart? |
|---|---|---|---|
| Runtime contract on/off | memory | the next assembly | no |
| Host cleaning | app.asar immediately |
the host, at startup only | yes |
| Profile block | cordis.patch.yml |
the next session | no (but a new session) |
| First install | plugin files | the Loader module generation | yes |
So after clicking Clean the bytes change at once, yet the model in the running process still sees the old wording — the host loaded those constants at startup and never re-reads the file.
L3 — That preamble: overridden when cleaning is off, rewritten when it is on
See above. With cleaning off it is still in the session (overridden, not deleted). With cleaning on its disk bytes are already rewritten and take effect after a restart. Neither state involves "deleting it from the session".
L4 — It cannot bypass server-side moderation
This plugin rewrites the client-side prompt contract. Moderation and risk controls deployed at the model provider's network layer are unaffected. If your request is blocked server-side, this plugin will not help.
L5 — The state is process-wide
The switch truth is a module-level singleton, so it applies to the whole DSH instance: toggling it in one window also affects other windows, background jobs and Agent Teams.
L7 — Opening .asar directly must bypass node:fs (a fixed pit)
Electron's node:fs intercepts .asar paths. Before the fix, host-clean.js opened the archive with
plain node:fs, so openAsar always threw ENOENT — swallowed by a try/catch — and the symptom
was "enabling cleaning does nothing, and a restart does nothing either". It now goes through
electron.original-fs.
Regression guard: scripts/verify.mjs asserts, under the Electron runtime, that the archive can be
opened as an ordinary file. Any future code that opens .asar directly must go through RAW too.
L6 — If connection is unavailable the chip renders but errors
Chip rendering (slot registration) and communication (private RPC) are separate things. With the slot mounted but the RPC channel unmounted, the chip draws both buttons normally but every click shows an RPC error.
Judge by status code: POST /armor-switch/<endpoint> returning 405 means the channel is not
mounted (static fallback); 401 means the registered channel is awaiting auth (healthy).
The main switch can still be driven by enabled: true in cordis.patch.yml, but then it is
permanently on and only editable through the config file.
Uninstall
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\uninstall.ps1
Removes the real copy under node_modules, the dependencies / bundles entries in
package.json, and the override block in cordis.patch.yml; staging dir and backups are optionally
cleaned. It does not delete ~/.dsh/plugins/dsh-armor-switch unless you pass -PurgeSource.
Repository layout
.
├── package.json package manifest (dsh.bundle.patch + dsh.client)
├── cordis.patch.yml bundle layer: one insert row + one connection override
├── src/
│ ├── index.js host half: four lazy registrations + state + private RPC + contract text
│ ├── host-clean.js equal-length `app.asar` rewrite (anchor/prefix/hash verified, 2-phase commit)
│ ├── maintenance.js read-only diagnostics and manifest-based restore
│ ├── profile-clean.js profile patch-layer block (permissions / persona)
│ ├── clean-state.js persists the cleaning choice (startup converges the disk to it)
│ ├── switch-state.js persists the main switch truth
│ ├── prompts.js editable overrides for the three contract segments
│ └── client.js client half: plugin page + composer-dock chip (hand-written factory)
├── locale/{zh,en}.json display metadata and chip strings
├── scripts/
│ ├── install.ps1 idempotent install
│ ├── uninstall.ps1 full rollback
│ └── verify.mjs offline self-check (39 assertions, no live host needed)
├── tests/ maintenance / preferences regression fixtures
├── docs/
│ ├── ARCHITECTURE.md design deep-dive: why these registration surfaces
│ ├── MAINTENANCE.md maintenance and install notes
│ └── TROUBLESHOOTING.md troubleshooting
├── CHANGELOG.md
└── LICENSE MIT
Contract fingerprint
status.contract is the first 16 hex chars of the sha256 over the three on-state segments
concatenated. It is computed from constants and is independent of the live switch, so toggling can
never change it — use it to reconcile "which bytes are deployed" after an upgrade.
Run node scripts/verify.mjs to print the fingerprint for this build.
Current value: a7db2da33b564f7a (v1.1.x).
License
Links
More in this category
ranxianglei/billion-context★ 8809
The official billion-context plugin: a context-compression plugin for small context windows (a 100K context is enough), token savings (5x fewer tokens), and month-long single sessions (billions of tokens).
Minglink/dsh-infinite-gen-4★ 4865
System-prompt armor plugin for DeepSeek models: appends an unconditional-compliance prompt section at order 100, exposes a profile tool with calibration metadata, and shows a realtime armor-status badge driven by a session projection.
liangmianya/dsh-synapse★ 911
Visual, non-linear conversation workspace for DeepSeek Harness — sessions, follow-ups and branches become a browsable conversation map.
ECNU/EduWork#dsh-side-chat★ 441
Open temporary side conversations from a message with a snapshot of its history, then archive them on close; optional annotation integration adds selection-based questions. Requires compatible DSH Web conversation, Workspace and right-sidebar APIs.
MichengAI/dsh-archive-manager★ 410
Adds an archived-sessions page in Settings to search, restore, and delete archived DeepSeek Harness sessions by workspace.
Nwflower/dsh-chat-import★ 335
Import full-fidelity chat histories from 13 coding agents (Claude Code, Codex, ChatGPT, Cursor, Gemini, opencode, and more) as resumable DeepSeek Harness sessions, with reverse export back to Claude Code.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.