DeepSeek Harness Plugin

skyskyskyl/dsh-question-shield

Stars ★ 1 Category Security & Permissions Added 2026-12-01

Keeps exploratory questions read-only and blocks unsolicited file creation without busting Prompt Cache.

Install

# from a prebuilt release tarball

dsh plugin --profile web add -w "https://github.com/skyskyskyl/dsh-question-shield/releases/download/v0.1.0/dsh-question-shield-0.1.0.tgz"

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:skyskyskyl/dsh-question-shield

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

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 prepare to compile TypeScript. If pnpm blocks the build script on first install, allow dsh-question-shield in your profile's pnpm-workspace.yaml (allowBuilds: { dsh-question-shield: true }) and re-run dsh 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

  1. agent/pre-step hook:
    • 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's messages without 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.
  2. tools/pre-execute hook:
    • Intercepts built-in DSH file mutation tools (write, edit, apply_patch, and non-view str_replace_editor commands).
    • 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 matches allowCreatePatterns, the creation is denied.

Development

pnpm install
pnpm run typecheck
pnpm run build
pnpm test

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.