Causal memory for dsh: a zero-dependency MCP stdio bridge that mounts the 17 tools of the causal-memory server under clean names (no mcp__ prefix) — decision → outcome edges with typed relations (caused / enabled / prevented) in a local SQLite store that survives compaction — plus a pinned system-prompt section. Requires the causal-memory server binary on PATH (pip install causal-memory, or a prebuilt release).
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:JingxuanC/causal-memory#path:/dsh-plugin
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.
DeepSeek Harness 原生记忆插件:把 causal-memory 的 17 个工具以干净命名
(无 mcp__ 前缀)挂到 DSH 的 ctx.tools,并注入一条系统提示词段落
(order 300),告诉模型何时查阅因果记忆库。
前置:causal-memory 二进制
插件按 DSH 惯例解析服务端二进制(不写死路径),四选一:
- pip 安装(推荐,无需 Rust 工具链):
会把pip install causal-memorycausal-memory命令装到 PATH 上,插件自动解析到它。 - 下载预编译二进制:从 GitHub Releases
下载对应平台(Windows / macOS / Linux × x64 / arm64)的压缩包,解压后把
causal-memory放到 PATH 上(如~/bin或/usr/local/bin)。 - 本仓库开发构建(克隆到任意位置即可):
插件会自动找到cargo build --release --bin causal-memory<仓库>/target/release/causal-memory。 - 显式指定:
config.command配置项或CAUSAL_MEMORY_BIN环境变量。
安装
cd <causal-memory 仓库路径>
dsh plugin --profile web add "$PWD/dsh-plugin"
以 link: 方式安装(pnpm link)——修改本目录代码即时生效,无需重装。
启用
本包声明了 dsh.bundle manifest(cordis.patch.yml),通过
dsh plugin add 安装时 insert 会自动合并,无需手工配置。
仅当以 link: 方式做开发安装时需要手工确认
~/.dsh/profiles/web/cordis.patch.yml 的 insert 列表包含:
- id: causal-memory-plugin
name: causal-memory-dsh-plugin
重启 dsh web 后生效。
配置(可选,均省略时有合理默认)
| 字段 | 默认 | 说明 |
|---|---|---|
command |
自动解析 | 二进制路径:config.command → CAUSAL_MEMORY_BIN → 仓库 target/release → PATH 裸名 |
dbPath |
~/.local/share/causal-memory/causal.db |
SQLite 路径(或 CAUSAL_MEMORY_DB) |
toolCallTimeoutMs |
60000 |
单次工具调用超时 |
exclude |
[] |
不挂载的工具名数组 |
failOnStartupError |
true |
启动连接失败时是否让插件激活失败(默认失败并附安装提示;显式设 false 则降级为仅记日志) |
env |
{} |
透传给服务端子进程的额外环境变量(优先级高于当前环境)。非字符串值会被丢弃并记一条 warn,因此 !!js 表达式算出 undefined 不会毒死子进程 |
用 env 打开 LLM 能力(可选)
服务端从环境变量读 LLM / Embed 配置。缺了它,依赖 LLM 的工具会静默降级成规则回退——resolve_updates、reconstruct_lesson 的叙事与 calibrate、以及 remember 的自动抽取都会被影响:
- id: causal-memory-plugin
name: causal-memory-dsh-plugin
config:
env:
# 注意:此值是 base URL,源码会自行追加 /chat/completions
CAUSAL_MEMORY_LLM_API: https://api.deepseek.com/v1
CAUSAL_MEMORY_LLM_KEY: !!js process.env.DEEPSEEK_API_KEY || ''
CAUSAL_MEMORY_LLM_MODEL: deepseek-chat
⚠️ CAUSAL_MEMORY_LLM_API 必须填 base(https://api.deepseek.com/v1)。填成完整路径 .../v1/chat/completions 会被再拼一次,得到 .../chat/completions/chat/completions → 404,而工具不会报错,只会悄悄退回规则路径。密钥建议走环境变量或 vault,不要明文写进本文件。
工具清单(17 个)
record_decision · record_fact · remember · search_causal ·
search_facts · search_memory · search_patterns · causal_directory ·
trace_cause · trace_cause_chain · intervention_query ·
counterfactual_query · prediction_report · invalidate_decision ·
invalidate_pattern · resolve_updates · reconstruct_lesson
(工具列表运行时从服务端动态发现,服务端升级后无需改插件。)
卸载
dsh plugin --profile web remove causal-memory-dsh-plugin
# 并从 ~/.dsh/profiles/web/cordis.patch.yml 删除对应 insert 行
设计说明
- 零运行时依赖:只用 Node 内置模块;JSON-RPC over stdio 直接与 causal-memory 二进制通信(rmcp 的新行分隔 JSON 线协议)。
apply为 async:与 DSH 官方@deepseek-ai/dsh-mcp-client同款时序 (cordis 4.x 会等待 async apply 的 promise,工具在激活前完成握手与发现)。- 所有注册均为 effect 作用域:卸载时注销工具并终止子进程。
- 与 MCP 桥(
@deepseek-ai/dsh-mcp-client,工具名mcp__causal-memory__*) 二选一启用,避免双份工具。
Links
More in this category
vectorize-io/hindsight#coding-agents★ 54464
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★ 40976
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★ 12136
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★ 3702
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★ 2802
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★ 1321
Reads the session files forty-two other coding agents on this machine already wrote (Claude Code, Codex, Cursor, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Cline, Zed and more), including sessions from before it was installed: six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall added to the runtime context. Local BM25 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.