# dsh-experience-memory

[![npm version](https://img.shields.io/npm/v/dsh-experience-memory.svg)](https://www.npmjs.com/package/dsh-experience-memory)
[![CI](https://github.com/lzpgood123/dsh-experience-memory/actions/workflows/ci.yml/badge.svg)](https://github.com/lzpgood123/dsh-experience-memory/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

DSH（DeepSeek Harness）记忆插件：**全局热记忆 + 按需经验库**。

- 全局热记忆：`USER.md` / `MEMORY.md` 自动常驻注入。
- 经验库：默认不自动全局加载；用户可通过 WebUI 卡片/侧边栏手动选择加载，Agent 也可按相关度阈值自动检索注入当轮上下文。
- 记忆审批：可开关。开启时写入进入 `pending`，等待用户批准；关闭时 Agent 可自动判断并直接写入。
- 后台子代理记忆 review：每 N 轮对话后自动启动子代理审查，提炼值得保存的偏好/决策/方案（Hermes 同款机制）。
- 本地 SQLite + FTS5 关键词检索，不依赖向量模型。
- 使用/反馈加权排序，拒绝精确重复并提示相似条目。

## 安装

已发布到 npm：[`dsh-experience-memory`](https://www.npmjs.com/package/dsh-experience-memory)

```bash
dsh plugin --profile web add dsh-experience-memory
dsh --profile web
```

本地开发：

```bash
pnpm install
pnpm verify
```

## 命令

```text
/memory status|add|edit|remove|list|pending|approve|reject
/experience save|search|load|unload|list|export
```

## Agent 工具

- `experience_save(title, content, category?, tags?, workspace?)`
- `experience_recall(query, workspace?, category?, limit?)`

## 存储

```text
~/.dsh-experience/
├── global.json
├── USER.md
├── MEMORY.md
└── experience.db
```

## 开发

```bash
pnpm typecheck
pnpm test
pnpm build
```

## 文档

- [设计文档](./docs/spec.md)
- [English README](./README.md)

## License

MIT
