@wwskills/dsh-long-memory

August 28, 2026 · View on GitHub

Long-term cross-session memory + self-evolving learning plugin for DeepSeek Harness.

SQLite-backed, FTS5 + optional embedding recall, append-only audit log, L7 auto-extraction, lesson capture from user corrections, rule lifecycle with context injection. Single-bundle dual-face packaging (Node service + browser UI).

Features

Memory & Recall

  • 8 mem_* tools — search, record, status, stats, forget, confirm, scope list, scope set
  • FTS5 full-text search with CJK support (works out of the box, zero config)
  • Optional embedding — Ollama (local, zero cost) or any OpenAI-compatible API
  • Hybrid recall — BM25 + vector + RRF fusion when embedding is enabled
  • L7 auto-extraction — automatically extracts memories from conversations on turn/end using your DSH LLM provider (zero extra config)
  • Keyword fallback — if LLM is unavailable, regex-based keyword extraction kicks in
  • File tracksMEMORY.md session markers + memory/YYYY-MM-DD.md daily notes
  • Audit log — append-only, tracks every memory operation

Self-Evolving Learning (merged from agent-evolve)

  • Signal word detection — real-time capture when user says "不对" / "wrong" / "should be" etc. (8 CN + 7 EN, configurable)
  • Tool error capturetools/result event listener auto-records tool failures as corrections
  • Agent error captureagent/error event listener auto-records harness-level errors
  • Lesson extraction — LLM-powered structured lesson extraction from correction-triggering messages
  • Rule lifecycle — proposed → approved → rejected → archived → promoted_to_agents
  • Rule injection — approved rules auto-injected into agent context via agent/pre-step (≤800 token budget, hit_count tracking)
  • Rule conflict detection — Jaccard overlap >60% warns on approve
  • AGENTS.md promotion — high-hit-count rules can be promoted to AGENTS.md format
  • Daily decay — stale rules (90 days unhit) auto-archived

Browser UI

  • 4 Tab management panel — 教训 (Corrections) / 规则 (Rules) / 记忆 (Memories) / 画像 (Persona)
  • Overview strip — pending corrections, proposed rules, active memories at a glance
  • Config panel — embedding, LLM model, signal words, extraction settings
  • 30s auto-refresh — stats and badges stay current

Install

dsh plugin --profile web add @wwskills/dsh-long-memory

Configuration

Defaults are sensible. Override via your profile's patch layer as needed.

Embedding

ProviderUse caseCost
noneFTS5 keyword only (default)Zero
ollamaLocal Ollama serviceZero (local)
openai-compatibleAny OpenAI-style APIPer-call
- id: long-memory
  config:
    embedding:
      provider: 'ollama'          # 'none' | 'ollama' | 'openai-compatible'
      model: 'bge-m3'
      dimension: 1024
      ollama:
        base_url: 'http://127.0.0.1:11434'

L7 Auto-extraction

L7 reads your DSH LLM provider config automatically — no extra API key needed.

- id: long-memory
  config:
    l7:
      enabled: true               # enable auto memory extraction
      auto_extract: true          # LLM-based + keyword fallback
      extractor_model: ''         # empty = use cheapest model from your DSH config
      extractor_temp: 0.2
      interval_ms: 21600000       # 6h minimum between extractions

Signal Words (Self-Evolving)

Signal words trigger real-time correction capture when users say things like "不对" or "wrong":

- id: long-memory
  config:
    # Default signal words (8 CN + 7 EN) are built-in.
    # Override via WebUI Settings → Plugins → Long Memory.
    # Or set in patch:
    # signal_words:
    #   - '不对'
    #   - 'wrong'
    #   - ...

Storage

    storage:
      path: '${DSH_HOME}/long-memory/long-memory.db'
      markdown_dir: '${DSH_HOME}/long-memory/markdown'

Tools

ToolPurpose
mem_searchFTS5 + hybrid search across memories
mem_recordPersist a memory; auto-detects scope
mem_statusStorage + recall state
mem_statsAggregate statistics
mem_forgetArchive or delete; writes audit log
mem_confirmApprove/reject queued sensitive memory
mem_scope_listList all scopes
mem_scope_set_activeSet active scope filter

Web API

MethodPathPurpose
GET/plugins/dsh-long-memory/api/memoriesList memories (scope/type/q filter)
DELETE/plugins/dsh-long-memory/api/memoriesDelete a memory
GET/plugins/dsh-long-memory/api/confirm-queuePending sensitive memories
POST/plugins/dsh-long-memory/api/confirm-queueApprove/reject
GET/POST/plugins/dsh-long-memory/api/embedding-configEmbedding settings
GET/plugins/dsh-long-memory/api/correctionsList corrections (status/trigger filter)
POST/plugins/dsh-long-memory/api/corrections/:id/extractPromote correction to rule
POST/plugins/dsh-long-memory/api/corrections/:id/ignoreIgnore correction
GET/plugins/dsh-long-memory/api/rulesList rules (status filter)
POST/plugins/dsh-long-memory/api/rules/:id/approveApprove rule
POST/plugins/dsh-long-memory/api/rules/:id/rejectReject rule
POST/plugins/dsh-long-memory/api/rules/:id/promotePromote to AGENTS.md
GET/plugins/dsh-long-memory/api/rules/:id/sourceView source corrections
PUT/plugins/dsh-long-memory/api/rules/:idEdit rule
GET/plugins/dsh-long-memory/api/statsMonthly stats

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    long-memory plugin                       │
├──────────────┬──────────────┬──────────────────────────────┤
│  Memory &    │  Self-Evolving│  Browser UI                  │
│  Recall      │  Learning     │  (4 Tab Panel)               │
│              │               │                              │
│ • memories   │ • corrections │ • 教训 Tab (list/extract)   │
│ • FTS5       │ • rules       │ • 规则 Tab (approve/edit)   │
│ • embedding  │ • signal words│ • 记忆 Tab (search/filter)  │
│ • L7 extract │ • tool errors │ • 画像 Tab (persona)        │
│ • scope      │ • rule inject │ • Config panel              │
│ • KG         │ • decay       │ • 30s auto-refresh          │
│ • 8 tools    │ • conflicts   │                              │
│ • audit log  │ • AGENTS.md   │                              │
└──────────────┴──────────────┴──────────────────────────────┘

Requirements

  • Node ≥ 22.5 (uses built-in node:sqlite)
  • DeepSeek Harness 0.1.0-rc.2+

Migrations

#FileDescription
00010001_initial.sqlCore tables: memories, embeddings, audit_log, confirm_queue, schema_meta
00020002_l7_buffer.sqlL7 message buffer table
00030003_embedding_cache_key.sqlComposite PK for embeddings
00040004_corrections_rules.sqlCorrections + rules + usage_stats (self-evolving)

License

MIT — see LICENSE.