bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
上下文透镜:可视化每次请求的 token 用量(上下文构成、KV 缓存命中率),并提供每轮 / 每会话预算控制(超限提醒与拦截)(npm: `dsh-my-context`)。
dsh-my-context:DSH 上下文透镜 + 成本治理插件——上下文透镜统计每次请求的 token 用量与上下文构成(system / tools / user / 注入 / assistant / 工具结果)、可视化 KV 缓存命中率与上下文占用预警,按会话隔离、重启后恢复;成本治理提供每轮 / 每会话 token 预算,超限提醒(warn)或拦截(deny)。
cacheRead / (input + cacheRead),长会话的缓存收益一目了然。warnThreshold(默认 0.8)→ 预警、alertThreshold(默认 0.9)→ 告警、固定 0.95 → 严重分级,命中时给出压缩建议并记录「溢出预警」列表。$DSH_HOME/context/context.json(防抖 + 原子写),每会话请求记录上限 500 条 FIFO、告警 50 条。💡 npm 安装(普通用户推荐):dsh plugin --profile web add dsh-my-context --trust-lockfile——无需克隆本仓库;link 方式供本仓库开发者使用。git clone https://github.com/baosfeng/my-dsh-plugins.git
dsh plugin --profile web add link:<仓库路径>/plugins/dsh-my-context安装后重启 dsh web(server 端改动需重启;client 端改动硬刷新浏览器即可)。
插件行的 config: 块,均可省略:
配置项 · 默认值 · 说明 perTurn · 0 · 每轮 token 上限(0 = 不限制) perSession · 0 · 每会话 token 上限(0 = 不限制) mode · 'warn' · 超限行为:warn 提醒 / deny 拦截 warnThreshold · 0.8 · 溢出预警阈值(进度条变色) alertThreshold · 0.9 · 溢出告警阈值(95% 固定为严重)
预算与阈值也可在侧边栏面板中动态修改(POST /context/api/budget、POST /context/api/overflow)。
→ 上下文透镜模块文档 · CHANGELOG