Witchwarren2344/dsh-mnemosyne-memory1

dsh-mnemosyne-memory

Mnemosyne 永久记忆插件 - 为 DSH 提供长期记忆、向量搜索和 LLM 反思功能

包名
dsh-mnemosyne-memory
版本
1.4.0
许可证
MIT
最近更新
2026年9月12日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Witchwarren2344/dsh-mnemosyne-memory

💡 两种使用方式 | Two Ways to Use

方式Approach成本适用场景
🏠 本地部署Local (Ollama)免费隐私敏感、离线环境
☁️ 云端 APICloud (Gemini/DeepSeek)可选需要更高精度

5. 将 Key 添加到配置

配置本地模式 | Configure Local Mode


# 编辑配置文件
nano config/mnemosyne.json
{
  "embedding": {
    "enabled": true,
    "provider": "ollama",
    "model": "nomic-embed-text",
    "dimensions": 768,
    "endpoint": "http://localhost:11434"
  }
}

优点:完全离线、无 API 限制、数据不离开本地 Pros: Fully offline, no API limits, data stays local


📦 Installation | 安装方法

Prerequisites | 前置要求

  • Node.js >= 18.0.0
  • DSH (DeepSeek Harness) >= 0.1.0-rc.7
  • Git (for codebase survey)

Installation Steps | 安装步骤


### Configure API Keys | 配置 API Key

#### 方式 A:使用免费 Gemini API(推荐)| Method A: Free Gemini API (Recommended)

```bash

# 复制配置模板
cp config/mnemosyne.json.example config/mnemosyne.json

# 编辑配置,填入你的 Gemini API Key
nano config/mnemosyne.json
{
  "embedding": {
    "provider": "gemini",
    "apiKey": "你的-Gemini-API-Key"
  }
}

方式 B:本地 Ollama 部署 | Method B: Local Ollama


# 无需 API Key,编辑配置即可
nano config/mnemosyne.json
{
  "embedding": {
    "provider": "ollama",
    "model": "nomic-embed-text",
    "endpoint": "http://localhost:11434"
  }
}

Verify Installation | 验证安装


## ⚙️ Configuration | 配置说明

### Environment Variables | 环境变量

```bash

# API Keys(如果使用云端 API)
export GEMINI_API_KEY=your-free-key-here  # 免费获取
export OPENAI_API_KEY=sk-xxx
export DEEPSEEK_API_KEY=sk-xxx

### JSON Configuration | JSON 配置文件

```json
// config/mnemosyne.json
{
  "enabled": true,
  "embedding": {
    "enabled": true,
    "provider": "ollama",       // ollama | gemini | openai | deepseek
    "model": "nomic-embed-text", // nomic-embed-text | gemini-embedding-001
    "dimensions": 768,
    "apiKey": "可选"            // Ollama 模式不需要此字段
  },
  "reflect": {
    "enabled": true,
    "provider": "gemini",
    "model": "gemini-flash-lite-latest",
    "temperature": 0.3,
    "maxTokens": 2000,
    "apiKey": "可选"            // Ollama 模式不需要此字段
  },
  "sharedBanks": {}
}

📖 Usage Examples | 使用示例

Store Memory | 存储记忆

// Record a decision
await mnemo_store({
  type: 'decision',
  content: '决定优先开发客服 AI 场景',
  importance: 0.85,
  tags: ['战略', '客服']
});

// Record an insight
await mnemo_store({
  type: 'insight',
  content: '用户更偏好快速响应而非深度分析',
  importance: 0.75,
  tags: ['用户反馈', '体验']
});

Recall Memory | 检索记忆

// Semantic search
const results = await mnemo_recall({
  query: '我们之前决定用什么框架',
  k: 5,
  min_importance: 0.5
});

// Filter by role
const ceoInsights = await mnemo_recall({
  query: '战略方向',
  role: 'ceo',
  k: 10
});

Trigger Reflection | 触发反思

// Auto-reflect current session
const reflection = await mnemo_reflect({
  turns: 20,  // Analyze last 20 turns
  force: false
});

console.log('Extracted insights:', reflection.insights_added);

Knowledge Pages | 知识页面

// List all pages
const pages = await mnemo_pages_list();

// Read a page
const arch = await mnemo_pages_read({ page_id: 'architecture' });

// Incremental refresh
const delta = await mnemo_pages_delta();
// → { added: 2, modified: 5, deleted: 0 }

Git History Import | Git 历史导入


# 3. 配置
cp config/mnemosyne.json.example config/mnemosyne.json

# 3. 配置本地模式
cp config/mnemosyne.json.example config/mnemosyne.json