dsh-memory-connect
by Asher-2000
跨会话记忆插件 (v0.3.0):自动提取、SQLite FTS5 索引、RRF 语义召回、定时维护、LLM 智能合并(自动接入 ctx.llm)、上下文爆炸防护、全局身份 Soul(~/.dsh/soul.md)。零配置。
Cross-session memory plugin for DSH (v0.3.0): auto-extraction, SQLite FTS5 indexing, RRF semantic recall, scheduled maintenance, LLM-powered consolidation via ctx.llm, context explosion prevention, and global Soul identity via ~/.dsh/soul.md. Zero-config.
安装
dsh plugin --profile web add github:Asher-2000/dsh-memory-connectGitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试
安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗
安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。
README
目录
- Overview
- 🚨 v0.4.0 — The "it actually works now" release
- Features
- 🧠 Global Soul (Identity)
- How it works
- Example Soul file
- Installation
- Configuration
- Basic Options
- Scheduler Options
- Context Explosion Prevention Options
- Soul Options
- API
- Search Memories
- Recall for Session
- Synchronous Recall (for system-prompt providers)
- Latest User Text (from dsh session logs)
- Store Memory
- Manual Maintenance
- Context Explosion Prevention
- How It Works
- Output Example
- Memory Types
- Development
- License
- 中文
- 概述
- 🚨 v0.4.0 — "这次真的能跑"版本
- 核心功能
- 🧠 全局身份 (Soul)
- 工作原理
- Soul 文件示例
- 快速开始
- 许可证
跨会话记忆插件 — 让 AI Agent 拥有持久记忆和全局身份
Cross-session memory plugin for DeepSeek Harness (DSH)
English | 中文
Overview
dsh-memory-connect is a cross-session memory sharing plugin for DeepSeek Harness. It automatically extracts, stores, and recalls memories across sessions, giving your AI agent persistent, intelligent memory with context explosion prevention and global Soul identity.
Zero-config — works out of the box with SQLite FTS5 and DSH's built-in LLM.
🚨 v0.4.0 — The "it actually works now" release
v0.3.0 registered the service but never instantiated it (Cordis lazily constructs services — passing the class to
ctx.provide()means the constructor never runs), and the "recall" feature wrote a computed context to a field no one ever read. In practice the plugin did nothing.v0.4.0 fixes the activation chain and wires recall into the system prompt: a
systemPrompt.contextprovider injects## Related Memories from Previous Sessionson every turn. Zero-config runnable: a baredsh plugin addused to crash onconfig.openAt(Cordis passesundefinedconfig when the patch has noconfig:block) —apply()now fills in full defaults (DB at~/.dsh/memory.db,openAt: startup). Verified end-to-end on dsh v0.1.1-rc.2 / Node 24: tell session A "my cat is named Mimi", start a fresh session B and ask — the model answers correctly from memory.See CHANGELOG.md for the full breakdown.
Features
| Feature | Description |
|---|---|
| 🧠 Global Soul | Persistent identity across all workspaces via ~/.dsh/soul.md |
| 🔍 Auto Extraction | Extracts facts, preferences, decisions, and context from conversations |
| 🧠 Cross-Session Recall | FTS5 keyword recall injected into the system prompt every turn (recency fallback when no query text is available) |
| 🛡️ Context Explosion Prevention | Token budget management prevents context window overflow |
| ⏰ Scheduled Maintenance | Automatic periodic decay and consolidation via built-in scheduler |
| 🤖 LLM Consolidation | Intelligent memory merging using DSH's built-in ctx.llm (zero-config) |
| 📉 Memory Decay | Old, unused memories naturally fade; frequently accessed ones persist |
| 🎯 Smart Prioritization | Memory selection based on relevance × recency × frequency |
| 🗜️ Memory Compression | Automatic compression when approaching token limits |
🧠 Global Soul (Identity)
The Soul feature provides a persistent identity that follows you across all workspaces.
How it works
- Create
~/.dsh/soul.mdwith your identity information - The plugin automatically loads and injects it into every session
- Your preferences, tech stack, and coding style are always available
Example Soul file
# 🧠 Soul — Global Identity
## 👤 Identity
- GitHub: your-username
- Role: Developer/Designer/Product Manager
## 💻 Tech Stack
- TypeScript, React, Node.js, DSH/Cordis
## 🎨 Coding Style
- Functional programming
- ES Modules
- Zero-config preferred
## ⚠️ Preferences
- No class components
- No redundant comments
Installation
⚠️ Not on npm yet — install from GitHub (v0.4.0):
# 方式 A:dsh plugin add(推荐,自动装入 profile)
dsh plugin --profile <你的profile> add github:Asher-2000/dsh-memory-connect
# 方式 B:npm 直接装 git tag
npm install github:Asher-2000/dsh-memory-connect#v0.4.0
# 方式 C:本地源码 link(开发/调试用)
git clone https://github.com/Asher-2000/dsh-memory-connect.git
cd dsh-memory-connect
dsh plugin --profile <你的profile> add link:/path/to/dsh-memory-connect
Add to your DSH composition:
# agent.cordis.yml
- id: memory
name: '@deepseek-ai/dsh-memory-connect'
config:
path: ~/.dsh/memory.db
enableSoul: true # Enable Soul injection (default: true)
v0.4.0 requirement: the plugin now injects
systemPrompt(used for the cross-session recall context provider). Any profile that loads this plugin needs thesystemPromptservice available (standard in the dsh web/headless profiles).
Configuration
Basic Options
| Option | Default | Description |
|---|---|---|
path |
(required) | Path to SQLite memory database |
openAt |
startup |
When to open: startup, first-query, never |
maxRecallCount |
10 |
Max memories to recall per session |
decayRate |
0.02 |
Decay constant (higher = faster decay) |
journalMode |
wal |
SQLite journal mode |
Scheduler Options
| Option | Default | Description |
|---|---|---|
schedulerEnabled |
true |
Enable periodic maintenance |
schedulerDecayIntervalMs |
3600000 |
Decay interval (ms), default 1h |
schedulerConsolidateIntervalMs |
21600000 |
Consolidation interval (ms), default 6h |
Context Explosion Prevention Options
| Option | Default | Description |
|---|---|---|
maxContextTokens |
4000 |
Max tokens for memory context injection |
smartPrioritization |
true |
Enable smart memory prioritization |
enableCompression |
true |
Enable memory compression |
Soul Options
| Option | Default | Description |
|---|---|---|
enableSoul |
true |
Enable global Soul injection |
soulPath |
~/.dsh/soul.md |
Custom Soul file path |
Full configuration example:
- id: memory
name: '@deepseek-ai/dsh-memory-connect'
config:
path: ~/.dsh/memory.db
openAt: startup
maxRecallCount: 10
decayRate: 0.02
journalMode: wal
schedulerEnabled: true
maxContextTokens: 4000
smartPrioritization: true
enableCompression: true
enableSoul: true
API
Search Memories
const memories = await ctx.crossSessionMemory.searchMemories({
query: 'TypeScript configuration',
types: ['fact', 'decision'],
limit: 5,
})
Recall for Session
const memories = await ctx.crossSessionMemory.recallForSession(
'session-123',
'Setting up a new React project',
10
)
Synchronous Recall (for system-prompt providers)
// v0.4.0+ — sync API for prompt-context providers (node:sqlite is synchronous,
// so no async needed). Returns a formatted markdown block or ''.
const block = ctx.crossSessionMemory.recallSync('session-123', 'React project')
Latest User Text (from dsh session logs)
// v0.4.0+ — extracts the most recent user message text from a dsh Session
// (handles {event: ...} wrappers, agent/inbox/spliced, and bare events).
const query = ctx.crossSessionMemory.currentUserText(agent.session)
Store Memory
await ctx.crossSessionMemory.storeMemory({
type: 'preference',
content: 'User prefers functional programming style',
sessionId: 'session-123',
tags: ['coding-style', 'preference'],
})
Manual Maintenance
// Trigger a full maintenance cycle (decay + consolidation)
const result = await ctx.crossSessionMemory.triggerMaintenance()
// Or run individually
await ctx.crossSessionMemory.runDecay()
await ctx.crossSessionMemory.consolidate()
Context Explosion Prevention
How It Works
- Token Counting — Estimates tokens for English, Chinese, and mixed text
- Smart Prioritization — Ranks memories by:
relevance × 50% + recency × 30% + frequency × 20% - Budget Management — Enforces
maxContextTokenslimit (default: 4000) - Memory Compression — Automatically truncates or summarizes when approaching limits
Output Example
## 🧠 Global Identity (Soul)
[Your Soul content here]
---
## Related Memories from Previous Sessions
- [preference] User prefers TypeScript
- [decision] Chose PostgreSQL over MySQL
> 💾 Memory: 2/10 memories + Soul | 250/4000 tokens
Memory Types
| Type | Description | Example |
|---|---|---|
fact |
Objective information | "Project uses TypeScript 5.3" |
preference |
User preferences | "Prefers functional components" |
context |
Project context | "E-commerce platform migration" |
decision |
Decisions made | "Chose PostgreSQL over MySQL" |
skill |
Learned patterns | "How to configure ESLint" |
Development
git clone https://github.com/Asher-2000/dsh-memory-connect.git
cd dsh-memory-connect
npm install
npm test
License
MIT
中文
概述
dsh-memory-connect 是 DeepSeek Harness 的跨会话记忆共享插件。它自动从对话中提取、存储和检索记忆,让 AI Agent 拥有持久化的智能记忆能力,并防止上下文爆炸和全局身份。
零配置 — 基于 SQLite FTS5 和 DSH 内置 LLM,开箱即用。
🚨 v0.4.0 — "这次真的能跑"版本
v0.3.0 只注册了服务但从未实例化(Cordis 懒加载机制:把类传给
ctx.provide()导致构造函数永远不执行),且"召回"功能把计算好的上下文写进了一个无人读取的字段——实际运行中插件什么都不做。v0.4.0 修复了启动链路,并把召回真正接入了系统提示词:通过
systemPrompt.context提供者,每轮对话都注入## Related Memories from Previous Sessions。零配置即可运行:此前仅执行dsh plugin add(patch 无config:块时 Cordis 传入undefined配置)会在config.openAt崩溃——现在apply()自动填充完整默认值(DB~/.dsh/memory.db、openAt: startup)。已在 dsh v0.1.1-rc.2 / Node 24 上端到端验证:会话 A 说"我的猫叫咪咪",开新会话 B 问它,模型能正确从记忆中回答。详见 CHANGELOG.md。
核心功能
| 功能 | 说明 |
|---|---|
| 🧠 全局身份 (Soul) | 通过 ~/.dsh/soul.md 跨所有工作区持久化身份 |
| 🔍 自动提取 | 从对话中提取事实、偏好、决策和上下文 |
| 🧠 跨会话召回 | FTS5 关键词召回,每轮注入系统提示词(无查询文本时按最近记忆兜底) |
| 🛡️ 上下文爆炸防护 | Token 预算管理,防止上下文窗口溢出 |
| ⏰ 定时维护 | 内置调度器自动执行衰减和整合 |
| 🤖 LLM 整合 | 使用 DSH 内置 LLM 智能合并相似记忆 |
| 📉 记忆衰减 | 旧的、不常用的记忆自然消退 |
| 🎯 智能优先级 | 基于相关性 × 时间 × 频率的记忆排序 |
| 🗜️ 记忆压缩 | 接近 token 限制时自动压缩 |
🧠 全局身份 (Soul)
Soul 功能提供跨所有工作区的持久化身份。
工作原理
- 创建
~/.dsh/soul.md包含你的身份信息 - 插件自动加载并注入到每个会话
- 你的偏好、技术栈和编码风格始终可用
Soul 文件示例
# 🧠 Soul — 全局身份
## 👤 身份
- GitHub: your-username
- 角色: 开发者/设计师/产品经理
## 💻 技术栈
- TypeScript, React, Node.js, DSH/Cordis
## 🎨 编码风格
- 函数式编程
- ES Modules
- 零配置优先
## ⚠️ 偏好
- 不用 class 组件
- 不写冗余注释
快速开始
⚠️ 尚未发布到 npm — 从 GitHub 安装 (v0.4.0):
# 方式 A:dsh plugin add(推荐,自动装入 profile)
dsh plugin --profile <你的profile> add github:Asher-2000/dsh-memory-connect
# 方式 B:npm 直接装 git tag
npm install github:Asher-2000/dsh-memory-connect#v0.4.0
# 方式 C:本地源码 link(开发/调试用)
git clone https://github.com/Asher-2000/dsh-memory-connect.git
dsh plugin --profile <你的profile> add link:/path/to/dsh-memory-connect
添加到 DSH 配置:
# agent.cordis.yml
- id: memory
name: '@deepseek-ai/dsh-memory-connect'
config:
path: ~/.dsh/memory.db
enableSoul: true
v0.4.0 依赖:插件现在注入
systemPrompt服务(用于跨会话召回 context 提供者)。所在 profile 需要提供systemPrompt(dsh web/headless profile 默认都有)。
许可证
MIT
原始 README: https://github.com/Asher-2000/dsh-memory-connect/blob/main/README.md ↗
同类插件
查看全部 →
mnemon
LLM监督持久内存插件 — 基于图的召回,跨会话知识,单二进制。与DeepSeek Harness、Claude Code、OpenClaw及任何代理运行时兼容。

memtrace-public
面向 AI 编码 agent 的结构化记忆:双时态图谱、MCP 原生、零 LLM 调用;支持 Cursor · Claude Code · Codex · DeepSeek Harness · Hermes · VS Code · Windsurf

dsh-flowix-memory
将本地 flowix-cli 注册为 MCP 服务,让 agent 可以搜索、读取、创建和编辑 Flowix 备忘与思维导图产物。

flowix
笔记助你,记忆助你的代理。

engramory
AI代理的便携式内存协议 — 以静态规则加载;整理学科 + 参考规范 + 可选的钩子API

dsh-memory-evolve
为 DeepSeek Harness 提供纯插件实现的跨会话长期记忆与后台自我进化能力:五轨记忆、Git 分支感知、回合内自我审查、技能自我进化与技能管理器、四轨待办、COI 调度、会话广播、会话搜索、提示词管理器和临时信息便签;零核心修改、零运行时依赖,安装即用,卸载即净。