dsh-plugin-approval-alert
doncelee229-cmyk
DeepSeek Harness 审批/选择方案系统级通知提醒,显示工作区名、点击跳转、多语言。Approval & decision alerts with native notifications for DeepSeek Harnes…
PerryLink/dsh-permission-rules
Claude Code-style declarative permission rules for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex), and workspace-path matching on the tools/pre-execute waterfall, session-log audit, and HMR reload.
PROJECT TOPICS
PROJECT README
Claude Code-style declarative permission rules for DeepSeek Harness.
Rules decide what is known. A reviewer model decides what is not.
dsh-permission-rules puts an ordered allow / deny / ask rule list in front of every tool call on the tools/pre-execute waterfall — deterministic, instant, auditable, and written by you in plain YAML:
deny blocks the call. The rule's reason becomes the model-visible error, so the agent learns why instead of retrying blindly.ask rides the official approval seam. Mount dsh-auto-review alongside and the question is settled by a second model; otherwise a human answers; with neither, the harness fails closed.allow (and no-match) strictly delegates via next() — downstream listeners are never short-circuited.Every hit and every passthrough is audit-logged as a permissionRules/decision session event (log-only — nothing extra is injected into the model context).
tools/pre-execute waterfall approval/request waterfall (answerer chain)
│ │
dsh-permission-rules dsh-auto-review answerer
· first-match rules in file order ┌───────────────┴──────────────┐
· deny/ask claim the call │ AI verdict (second model) │ no ── next() ──▶ human UI
· allow/passthrough → next() └───────────────┬──────────────┘
│ deny ──▶ denied tool result │ allowed-once / rejected
│ ask ──▶ ctx.approval ──────────────────────────┘
│
audit: permissionRules/decision → approval/asked → autoReview/verdict → approval/decided
A second model answers "is THIS call okay?" with judgment, but costs a round-trip and can be wrong. Declarative rules answer deterministically, instantly, and without a model — but only cover what an admin wrote down. Combined, you get the "rules first, AI backstop" loop: rules decide the known, the reviewer decides the unknown.
allow, deny, ask, evaluated in file order, first match winsmcp__*), agent-identity selectors (main / subagent / preset:*), argument key/value globs or regexes (with !pattern negation and an absent key dimension), workspace-relative path globs extracted from documented argument keys at any nesting depth, and when host conditions (env vars, platform)searchUp merges every .dsh/rules.yaml from the session cwd to the filesystem root, nearest first, so a child project can override parent rulesenabled: false, description, tags; /rules warns about rules shadowed by an earlier catch-allallow/passthrough always call next(); only deny/ask short-circuitask flows through ctx.approval; never re-implemented, never bypassedpermissionRules/decision events carry the rule action, the workspace cwd, AND the final outcome for every call; /rules decisions replays the trail in-session; hosts that predate the audit envelope marker degrade to audit-off with a one-time warning instead of writing unresumable logs (allowUnmarkedAudit opts back in)enforce: false audits what the policy would do (would-be action + real downstream outcome, dryRun-marked) while passing every call through; safe policy trialing in production/rules test <tool> <json-args> evaluates the active rules without executing anything, with --cwd, --env, --agent, and --platform overrides for every match dimensionmaxRules fail the loadmaxRules; glob backtracking degree capped by maxGlobStars# 1. install the bundle into your profile
dsh plugin --profile web add "github:PerryLink/dsh-permission-rules#main"
# or from a packed tarball (built artifacts, no build permission needed)
pnpm pack
dsh plugin --profile web add ./dsh-permission-rules-0.4.1.tgz
# 2. restart
dsh --profile web
Then create the rules file for your project and start a session in it:
# <project>/.dsh/rules.yaml
rules:
- match: { tools: [bash, pwsh], params: { command: "git push*" }, paths: ["**/secrets/**"] }
action: deny
reason: "No pushes from protected paths"
- match: { tools: [edit, write] }
action: ask
reason: "File writes need confirmation"
dsh --profile web --dump-config | grep -A4 'id: permission-rules' # verify the row
A complete 5-rule security baseline and the full schema live in docs/rules-format.en.md.
All tunables are Schemastery Config fields (changeable from cordis.yml). An id-targeted override replaces the whole row — restate every key you need.
| Key | Default | Meaning |
|---|---|---|
rulesFile |
.dsh/rules.yaml |
Rule file location; relative = resolved against the calling session's cwd, absolute = global and validated at mount |
fallbackPath |
(none) | Rule file used when per-cwd discovery finds nothing; validated at mount |
badFilePolicy |
fail |
Bad rule file: fail errors the pending tool call loudly (reloads keep the previous rules); ignore-with-warning warns and continues empty |
maxRules |
256 |
Hard cap on rule count across the effective source chain; larger files fail the load |
maxCachedWorkspaces |
512 |
Hard cap on cached per-workspace rule loads; the least-recently-used workspace (and its watcher) is evicted beyond it |
patternMode |
glob |
params/paths/when.env pattern flavor: glob or regex (tool names are always globs) |
watch |
true |
Chokidar watch + reload on change |
watchStabilityThresholdMs |
200 |
Reload debounce window (ms) |
language |
en |
/rules output language: en, zh, es, pt, hi (en/zh are the reference translations) |
caseInsensitivePaths |
(win32) | paths patterns and workspace-root comparison ignore ASCII case; defaults to true on Windows, false elsewhere |
audit |
all |
Audit granularity: all logs every hit AND passthrough; hits skips passthrough events |
searchUp |
false |
Walk parent directories from the session cwd and merge every found rule file, nearest first |
maxGlobStars |
2 |
Hard cap on unbounded */** quantifiers per glob pattern (backtracking-degree bound) |
enforce |
true |
false = dry-run mode: deny/ask hits are audit-logged with a dryRun marker (would-be action + real downstream outcome) and every call passes through — trial a policy before enforcing it |
allowUnmarkedAudit |
false |
Hosts whose Session.append predates the ignorable marker (the 0.1.0-rc.6 line) write audit events unmarked, making sessions unresumable on stricter builds: the plugin detects them and disables session-log audit with a one-time warning. Set true to opt back into the in-session trail (repair existing logs with scripts/repair-session-logs.mjs) |
/rules list the active rules, their source files, and any last-reload error
/rules list explicit alias for the bare listing
/rules reload re-read the rule-file chain for this workspace
/rules decisions [n] show the last n permission decisions of this session (default 10)
/rules test <tool> <json> dry-evaluate the rules against a hypothetical call, e.g. /rules test bash {"command":"git push origin main"}
/rules test also accepts leading flags: --cwd <dir> evaluates against another workspace, --env KEY=VALUE (repeatable) overrides host env for when.env, --agent <selector> (repeatable) supplies identity candidates for the agents dimension, and --platform <name> overrides the host platform for when.platform. In multi-file chains (e.g. searchUp), every listed rule line is attributed to its own source file.
Command output is UI-only — the model learns the rules only through the tool results they produce. language picks the output language. A JSON Schema for the rule file ships at docs/rules-format.schema.json (wire it up with # yaml-language-server: $schema=... for editor completion).
dsh-permission-rules produces ask; dsh-auto-review answers on the approval/request waterfall with a read-only second-model verdict (or delegates to humans). Mount both for the full closed loop.test/integration.spec.ts): permissionRules/decision → approval/asked → autoReview/verdict → approval/decided, with the reviewer replaced by a scripted mock.never approval policy and every fail-closed guarantee of the official harness stay untouched.paths candidates come only from a documented set of argument keys (at any nesting depth, depth-capped), and only workspace-relative paths match.ask decision is the end of its work.maxGlobStars unbounded star expansions; regex-mode patterns reject nested unbounded quantifiers and quantified overlapping literal alternations. (Regex chains like \d+\.\d+\.\d+ stay allowed — regex mode is the escape hatch, glob mode is the guarded default.)next()-safe delegation.Drifter-yh/dsh-tool-policy — deny-by-default tool policy; documented here to avoid duplicate implementation.dsh-auto-review — the AI-backstop half of the loop this plugin fronts.permissionRules/decision is appended with the envelope's ignorable: true marker, so any harness build loads the log — readers that do not know the out-of-repo type simply skip the audit record instead of refusing the session. Hosts whose Session.append predates the marker (the 0.1.0-rc.6 line) silently DROP it: the plugin detects them at runtime (peer-version pre-check + a probe of the appended envelope) and disables session-log audit with a one-time warning, so session logs stay loadable everywhere. Set allowUnmarkedAudit: true to opt back into the in-session trail; logs already written without the marker can be repaired with scripts/repair-session-logs.mjs before loading on hosts with required-on-read semantics.paths candidates are heuristic: only the documented argument keys feed path matching, and workspace-relative matching is ASCII-case-insensitive only when caseInsensitivePaths is on.Session logs written before the ignorable marker existed can be refused by newer harness builds (SessionFormatUnsupportedError). The shipped scripts/repair-session-logs.mjs rewrites only the targeted audit rows to carry ignorable: true, frame-preserving, with backups:
node scripts/repair-session-logs.mjs scan [--home DIR] # report foreign rows, change nothing
node scripts/repair-session-logs.mjs repair [--home DIR] [--dry-run]
--home defaults to $DSH_HOME/sessions (or ~/.dsh/sessions). See the script header for the full contract.
pnpm install # node ^22.19 || >=24
pnpm run typecheck # tsc, src + tests
pnpm run lint # eslint, src + tests + scripts
pnpm test # vitest: 139 tests, 9 suites
pnpm run test:coverage # coverage gate (90/80/90/90)
pnpm run build # tsc declarations + tsdown bundles (lib/)
pnpm run pack:check # build + pack (the published artifact)
node scripts/check-readme-sync.mjs # five-language README sync gate (also in CI)
See VERIFICATION.md for the headless end-to-end verification record (deny blocking a shell tool, ask routing through the approval seam, --dump-config).
ignorable marker (#2) and the upstream harness discussion; the v0.4.1 runtime host-capability detection and the documentation correction drew directly from that analysis.This project is one of the 15 DeepSeek Harness plugins maintained by PerryLink. If this one helps you, the others likely will too:
| Plugin | One-liner |
|---|---|
| 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 |
Apache License 2.0 © 2026 dsh-permission-rules contributors
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。