2JumpSinA/dsh-context-guard ↗★ 1
@2jumpsina/dsh-context-guard
DSH context-pressure guard: when a session's next request would carry a dangerously large prompt, tell the user at turn end to write the handoff and start a new session. Consumes the official token-meter contextPressure projection; injects no prompt, registers no model-facing tool, so its context tax is zero. v0.3: at 45% occupancy the host half auto-drafts a machine-facts handover block into the session working directory; v0.2 added the host state route and an opt-in (default off) WeChat push; v0.3.2 onwards ships bilingual (zh/en, auto-detected per half) runtime copy; v0.3.3 was a docs-only release that fixed the install instructions once the package was live on npm; v0.3.4 fixes cross-platform absolute-path detection in resolveHandoverPath (a Windows-style path was treated as relative on Linux) and moves publishing to CI with npm trusted publishing (OIDC). 适合需要防止长对话Token超限并自动生成交接文档的DSH用户。
Install
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:2JumpSinA/dsh-context-guardREADME
Read the full README ↗Configuration
Editable on the settings page, all applied live; every config field is volatile ⇒ changing them needs no restart (changing source, however, does — see below).
| Field | Default | Range | Meaning |
|---|---|---|---|
enabled | true | bool | Master switch |
locale | auto | auto|zh|en | Copy language; auto detects per half — see Language |
warnRatio | 0.45 | 0.1–0.95 | Occupancy (projectedTokens / contextWindow) at which "time to wrap up" fires |
hardRatio | 0.60 | 0.1–1 | "Time to start a new session"; must be > warnRatio |
hysteresisRatio | 0.05 | 0–0.2 | Hysteresis: re-arm only after falling back below warn − this value |
cooldownTurns | 5 | 0–100 | How many turns of silence follow a level change |
onResume | true | bool | Also warn when entering an already-high historical session |
respectCompaction | true | bool | Stay quiet while automatic compaction is already reducing the level |
crossSessionTrend | true | bool | Count how many sessions crossed the line within the window, to escalate wording |
trendWindowHours | 24 | 1–168 | Trend window (hours) |
trendEscalateAt | 3 | 2–20 | Escalate wording when this many sessions hit hard inside the window |
pushChannel | none | none|wechat | Extrapolation channel (off by default) |
pushMinLevel | hard | warn|hard | Level from which extrapolation starts |
pushCooldownMinutes | 10 | 0–1440 | Global minimum interval between two extrapolations |
handoverOnWarn | true | bool | Auto-draft the handoff block once warnRatio is crossed |
handoverPath | HANDOVER.md | string | Relative to the session working directory, or an absolute path |
handoverRefreshPercent | 5 | 1–25 | Refresh the draft every additional N percentage points of occupancy |
handoverTurns | 6 | 1–20 | How many "prompt / reply" previews the draft carries |
handoverFiles | 12 | 1–50 | How many recently written files the draft carries |
The schema floor for
warnRatiois 0.1: a value like0.05stops the entire plugin from mounting (ValidationError: invalid config: $.warnRatio expected number >= 0.1, and the state route then 404s).