@hy-sde-org/dsh-tool-memory

中文文档
0.2.1-rc.5发布于 2026/11/01MITTypeScriptES Module

Model-facing long-horizon memory tools (retain, recall, reflect, memory_edit, learn) over the ctx.memory service, plus first-turn project-memory prompt injection — a standalone plugin for DeepSeek Harness with no upstream harness changes required.

原始使用文档
文档目录4 节
  1. The six tools
  2. Prompt injection
  3. Config (the tool-memory row)
  4. Tests

@hy-sde-org/dsh-tool-memory

The model-facing memory surface for DeepSeek Harness — the six tools retain, recall, reflect, memory_edit, learn, and mine_sessions over the host ctx.memory service, plus a memory:project system-prompt section that reloads the session's project memory at the start of every session. Ported from the @oh-my-pi coding-agent memory surface; storage lives in @hy-sde-org/dsh-memory.

This package is agent-plane: it mounts as a preset row and resolves the host memory service, registering no service of its own. It installs as a standalone plugin for stock DeepSeek Harness (dsh-v0.2.0-rc.2 and later) — see @hy-sde-org/dsh-memory for the install recipe and the preset example.

The six tools

  • retain — store one or more durable facts (user preferences, project decisions, architectural choices) for future sessions. Batch related facts; entries are self-contained, normalized, and deduplicated.
  • recall — relevance-ranked search over bank + lessons + summary. Returns ids that round-trip through memory_edit. Use proactively before questions about past decisions or preferences. When a host sessionQuery service is mounted, past-session hits merge in as a session source tier.
  • reflect — synthesize an answer across many stored memories (blends, unlike recall). Grounding is memory-only; verify repository facts.
  • memory_edit — update (replace content/importance), forget (hard delete), invalidate (soft supersede, optional replacement_id). Lesson and summary entries are read-only facts.
  • learn — capture one durable lesson (what/when/why) into learned.md; write-path neutralization strips prompt-injection markers and secrets.
  • mine_sessions — harvest reusable lessons from your own past sessions (digests from compaction summaries, failures from turn/end error reasons, all-completed todos), stored as learn entries with session provenance and deduped. Needs a host sessionQuery service; without one it reports unavailable rather than erroring — this standalone ships the bridge (session-history.ts, ctx.get('sessionQuery') duck-typed) but no session backend.

Prompt injection

apply() registers systemPrompt.section({ name: 'memory:project', order: 150 }) whose text is evaluated at each assembly and returns the calling session's project memory — memory_summary.md + learned.md, combined and head-tail truncated to injectionMaxChars (default 16000 chars) — or '' for a project with no memory yet. Stored memory remains literal, so complete {{variable}} groups in it do not resolve as prompt variables. The session identity comes from context.agent.session.header.cwd, so each project sees its own bank and a fresh process picks it up on the very first turn.

Config (the tool-memory row)

KeyDefaultMeaning
root<harness home>/memoriesMust match the ctx.memory row's root.
injectionMaxChars16000Combined char budget for the injected summary + lessons.
enabledtrueSet false to disable prompt injection while keeping the tools.

Tests

pnpm -r --filter @hy-sde-org/dsh-tool-memory test

版本与发布记录

@hy-sde-org/dsh-tool-memory 共发布 11 个版本,首次发布于 2026/08/26;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.2.1-rc.5latest2026/11/012 天前
0.2.1-rc.32026/10/259 天前
0.2.1-alpha.42026/10/1618 天前
0.2.1-alpha.22026/10/1321 天前
0.2.0-rc.22026/10/031 个月前
0.1.7-rc.22026/09/291 个月前

关于 @hy-sde-org/dsh-tool-memory 的常见问题

@hy-sde-org/dsh-tool-memory 是什么?

在ctx上面向模型的长期记忆工具(保留、回忆、反映、memory_edit、学习)。内存服务,加上第一次项目内存提示注入- DeepSeek线束的独立插件,无需更改上游线束。

如何安装 @hy-sde-org/dsh-tool-memory?

在项目目录运行 npm install @hy-sde-org/dsh-tool-memory,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@deepseek-ai/cordis(~4.0.5)、@deepseek-ai/dsh-tools(^0.2.1-rc.5)、@hy-sde-org/dsh-memory(^0.2.1-rc.5)、@deepseek-ai/dsh-system-prompt(^0.2.1-rc.5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@hy-sde-org/dsh-tool-memory 支持 TypeScript 吗?

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

@hy-sde-org/dsh-tool-memory 支持 ESM 还是 CommonJS?

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

@hy-sde-org/dsh-tool-memory 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@hy-sde-org/dsh-tool-memory 可以商用吗?

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

@hy-sde-org/dsh-tool-memory 还在维护吗?

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