DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

ly028716 /

ly028716/dsh-memory-plugin

Verified

Intelligent memory system for DSH - Track user preferences, tool usage, and project context to provide personalized recommendations

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@196694c1

dsh-memory-plugin

Intelligent memory system for DSH - Track user preferences, tool usage, and project context to provide personalized recommendations

License Version DSH Plugin

简体中文 | English


🌟 简介

dsh-memory-plugin 是一个为 DeepSeek Harness (DSH) 设计的智能记忆系统插件。它能够自动学习用户的使用习惯、记住偏好设置、跟踪项目上下文,并基于这些数据提供个性化的智能推荐,显著提升开发效率和工作体验。

✨ 核心功能

  • 🎯 智能推荐引擎 - 基于历史数据自动推荐最适合的模型、Agent 和工具配置
  • 📊 工具使用追踪 - 自动记录常用工具(read、write、edit、glob、grep 等)的使用频率
  • 👤 偏好记忆 - 记住常用的 Agent、大模型、语言设置和代码风格
  • 📁 项目上下文 - 跟踪活跃项目、访问历史和项目标签
  • 💬 会话历史 - 记录讨论主题、完成的任务和工作模式
  • 💾 持久化存储 - JSON 格式本地存储,支持自动保存、导入和导出
  • 🔒 隐私保护 - 完全本地存储,无云端同步,用户完全掌控数据
  • 🎨 Web 查看器 - 精美的可视化界面,直观展示记忆数据

🚀 快速开始

一键安装(推荐)

Windows 用户:

# 方式 1:双击运行
install.bat

# 方式 2:PowerShell
.\install.ps1

脚本会自动:

  • 🔍 查找 DSH 配置目录
  • 📦 复制或创建符号链接
  • ✅ 验证安装结果

手动安装

方式 1:作为本地插件

# 克隆仓库
git clone https://github.com/ly028716/dsh-memory-plugin.git

# 在 DSH profile 目录中添加
cd ~/.dsh/profiles
dsh plugin --profile <name> add /path/to/dsh-memory-plugin

方式 2:通过 npm 包安装(推荐)

dsh plugin --profile <name> add @ly028716/dsh-memory-plugin

方式 3:直接集成到代码

const memoryPlugin = require('./dsh-memory-plugin');

// 创建 DSH context
const ctx = {
  _services: {},
  effect(fn) { /* ... */ },
  provide(name, service) {
    this._services[name] = service;
  }
};

// 应用插件
memoryPlugin.apply(ctx, {
  storagePath: '.dsh-memory.json',
  trackToolCalls: true,
  enableRecommendations: true
});

插件初始化是异步的。首次读取持久化数据前可等待 ctx.memory.ready;写入 API 会自动等待初始化完成:

await ctx.memory.ready;
const stats = ctx.memory.getStats();

基本使用

插件默认不会自动采集数据,也不会因为插件启动而创建记忆文件或增加会话计数。四个 track* 开关只控制自动采集;通过 ctx.memory 显式调用 API 仍会主动写入并持久化数据:

// 获取智能推荐
const recs = ctx.memory.getRecommendations('coding');

// 设置偏好
await ctx.memory.setPreference('defaultModel', 'qwen3.7-plus');
await ctx.memory.setPreference('preferredAgents', ['coding-assistant']);

// 记录会话
await ctx.memory.recordTopic('implement authentication');
await ctx.memory.addProject({
  path: '/projects/my-app',
  name: 'my-app',
  tags: ['react', 'typescript']
});

// 查看统计
const stats = ctx.memory.getStats();
console.log(stats);

默认采集语义

  • trackToolCalls、trackPreferences、trackProjectContext、trackSessionHistory 默认均为 false,分别控制对应的自动采集路径。
  • 默认启动只使用内存中的空白记忆,不创建 .dsh-memory.json,也不会记录 metadata.totalSessions。
  • setPreference()、recordTopic()、recordTask()、addProject()、storage.set() 和 importData() 属于显式操作,即使自动采集开关关闭也会持久化。
  • 只要打开任一自动采集开关,插件启动时就会加载或创建存储文件,并记录一次会话元数据。

⚙️ 配置选项

{
  // 存储文件路径(相对于工作区)
  storagePath: '.dsh-memory.json',
  
  // 最大历史记录数量
  maxHistoryItems: 100,
  
  // 自动保存间隔(毫秒)
  autoSaveInterval: 5000,
  
  // 自动采集开关(默认关闭,需显式设置为 true)
  trackToolCalls: false,       // 追踪工具调用
  trackPreferences: false,     // 追踪用户偏好
  trackProjectContext: false,  // 追踪项目上下文
  trackSessionHistory: false,  // 追踪会话历史
  
  // 隐私设置
  encryptSensitiveData: false, // 兼容旧配置;自动脱敏始终启用
  allowClearMemory: true,      // 允许清除记忆
  
  // 智能功能
  enableRecommendations: true,           // 启用推荐
  patternRecognitionThreshold: 3         // 模式识别阈值
}

🎨 Web 查看器

插件提供了精美的 Web 界面来可视化记忆数据:

# 双击运行
open-viewer.cmd

# 或在浏览器中打开
viewer.html

# 需要更完整的可视化布局时
premium-viewer.html

查看器功能:

  • 📊 数据概览卡片
  • 🛠️ 工具使用统计图表
  • 📁 项目管理列表
  • 💬 会话历史时间线
  • 🎯 智能推荐展示

📊 数据结构

记忆数据以 JSON 格式存储:

{
  "version": "1.0.0",
  "userPreferences": {
    "defaultModel": "qwen3.7-plus",
    "language": "zh-CN",
    "preferredAgents": ["coding-assistant", "reviewer"]
  },
  "inputHabits": {
    "preferredTools": ["read", "write", "glob"],
    "commonCommands": [
      {"command": "pnpm run dev", "count": 45}
    ]
  },
  "projectContext": {
    "activeProjects": [
      {
        "path": "/projects/my-app",
        "name": "my-app",
        "tags": ["react", "typescript"],
        "lastAccessed": "2026-08-20T10:30:00Z"
      }
    ]
  },
  "sessionHistory": {
    "recentTopics": [
      {"content": "plugin development", "timestamp": "2026-08-20T10:00:00Z"}
    ],
    "toolUsageStats": {
      "read": 156,
      "write": 89,
      "edit": 67
    }
  },
  "metadata": {
    "createdAt": "2026-08-20T00:00:00Z",
    "totalSessions": 25,
    "lastSessionDate": "2026-08-20T10:30:00Z"
  }
}

🔒 隐私与安全

  • ✅ 完全透明 - 所有数据存储在本地 JSON 文件中
  • ✅ 用户控制 - 可以禁用任何追踪功能
  • ✅ 数据所有权 - 数据完全属于用户,可随时导出或删除
  • ✅ 无云端同步 - 所有数据仅存储在本地
  • ✅ 可清除 - 可通过 ctx.memory.clearMemory() 清除插件记忆数据;查看器按钮仅清除浏览器缓存

🛠️ 项目结构

dsh-memory-plugin/
├── index.js              # 主入口文件
├── config.js             # 配置验证模块
├── storage.js            # 数据存储引擎
├── memory-manager.js     # 核心记忆管理
├── package.json          # NPM 包配置
├── viewer.html           # 默认 Web 查看器
├── premium-viewer.html   # 专业版 Web 查看器
├── demo-viewer.html      # 演示版查看器
├── open-viewer.cmd       # 一键启动脚本
├── quick-start.js        # 快速生成示例数据
├── test/                 # 测试文件
│   ├── config.test.js
│   ├── storage.test.js
│   └── memory-manager.test.js
├── README.md             # 中文文档
├── README.en.md          # 英文文档
├── LICENSE               # MIT 许可证
└── CONTRIBUTING.md       # 贡献指南

🧪 测试

# 运行测试
npm test

# 运行真实 DSH clean-profile E2E(未安装 dsh 时安全跳过)
npm run test:dsh-e2e

# 当前支持:DSH CLI >=0.1.1-rc.2 <0.2.0(已验证 0.1.1-rc.2)

# 运行快速演示
node quick-start.js

# 打开 Web 查看器
./open-viewer.cmd

💡 使用场景

场景 1:个性化助手

// 根据用户偏好自动配置
const model = ctx.memory.getPreference('defaultModel');
const agents = ctx.memory.getPreference('preferredAgents');
// 自动使用用户喜欢的配置

场景 2:智能推荐

// 编码时获取推荐
const recs = ctx.memory.getRecommendations('coding');
// 返回:推荐的 Agent、模型、项目等

场景 3:项目切换

// 自动识别和记录项目
await ctx.memory.addProject({
  path: process.cwd(),
  name: 'current-project',
  tags: ['typescript', 'api']
});

🤝 贡献

欢迎贡献代码、报告问题或提出建议!

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交改动 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

详见 CONTRIBUTING.md

📄 许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件

🙏 致谢

  • DeepSeek Harness - 强大的 AI 开发助手框架

Made with ❤️ by ly028716

⭐ Star this repo | 🐛 Report Bug | 💡 Request Feature

—/ 5

No ratings yet

Verified DSH bundle

Commit 196694c17686

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout