Project-level Local Context Engine for DeepSeek Harness: retrieval/compression/prioritization over history, code, files, user preferences and agent trajectories, producing a dynamic context window for any LLM.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:LFM097384/Context-Prism
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
ContextPrism 是一个面向 DeepSeek Harness (DSH) 的本地上下文引擎 / 动态 context window 插件。
完整架构文档见:docs/ARCHITECTURE.md
它会在调用任何 LLM 之前,对以下本地数据做 retrieval / compression / prioritization:
- 无限历史(会话 / 对话)
- 代码
- 文件
- 用户偏好
- Agent trajectory
然后输出一个受 token 预算约束的 动态 context window,可适配任意 LLM(DeepSeek / OpenAI / 其他兼容接口)。
特性
- DSH workspace / 项目级别
- 通过
ctx.workspaceRegistry自动定位当前 DSH workspace - 每个项目独立存储:
.lce/index.db
- 通过
- 进程内 JS 实现
- 纯 JS BM25 + Node 内置 SQLite FTS5
- 不依赖 Python / WSL
- 检索 / 压缩 / 优先级
- 混合检索:BM25 + 本地语义向量(hash n-gram embedding)+ 时间衰减 + 来源权重 + 用户优先级
- 压缩:完整保留高优先级片段,超预算时 extractive compression / 可选 LLM 摘要 + 截断
- 动态组装:
User Preferences → History → Trajectory → Code → Files
- LLM 摘要(可选)
- 配置
llmSummarization: true后,压缩阶段会尝试用 DeepSeek 生成摘要 - 未配置 API key 时自动回退到本地 extractive 压缩
- 配置
- DeepSeek / OpenAI 兼容
- 直接生成
deepseek-chat/deepseek-reasoner/ OpenAI 兼容 payload
- 直接生成
- 可视化
context_prism_dashboard生成独立 HTML 面板- DSH Web 侧边栏底部新增 ContextPrism 按钮,点击打开
/context-prism/dashboard实时面板
- 缓存与增量
- 检索 / 压缩结果 TTL+LRU 缓存
- 文件增量 ingest,按 mtime + size 跳过未变更内容
- 自动捕获 + 自动注入
- 自动把当前会话历史、assistant 消息、tool call / tool result 写入项目索引
- 自动增量索引项目文件(默认 60s 内最多扫描一次)
- 实时文件监听(
fs.watch+ 防抖重索引) - 在每次 LLM 请求前自动注入动态 context window,模型无需手动调用工具
目录
Context-Prism/
├── package.json # DSH 插件包
├── lib/index.js # DSH 插件入口
├── engine/ # JS 版 ContextPrism 核心
│ ├── models.js
│ ├── text_utils.js
│ ├── cache.js
│ ├── index.js
│ ├── sqlite_index.js
│ ├── retrieval.js
│ ├── prioritization.js
│ ├── compression.js
│ ├── ingest.js
│ ├── engine.js
│ └── providers.js
├── test/ # Node 测试
│ ├── engine.test.js
│ └── plugin.test.js
└── python/ # Python 参考实现(可选)
├── local_context_engine/
├── tests/
└── pyproject.toml
安装到 DSH
# 从 GitHub 安装(需要仓库公开后)
dsh plugin --profile web add github:LFM097384/Context-Prism
# 或在 profile 的 cordis.patch.yml 中激活
- insert:
- id: context-prism
name: 'context-prism-dsh-plugin'
config:
backend: 'auto'
defaultIndex: '.lce/index.db'
autoInject: true
autoIndexFiles: true
autoMaxTokens: 4000
autoReservedTokens: 800
autoIndexIntervalMs: 60000
fileWatch: true
watchDebounceMs: 2000
llmSummarization: false
summarizationModel: 'deepseek-chat'
summaryMaxTokens: 200
工具
| Tool | 作用 |
|---|---|
context_prism_build |
在调用 LLM 前构建动态 context window |
context_prism_ingest |
把文件/目录/history/trajectory 灌入本地索引 |
context_prism_status |
查看当前项目索引状态(chunk 数量、类型、来源) |
context_prism_dashboard |
生成并保存独立的 HTML 可视化面板到 .lce/dashboard.html |
context_prism_evaluate |
运行 A/B 检索评估(语义+BM25 vs BM25-only) |
context_prism_summarize |
用 LLM 或本地 extractive 方式总结文本 |
测试
npm install
npm test
Python 参考实现
cd python
python -m unittest discover -s tests -v
Links
More in this category
vectorize-io/hindsight#coding-agents★ 64023
Hindsight, agent memory that learns: long-term project memory with auto recall and retain, knowledge pages, deep reflection, and per-repo memory banks.
volcengine/OpenViking#examples/dsh-memory-plugin★ 42983
OpenViking memory and context bundle for DeepSeek Harness: pre-step auto-recall and profile injection, session capture, `viking://` URI guarding, and recall/write memory tools backed by an OpenViking server.
MemTensor/MemOS#memos-local-plugin★ 12530
Local-first memory plugin for DeepSeek Harness: layered L1/L2/L3 memory with automatic capture, manual memos_* retrieval tools, and a built-in memory viewer.
agentscope-ai/ReMe#dsh★ 3865
Connects DeepSeek Harness to ReMe's local-first, self-evolving personal knowledge base: automatically captures completed main-agent conversations as user-owned Markdown memory, searches conversations and source material through reme_search with BM25, optional embeddings, and wikilink expansion, and schedules daily memory consolidation.
zilliztech/memsearch#MemSearch★ 2962
Shared Markdown memory for DSH and other coding agents, with automatic capture, pre-step context injection, searchable recall, and memory-to-skill self-evolution through a review panel.
vshulcz/deja-vu#extensions/dsh★ 1694
Cross-session memory and context recovery across forty-five other coding agents (45+) on this machine, reading session files they already wrote before install (Claude Code, Codex, Cursor, Windsurf, Trae, Antigravity, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Qoder, Cline, Zed, Magpie and more): six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall injected into runtime context. Local BM25 CLI/MCP index, no LLM, no embeddings, no network (dsh plugin --profile web add dsh-deja).
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.