EvilIrving/dsh-context-proxy
On-demand context retrieval for DeepSeek Harness: context_query / context_slice / context_grep tools.
已收录
0
Session
Bundle 已验证
预览
功能介绍
按需取回薄层:context_query / context_slice / context_grep 三个工具读取已持久化的历史,引用可回放。
适合
- 需要按需取回已持久化历史片段的长会话。
- 需要引用规范会话事件或本地 spill 文件、且引用可回放的工作流。
- 需要轻量查询、有界上下文窗口和 grep 式检索,同时不改写既有上下文的 agent。
不适合
- 相关内容已完整保留在当前对话中的短会话。
- 没有 `sessionQuery` 后端的部署;检索工具会返回错误而不是结果。
- 回退检索必须使用正则表达式的场景;没有 spill 路径时,`context_grep` 仅执行忽略大小写、空白灵活的字面量扫描。
README
dsh-context-proxy
Thin on-demand context-retrieval layer for the DeepSeek Harness.
Automatic truncation, spill-to-disk, compaction, and token metering are already
owned by output-retention, spill-policy, compaction-basic, and
session-query. This package adds only the missing piece: three model-facing
tools that read already-persisted history back on demand.
Install
dsh plugin --profile <name> add github:EvilIrving/dsh-context-proxy
Or, from a checkout:
dsh plugin --profile <name> add ./dsh-context-proxy
The bundle patch inserts one plugin row (dsh-context-proxy). sessionQuery
and subprocess are optional backends (ctx.get): without a sessionQuery
backend each tool degrades to an isError result instead of waiting forever.
Tools
| Tool | Backing seam | Returns |
|---|---|---|
context_query |
sessionQuery.filterEvents |
lightweight { seq, type, text } matches by seq/type/surface/text |
context_slice |
sessionQuery.readEvent |
one event plus a bounded before/after window |
context_grep |
subprocess (packaged rg) or sessionQuery.filterEvents
|
matches with { text, citation }
|
Citations are replay-safe: context_query/context_slice cite session:<seq>
(rebuildable from the canonical log), and context_grep cites either a spill
path (path:line, fast local path) or session:<seq> (semantic-text fallback
when no spill path is supplied or available).
Config
export interface Config {
readWindowDefault: number // default before/after for context_slice (default 0)
grepMaxBytes: number // rg stdout in-memory cap (default 1 MiB)
rgGraceMs: number // rg termination grace (default 5000)
}
Dependencies
-
sessionQueryandsubprocessare optional services read viactx.get(...). A missingsessionQuerybackend degrades each tool to anisErrorresult (session query backend unavailable) instead of leaving the plugin waiting forever; the same applies tosubprocessforcontext_grepwith an explicit path. -
toolsis a hard dependency (inject). - The packaged ripgrep binary comes from
@vscode/ripgrep— the same mechanismdsh-tool-fs-searchuses — so no systemrginstall is required and no shell layer exists between the argv vector and ripgrep.
Model Experience
Request context and condition
What the model sees
Three tool schemas (context_query, context_slice, context_grep) are
registered into the agent’s tool set. Each result is a compact JSON object of
matches/items plus citations; no prose is returned for the model to parse ids
out of.
Token effect
Zero-direct effect until a tool is invoked; each invocation’s cost is bounded
by the query/slice window and the grepMaxBytes cap.
KV Cache effect
Append-only: tool results append to the surface; they never rewrite earlier request tokens.
Known Limitations and Deferred Work
-
context_grepline parse ispath:line:text— a spill path containing a newline (not expressible in the durable locator) would confuse the parser; absolute spill paths never contain one. -
Fallback text scan is literal, not regex — when no spill path is
supplied,
context_grepfalls back tosessionQuery’s literal, case-insensitive, whitespace-flexible scan, not a regex search. - Bundle writing is not sandboxed — nothing here writes files; retrieval only reads through the seams.
常见问题常见问题
在启用了 DSH 的终端中执行已验证命令 dsh plugin --profile default add github:EvilIrving/dsh-context-proxy。命令会解析公开 package 元数据,并保持插件与本页展示的目录身份一致。
兼容性以页面上展示的 bundle 与 profile 状态为准。如果某个 profile 尚未检测到,请先保持禁用,并在生产启用前阅读仓库文档。
GitHub 链接和 activity 元数据是 release 与维护状态的来源。新版本发布后重新查看本页,确认目录已经观察到最新版本。