overact/dsh-context-management ↗★ 0

@local/dsh-context-management

提供窗口化上下文压缩、私密笔记与历史召回 适合需要精细化管理上下文、记录会话私密笔记并分页召回历史的用户。

套件
@local/dsh-context-management
相容性
待驗證
Harness 依賴範圍
>=0.1.7-alpha.1
版本
0.3.0
授權
MIT
最近更新
2026年9月26日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:overact/dsh-context-management

Usage

/ctx toggles the plugin; /compact runs the current compaction mode. The toggle applies to every session of the running DSH instance, not to a single chat tab.

When the model calls new_context it gets back requested, not a reset: the switch is scheduled for the next safe step boundary, after the current step's tool results are fully written to history. Explicit switch requests are honoured even when DSH's auto compaction is off.

The web "Context management" settings page uses DSH 0.1.7 configForms and shares its backend setting with /ctx. Read failures, read-only connections and failed saves are never shown as a successful toggle. Settings changes need no restart; after upgrading the plugin code, reload the plugin or restart DSH, then refresh the page.

Configuration

- insert:
    - id: context-management
      name: '@local/dsh-context-management'
      config:
        enabled: true
        overrideCompaction: true
        injectTools: true
        defaultStrategy: window      # or native: models not listed in modelPolicies use native summaries
        modelPolicies: []            # e.g. [{ provider: deepseek, model: deepseek-chat, strategy: native }]
        handoffSummary: generated    # or extractive: no extra model call
        handoffMaxChars: 16000       # 8000–32000
KeyDefaultMeaning
enabledtrueEnable context management for every session of this DSH instance; this is what /ctx toggles
overrideCompactiontrueReplace native summaries with window handoffs (summary + goal/todo + recent instructions + notes + window index) plus history recall
injectToolstrueProvide the notes/history/new_context tools; when off, native summary compaction is used
defaultStrategywindowDefault compaction strategy; native makes unlisted models use native summaries
modelPolicies[]Per exact provider/model strategy overrides; the first match wins
handoffSummarygeneratedBody of the handoff: generated calls the native summary model once; extractive only excerpts records
handoffMaxChars16000Maximum characters of the window handoff

injectTools: false removes the tools and uses native summaries, so history is never trimmed without a way to recover it. overrideCompaction: false keeps the notes/history tools while regular auto compaction and /compact use native summaries; the model can still request new_context explicitly.

Unloading the host plugin removes the tools, the settings registration and the contextWindows service; preset engines then fall back to native summaries.

DSH web preset scope

The web host provides no global compaction; compaction engines live in each preset's isolated scope. The loader cannot patch rows nested in a preset's config.plugins by id (only group: true lists are indexed), and a patch cannot rename a row. So scripts/sync-presets.mjs copies each dsh-web-app preset that mounts dsh-compaction-basic (currently standard/ptc/cordis) in full into a generated block of the profile patch, swapping only that row for @local/dsh-context-management/compaction; presets defined by the profile itself are swapped in place.

node scripts/sync-presets.mjs            # generate/refresh (saves cordis.patch.yml.pre-sync first)
node scripts/sync-presets.mjs --check    # exit code 1 when the block is stale for the installed DSH
node scripts/sync-presets.mjs --remove   # delete the block and restore native rows (full rollback)

Re-run it after every DSH upgrade, or those three presets stay on the old definitions. Running --check from your DSH start-up script gives a log warning when they go stale. Do not edit standard/ptc/cordis in the web editor: the script refuses to write if it finds a same-id override outside the generated block.