- Início
- Plugins
- Segurança e permissões
- dsh-question-shield
dsh-question-shield
skyskyskyl/dsh-question-shield
Keeps exploratory questions read-only and blocks unsolicited file creation without busting Prompt Cache.
Instalar
dsh plugin --profile web add github:skyskyskyl/dsh-question-shieldREADME
dsh-question-shield
English | 简体中文
Stop your coding agent from refactoring your repo when you're just thinking out loud — and stop it from spawning random helper files you never asked for.
Before vs. After
1. Casual Question -> Accidental Refactor
# Before
you> Would it be better to make handleRequest() async?
agent> Great idea! Making it async right now...
[edit] src/server.ts (+48 -31)
[edit] src/router.ts (+22 -14)
[edit] tests/server.test.ts (+39 -19)
# You only wanted to discuss trade-offs. Now you're running `git checkout .`.
# After (with dsh-question-shield)
you> Would it be better to make handleRequest() async?
agent> Trade-offs to consider before changing handleRequest():
- Pros: non-blocking I/O under concurrent load, cleaner error propagation.
- Cons: viral async coloring across 3 callers in router.ts.
Want me to go ahead and refactor it?
# Zero files touched until you say the word.
2. Bug Fix -> Unsolicited File Sprawl
# Before
you> Fix the timeout bug in src/client.ts
agent> Fixed! Also created a few helper files for you:
[edit] src/client.ts (+4 -2)
[write] scripts/verify_timeout_tmp.mjs (NEW)
[write] TIMEOUT_FIX_NOTES.md (NEW)
# After
you> Fix the timeout bug in src/client.ts
agent>
[edit] src/client.ts (+4 -2)
[blocked] write scripts/verify_timeout_tmp.mjs
[Question Shield] Blocked unsolicited file creation: "scripts/verify_timeout_tmp.mjs".
The user did not ask to create a new file. Please edit existing files instead, or ask first.
Why it happens
In Speech Act Theory, "Would it be better to refactor this?" and "是不是改成异步会更好?" are Information-seeking / Polar Questions, not Directives. Coding agents trained to be eagerly helpful often collapse that distinction and treat every hypothetical question as an implicit order to start editing files.
dsh-question-shield restores that boundary locally using bilingual regex heuristics, a per-turn read-only lock, and a pre-execution file-creation guard. No extra LLM calls, and no system-prompt edits that bust your Prompt Cache.
(Never thought my linguistics knowledge would actually come in handy here lmao.)
Installation
Install from GitHub into a DSH profile
dsh plugin --profile default add github:skyskyskyl/dsh-question-shield
Note (pnpm >= 10): Git installs run
prepareto compile TypeScript. If pnpm blocks the build script on first install, allowdsh-question-shieldin your profile'spnpm-workspace.yaml(allowBuilds: { dsh-question-shield: true }) and re-rundsh plugin add.
Or load locally via --patch
git clone https://github.com/skyskyskyl/dsh-question-shield.git
cd dsh-question-shield
pnpm install && pnpm run build
Create a patch file question-shield.patch.yml:
- insert:
- id: question-shield
name: /absolute/path/to/dsh-question-shield/lib/index.js
Run DeepSeek Harness with the overlay:
dsh --patch ./question-shield.patch.yml
Configuration
All options are optional with sensible defaults. Override them in your profile's cordis.patch.yml:
- insert:
- id: question-shield
name: dsh-question-shield
config:
enableQuestionShield: true
strictReadOnlyOnQuestion: true
guardUnsolicitedFileCreate: true
allowCreatePatterns:
- "**/*.test.ts"
- "tmp/**"
customQuestionPatterns:
- "\\bbrainstorm\\b"
customDirectivePatterns:
- "\\bship it\\b"
| Option | Type | Default | Description |
|---|---|---|---|
enableQuestionShield | boolean | true | Detect exploratory questions (EN/ZH) and inject a read-only reminder. |
strictReadOnlyOnQuestion | boolean | true | Hard-block file mutation tools during a detected question turn. |
guardUnsolicitedFileCreate | boolean | true | Block creating non-existent files unless explicitly requested or named by the user. |
allowCreatePatterns | string[] | [] | Glob whitelist (*, **, ?) for paths allowed to be created freely. |
customQuestionPatterns | string[] | [] | Extra regex patterns (case-insensitive) treated as exploratory question cues. |
customDirectivePatterns | string[] | [] | Extra regex patterns (case-insensitive) that override question detection as directives. |
How it works
agent/pre-stephook:- Inspects incoming
source.kind === 'user'messages in Chinese, English, or mixed text. - Distinguishes exploratory questions (
是不是...,Would it be better...,?/?) from polite commands (能不能现在帮我把...改成...?,Can you please refactor...). - Appends a short
[Question Shield]notice at the end of the current turn'smessageswithout touching the system prompt prefix, so Prompt Cache stays warm. - Tracks per-agent turn state in a
WeakMap<Agent, TurnState>so follow-up tool steps stay guarded and new directive turns immediately unlock.
- Inspects incoming
tools/pre-executehook:- Intercepts built-in DSH file mutation tools (
write,edit,apply_patch, and non-viewstr_replace_editorcommands). - During a question turn with
strictReadOnlyOnQuestion: true, denies mutations and tells the model to explain trade-offs first. - During normal turns with
guardUnsolicitedFileCreate: true, checks if the target path does not yet exist on disk; unless the user asked to create a file, directly named the file, or the path matchesallowCreatePatterns, the creation is denied.
- Intercepts built-in DSH file mutation tools (
Development
pnpm install
pnpm run typecheck
pnpm run build
pnpm test