Back to home

Paloma966

dsh-mem

Local AI memory for DeepSeek Harness: memory_search / memory_remember / memory_context tools over a built-in SQLite store.

Stars
0
Language
Go
Created
Aug 16, 2026
Updated
Aug 16, 2026

Introduction

mem —— Local AI Memory Engine

mem 是一个本地 AI 长期记忆引擎。

将你的文件自动转换为结构化事实,通过 CLI 和 MCP Server 提供给 Claude Code 等 AI Agent 使用。

DeepSeek Harness 插件

dsh-memory-bundle/ 是本项目的 DeepSeek Harness (DSH)原生插件:自包含 bundle,内置 SQLite 存储,提供 memory_search / memory_remember / memory_context 三个工具。安装:

dsh plugin --profile <name> add dsh-memory-bundle

发布步骤见 dsh-memory-bundle/PUBLISHING.md

安装

git clone https://github.com/chun/mem.git
cd mem
go build -o mem ./cmd/mem
mv mem ~/.local/bin/  # 或任何在 PATH 中的位置

快速开始

1. 初始化

mem init

创建 ~/.mem/,包含 SQLite 数据库和默认配置。

2. 设置 API Key

export ANTHROPIC_API_KEY="your-api-key"

3. 导入文件

echo '# 项目 Alpha

## 技术栈
- 语言: Go
- 数据库: SQLite
- 负责人: 张三

## 里程碑
- 2026-08-01 上线' > /tmp/design.md

mem import /tmp/design.md -y

输出:

解析: /tmp/design.md (markdown, 0.1KB, 9行)
抽取中...

识别到的事实:

  [design]
    project.language                  = Go            [置信度: 0.95]
    project.database                  = SQLite        [置信度: 0.95]
    project.owner                     = 张三           [置信度: 0.94]
    project.deadline                  = 2026-08-01    [置信度: 0.91]

✓ 保存 4 条, 跳过 0 条 (未变化)

4. 查询

# 查看某个命名空间
mem show alpha.*

# 搜索
mem find Go

# 查看来源
mem source alpha.project.owner

5. Claude Code 集成

~/.claude/settings.json 中添加:

{
  "mcpServers": {
    "mem": {
      "command": "mem",
      "args": ["serve"]
    }
  }
}

重启 Claude Code 后,就可以在对话中使用 MCP 工具:

  • memory_search — 搜索记忆
  • memory_context — 获取命名空间上下文
  • memory_remember — 手动添加记忆

命令参考

命令说明
mem init初始化 ~/.mem
mem import <file> [-y] [--ns name]导入文件,AI 抽取事实
mem show <pattern>按 key 模式查看
mem find <keyword> [--ns name]关键词搜索
mem query <keywords>增强搜索
mem source <key>查看来源和历史
mem list [namespace]列出命名空间或 keys
mem serve启动 MCP stdio server

架构

文件 (MD/TXT/...) → Parser → Extractor (Claude API) → Memory Core (SQLite)
                                                          │
                                          ┌───────────────┴───────────────┐
                                          │                               │
                                       CLI                          MCP Server
                                   (mem import/show/...)            (stdio, Claude Code)

Key 格式

三段式:namespace.entity.attribute

alpha.project.language  = Go
alpha.project.owner     = 张三
preference.editor       = vim

配置

~/.mem/config.yaml:

llm:
  provider: claude
  model: claude-sonnet-5
  api_key: ${ANTHROPIC_API_KEY}

import:
  default_confidence: 0.80
  auto_save: false

mcp:
  transport: stdio

技术栈

  • Go 1.26+
  • SQLite (modernc.org/sqlite, 纯 Go, 无 CGO)
  • Claude API (Anthropic Messages API)
  • cobra + viper (CLI)
  • MCP JSON-RPC 2.0 over stdio

License

MIT