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用户。

패키지
@2jumpsina/dsh-context-guard
호환성
미검증
버전
0.3.4
라이선스
MIT
최근 업데이트
2026. 9. 30.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:2JumpSinA/dsh-context-guard

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).

FieldDefaultRangeMeaning
enabledtrueboolMaster switch
localeautoauto|zh|enCopy language; auto detects per half — see Language
warnRatio0.450.1–0.95Occupancy (projectedTokens / contextWindow) at which "time to wrap up" fires
hardRatio0.600.1–1"Time to start a new session"; must be > warnRatio
hysteresisRatio0.050–0.2Hysteresis: re-arm only after falling back below warn − this value
cooldownTurns50–100How many turns of silence follow a level change
onResumetrueboolAlso warn when entering an already-high historical session
respectCompactiontrueboolStay quiet while automatic compaction is already reducing the level
crossSessionTrendtrueboolCount how many sessions crossed the line within the window, to escalate wording
trendWindowHours241–168Trend window (hours)
trendEscalateAt32–20Escalate wording when this many sessions hit hard inside the window
pushChannelnonenone|wechatExtrapolation channel (off by default)
pushMinLevelhardwarn|hardLevel from which extrapolation starts
pushCooldownMinutes100–1440Global minimum interval between two extrapolations
handoverOnWarntrueboolAuto-draft the handoff block once warnRatio is crossed
handoverPathHANDOVER.mdstringRelative to the session working directory, or an absolute path
handoverRefreshPercent51–25Refresh the draft every additional N percentage points of occupancy
handoverTurns61–20How many "prompt / reply" previews the draft carries
handoverFiles121–50How many recently written files the draft carries

The schema floor for warnRatio is 0.1: a value like 0.05 stops the entire plugin from mounting (ValidationError: invalid config: $.warnRatio expected number >= 0.1, and the state route then 404s).