@dreamor/dsh-memvault

中文文档
0.7.0发布于 2026/11/07MITTypeScriptES Module构建来源已验证近 30 天下载 3134

DeepSeek Harness (dsh) Cordis plugin: auto-injects MemVault memories into the system prompt and auto-extracts memories at turn end.

原始使用文档
文档目录6 节
  1. What it does
  2. Install
  3. Overriding config (local development)
  4. Config
  5. Build
  6. Status

@dreamor/dsh-memvault

Cordis plugin bridging MemVault into DeepSeek Harness (dsh).

The dsh/Cordis API surface it relies on (ctx.systemPrompt.section(), session/event payloads, Plugin.Object resolution) was verified against the actual deepseek-harness source, not secondhand docs.

What it does

  • Auto-injection: keeps memory://session-inject cached and registers it as a system prompt section (ctx.systemPrompt.section()), refreshed eagerly at load and again on every turn/end. No agent tool call required.
  • Auto-extraction: on turn/end with reason.kind === 'completed', calls MemVault's notify_response with both that turn's assistant text and the user's own turn text (user/message events with source.kind === 'user') automatically. Passing the user's own words matters — MemVault's extractor signal words are first-person ("我偏好"/"我喜欢"), which match a user's own statement far more reliably than an assistant's restatement of it.

If you only want the raw 20 MemVault tools exposed to the model (no auto-injection/auto-extraction), you don't need this package — dsh's own @deepseek-ai/dsh-mcp-client does the same with zero code: each upstream server gets its own Cordis plugin instance via cordis.patch.yml (transport: stdio, serverName: memvault, command: <path to memvault-proxy>).

Install

Prerequisites: a working dsh install (e.g. npx @deepseek-ai/dsh web) and the memvault-proxy binary reachable from PATH (or point binaryPath at one — see the override section below).

Build, then install into a dsh profile from the repo's dsh-plugin/ directory:

cd dsh-plugin
npm install
npm run build      # tsc --strict
npx @deepseek-ai/dsh plugin --profile <profile> add "$PWD"

dsh plugin add runs the equivalent of pnpm add and appends the package to that profile's dsh.profile.bundles automatically — no manual edit of the profile's cordis.patch.yml is needed for a default install. The plugin ships a cordis.patch.yml that registers one memvault entry with the default config (mode: spawn, embeddingProvider: native, …).

Verify the composed config, then start:

npx @deepseek-ai/dsh --profile <profile> --dump-config   # 组合后应只有一条 id: memvault 且字段正确
npx @deepseek-ai/dsh <profile> --port 0                  # 实际启动方式以你的 dsh 用法为准

At startup the plugin spawns memvault-proxy on port 3778 and probes http://127.0.0.1:3778/health until the server is ready. Transport, port and db overrides are passed as CLI flags, so an existing ~/.memvault/proxy.yaml (including upstreams and markdown_dir) is loaded but never rewritten. To confirm the injection actually lands: start a real conversation turn, then decompress the session log (zstd -d ~/.dsh/sessions/.../session.jsonl.zstd) and check that request/header.data.header.system contains the injected [MUST]/[REF] blocks.

Overriding config (local development)

To override a single field (e.g. point binaryPath at a locally built memvault-proxy), add a bare-id override patch to the profile's cordis.patch.yml and rewrite the whole config block — an override replaces the entire config, it does not merge per-field:

- id: memvault
  name: '@dreamor/dsh-memvault'
  config:
    mode: spawn
    db: '~/.memvault/data.db'
    port: 3778
    binaryPath: /absolute/path/to/memvault-proxy
    embeddingProvider: native
    agentId: dsh
    injectOnAssemble: true
    extractOnTurnEnd: true

The cordis.patch.yml this plugin ships wraps its entry in insert: because the entry doesn't exist in any earlier layer. A bare - id: patch is an override that requires the id to already exist and errors with patch: entry "memvault" not found otherwise — an override patch must rewrite the whole config block, it never merges per-field.

Config

FieldDefaultMeaning
modespawnspawn manages a memvault-proxy child process; attach connects to url.
db~/.memvault/data.dbUsed when mode: spawn.
port3778Used when mode: spawn.
url''Used when mode: attach, e.g. http://127.0.0.1:3778/mcp.
binaryPath'' (resolved from PATH)Used when mode: spawn.
embeddingProvidernativeUsed when mode: spawn — forced as MEMVAULT_EMBEDDING_PROVIDER in the child's env, so it can't accidentally inherit dsh's own OPENAI_API_KEY.
agentIddshReported to MemVault on every call.
injectOnAssembletrueToggle auto-injection.
extractOnTurnEndtrueToggle auto-extraction.
inferOutcomeOnSessionEndfalseAuto-call infer_outcome at session end (session/disposed) to record a task outcome/episode for bench and lesson reflection — mirrors the Claude/Codex plugin's MEMVAULT_HOOK_OUTCOME knob.

Build

npm install
npm run build
npm test

Status

Builds clean (tsc --strict) against the real, npm-published @deepseek-ai/[email protected], @deepseek-ai/[email protected], @deepseek-ai/[email protected], and @deepseek-ai/[email protected] packages (not mocks — see src/index.smoke.test.ts, which mounts the plugin on a real Context alongside the real SystemPrompt service and asserts ctx.systemPrompt.assemble() actually contains the injected section).

Fully verified end to end against a real dsh install (npx @deepseek-ai/dsh web, v0.1.0-rc.6). Four real bugs were found and fixed in the course of the verification:

  1. cordis.patch.yml insert vs. override patch semantics (a bare id patch requires the id to already exist).
  2. memvault-proxy inheriting a stray OPENAI_API_KEY from dsh's own process env, plus a stale (pre-native-embedding) local binary.
  3. The eager injection-cache refresh at apply() time racing memvault-proxy's own startup (fetch failed).
  4. mcp-client.ts permanently caching a failed connection attempt — connected ??= (...) memoized on the first (raced, failing) call, so every later call kept re-rejecting forever, never retrying even after the proxy came up.

With all four fixed, a real conversation turn's session log (~/.dsh/sessions/.../session.jsonl.zstd, decompressed with zstd -d) shows the actual request/header.data.header.system text containing MemVault's injected [MUST]/[REF] memories, and a direct notify_response call against the running memvault-proxy moved MemVault's memory count from 8 to 10 (new preference/fact memories actually saved to Inbox).

A follow-up round extended notify_response to also extract from the user's own turn text — MemVault's extractor signal words are first-person, so a user's own statement ("我偏好用 tabs") matches far more reliably than an assistant's restatement of it ("你偏好用 tabs" used to be silently rejected; the signal-word list was also extended with second/third-person mirrors). Verified against the real running memvault-proxy: memory count went from 10 to 13 across three scenarios, with source:user/source:assistant tags on the results.

DSH 0.2 compatibility has also been checked with @deepseek-ai/dsh-*@0.2.0-rc.2 and a real [email protected] plugin add / --dump-config run; the plugin keeps its wildcard peer range so DSH 0.1 installs remain usable.

版本与发布记录

@dreamor/dsh-memvault 共发布 22 个版本,首次发布于 2026/09/11;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/11/076 天前
0.6.122026/11/049 天前
0.6.112026/10/3014 天前
0.6.102026/10/2915 天前
0.6.92026/10/2915 天前
0.6.82026/10/2816 天前

关于 @dreamor/dsh-memvault 的常见问题

@dreamor/dsh-memvault 是什么?

DeepSeek Harness (dsh) Cordis plugin: auto-injects MemVault memories into the system prompt and auto-extracts memories at turn end.

如何安装 @dreamor/dsh-memvault?

在项目目录运行 npm install @dreamor/dsh-memvault,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@deepseek-ai/cordis(^4.0.0)、@deepseek-ai/dsh-llm(*)、@deepseek-ai/dsh-session(*)、@deepseek-ai/schemastery(*)、@deepseek-ai/dsh-system-prompt(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dreamor/dsh-memvault 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dreamor/dsh-memvault 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dreamor/dsh-memvault 可以商用吗?

@dreamor/dsh-memvault 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dreamor/dsh-memvault 的下载量有多少?

根据 npm 官方下载统计,@dreamor/dsh-memvault 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,134 次,日均约 104 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dreamor/dsh-memvault 还在维护吗?

最新版本 0.7.0 发布于 2026/11/07(6 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/09/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。