DSH HUB
首页插件商店插件包社区排行榜资源发布指南
插件源码
返回插件目录

137qufh /

137qufh/dsh-ctxpatch

仅 Topic 仓库

上下文修补器(DeepSeek Harness 插件):海马体式情景记忆、跨会话无损续接、线索联想复习、Prefix Cache 纪律与 CSCR-Bench 评测基准

★ 0 Stars0 Forks0 IssuesN/A 社区评分0 已确认安装
查看 GitHub
README来源: main@6c9a272c

上下文修补器 dsh-ctxpatch

license node dsh

给 DeepSeek Harness(dsh)补上一块海马体:原始对话一轮不丢,线索可以「稍加复习」式地跨会话联想,交接胶囊是可核对的指针而不是摘要,并且不把 DeepSeek 的前缀缓存前缀写坏。

用户回合 ──► L0 情景原文(只追加)
                │
                ▼
            L1 结构化账本(决定 / 待办 / 产物 / 继续点,带证据与时效)
                │
                ▼
            L2 联想图 + Personalized PageRank(模式分离 / 模式完成)
                │
                ▼
            L3 中英混合索引(分词 FTS5 + 代码 trigram,可选向量)
                │
                ▼
        工作记忆胶囊(2K–4K,冻结一次)+ 工作区漂移报告

English overview

dsh-ctxpatch is a DeepSeek Harness plugin and a harness-independent memory engine. It stores every turn in a local SQLite file, keeps a typed ledger that cites those turns, and recalls them with bilingual full-text search plus a graph walk. A handoff compiles a frozen working-memory capsule (resume point, active decisions, open loops, file hashes) instead of a lossy summary. New sessions boot from that capsule without rewriting the prefix, which is what DeepSeek's prompt cache needs. CSCR-Bench has 40 probes across four domains. On the seeded offline run, ctxpatch-full scores 1.000 macro versus 0.350 for lexical RAG and 0.000 for naive summaries. Mean capsule size is 287 tokens; the cache probes' second-request prefix hit rate is 0.987.

安装

需要 Node.js ≥ 22.13(node:sqlite;24+ 起该模块更稳定)。

dsh plugin add dsh-ctxpatch

从本仓库安装:

pnpm install
pnpm build
dsh plugin --profile demo add ./packages/dsh-ctxpatch

Git 安装会跑 prepare 编译 TypeScript。pnpm 10 需要在 profile 的 pnpm-workspace.yaml 里允许该包的构建脚本。详见 使用指南。

记忆库默认在 $DSH_HOME/ctxpatch/memory.db,按工作区隔离。

命令与工具

入口 作用
/handoff 冻结胶囊,记下覆盖到的 seq、账本版本、文件 SHA-256、git HEAD
/recall <线索> 多跳回忆,或按会话号列出指针
/ctx-status 规模、检查点、前缀是否仍不可变、缓存命中率
ctx_recall / ctx_restore / ctx_ledger / ctx_sessions 给模型调用的 JSON Schema 工具

也可以直接说「这个对话满了,我们从下一个对话开始」或 session is full, continue in next session。下一会话启动时注入一次冻结胶囊,并对照工作区文件报告漂移。

CSCR-Bench(种子 20261129,40 题,离线,无 API key)

每类 4 题,覆盖重构、库表迁移、竞态和论文笔记,并带干扰会话。单元格是该类准确率。平均胶囊 287 token(最长 975,上限 4000)。缓存类题的第二次请求前缀命中率 0.987。

任务 no-memory naive-summary lexical-rag no-graph no-ledger full
逐字针回忆 0.00 0.00 1.00 1.00 1.00 1.00
释义线索(稍加复习) 0.00 0.00 0.75 0.75 1.00 1.00
跨会话多跳 0.00 0.00 0.00 0.00 1.00 1.00
决定一致性 0.00 0.00 0.00 1.00 0.00 1.00
代码续接 0.00 0.00 0.75 1.00 1.00 1.00
未闭环 0.00 0.00 0.00 1.00 0.00 1.00
时间顺序 0.00 0.00 0.00 1.00 0.00 1.00
拒绝编造 1.00 0.00 1.00 1.00 1.00 1.00
多次交接取回 0.00 0.00 0.00 1.00 1.00 1.00
前缀缓存 0.00 0.00 0.00 1.00 1.00 1.00
宏平均 0.100 0.000 0.350 0.875 0.700 1.000

多跳只在有图时成立。被取代的决定、已关闭的待办和时间顺序只在有账本时成立。有一个释义题要靠术语边才能从代号走到密钥,所以 no-graph 的释义准确率是 0.75。方法和原始结果在 docs/BENCHMARK.md 与 benchmarks/results/latest.md。

pnpm test
pnpm bench
# 可选,需要密钥才会打到 api.deepseek.com
DEEPSEEK_API_KEY=... pnpm bench:live

仓库

路径 内容
packages/ctxpatch-core 不依赖 Harness 的记忆引擎
packages/dsh-ctxpatch Cordis 插件、cordis.patch.yml
packages/cscr-bench CSCR-Bench
docs/ 架构、评测、使用说明

设计说明:docs/ARCHITECTURE.md。使用说明:docs/GUIDE.md。

许可

MIT

—/ 5

暂无评分

需要先验证清单

Commit 6c9a272cf3aa

社区评论

还没有评论,来写第一条。

DSH HUB

社区维护的 DSH 插件索引。不是 GitHub 或 DeepSeek AI 的官方产品。

社区资源API关于