2JumpSinA/dsh-context-guard ↗★ 1

@2jumpsina/dsh-context-guard

在上下文超限前提示用户开启新会话 适合需要防止长对话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).