Back to home

opok-ops

dsh-mindforge

Encrypted 4-layer lifelong memory for DeepSeek Harness - powered by MindForge

Stars
0
Language
TypeScript
Created
Aug 15, 2026
Updated
Aug 15, 2026

Introduction

dsh-mindforge

Encrypted 4-layer lifelong memory for DeepSeek Harness — powered by MindForge

License: MIT dsh-plugin Python 3.9+ Node 22+

Why dsh-mindforge?

DeepSeek Harness ships with basic session persistence — an append-only log and a simple memory table. That's enough for a single conversation, but agents forget everything across sessions, can't reason over past interactions, and have no way to encrypt sensitive memories.

dsh-mindforge plugs MindForge — a production-grade lifelong memory engine — directly into DSH as a native Cordis plugin. Your agent gets:

Featuredsh-mindforgedsh-mnemonDSH native
Memory layers4 (sensory/short/long/permanent)32
AES-256-GCM encryptionYesNoNo
Full-text search (FTS5 + trigram, Chinese-ready)YesPartialPartial
Vector search (384-dim MiniLM)YesNoNo
6-way fusion retrievalYesNoNo
Knowledge graphYesYesNo
Federated memory + ACLYesNoNo
Memory evolution (decay/cluster/link/reinforce)YesPartialNo
Metacognitive reflectionYesNoNo
Memory lineage & version historyYesPartialNo
DSH native tools10~8
DSH commands (/mindforge)YesYes
Auto context injection (agent.inject)YesYes

Architecture

┌─────────────────────────────────────────────────┐
│              DeepSeek Harness (Cordis)            │
│  ctx.tools  │  ctx.commands  │  agent.inject()   │
└──────┬───────┴───────┬───────┴────────┬──────────┘
       │               │                │
┌──────▼───────────────▼────────────────▼──────────┐
│           dsh-mindforge (TypeScript)              │
│  Tool registration │ Commands │ Pre-step injection │
│                   CLI Bridge                      │
└───────────────────────┬───────────────────────────┘
                        │ child_process.spawn
┌───────────────────────▼───────────────────────────┐
│              MindForge (Python CLI)                │
│  201 CLI commands │ 150+ API methods │ 32 MCP tools│
│  SQLite + FTS5(trigram) │ Embeddings(384-dim)      │
│  Knowledge Graph │ Federated ACL │ AES-256-GCM     │
└───────────────────────────────────────────────────┘

This is the same proven pattern used by dsh-mnemon — a TypeScript Cordis plugin wrapping an external CLI. The difference: MindForge brings encryption, 4-layer memory, federated ACL, and 6-way fusion search that no other DSH memory plugin offers.

Quick Start

Prerequisites

  1. MindForge CLI — Install Python engine:

    pip install MindForge
    # Or from source:
    git clone https://github.com/opok-ops/MindForge.git
    cd MindForge
    pip install -e .
    
  2. Initialize MindForge (creates encrypted database):

    MindForge init
    # Or non-interactive (CI/CD):
    MindForge init --no-encrypt
    
  3. Node.js 22+ — Required by DSH.

Install Plugin

# From local path (development):
dsh plugin --profile web add "link:/absolute/path/to/dsh-mindforge"

# From GitHub (once published):
dsh plugin --profile web add "github:opok-ops/dsh-mindforge"

Configure

The cordis.patch.yml in this plugin provides defaults. Override in your DSH config:

mindforge:
  cliPath: MindForge          # or full path to executable
  # dbPath: ~/.MindForge/data/store/memory.db
  # keyFile: ~/.MindForge/data/store/key.bin
  storageScope: global         # global | workspace | custom
  injectOnStep: true           # auto-inject memories before each model step
  maxContextTokens: 2048
  tools:                       # choose which tools to expose to the model
    - memory_add
    - memory_search
    - memory_context
    - memory_stats
    - memory_recall
    - graph_query

Usage

Model Tools (auto-registered on ctx.tools)

The model can call these tools directly:

ToolDescription
memory_addStore a memory (4-layer, encrypted)
memory_search6-way fusion search (vector + FTS5 + TF-IDF + fuzzy + expansion + rerank)
memory_contextToken-budget-aware context retrieval for prompt injection
memory_statsMemory store statistics
memory_recallSmart recall (search + association + layer-aware)
memory_reflectionMetacognitive analysis of memory themes and drift
memory_reinforceIdentify high-value decaying memories
memory_lineageTrace version history and audit events
graph_queryQuery the knowledge graph
rerank_searchQuery expansion + cross-encoder reranking

DSH Commands

/mindforge status              # Memory store statistics
/mindforge recall <query>      # Smart recall top 5
/mindforge remember <text>     # Store as permanent memory
/mindforge forget <id>         # Delete a memory
/mindforge graph               # Knowledge graph overview
/mindforge search <query>      # Full 6-way fusion search

Auto Context Injection

When injectOnStep: true (default), dsh-mindforge listens to agent/pre-step events and automatically injects relevant memories before each model turn:

  1. Extract keywords from the user's message
  2. Call MindForge memory-context for token-budget-aware retrieval
  3. Inject as a system message via agent.inject()

No configuration needed — works out of the box.

The 4-Layer Memory Architecture

LayerLifetimeUse Case
SensorySeconds–minutesRaw input buffer, auto-expiring
Short-termCurrent sessionWorking memory, conversation context
Long-termPermanent (until decay)Facts, preferences, learned skills
PermanentNever expiresCore identity, critical knowledge

Memory evolves automatically: sensory → short-term → long-term → permanent, with decay scoring, clustering, link reasoning, and reinforcement suggestions.

6-Way Fusion Search

MindForge's retrieval pipeline combines six strategies, merging scores by document ID (highest wins):

  1. Vector recall — 384-dim MiniLM embeddings, cosine similarity
  2. FTS5 full-text — trigram tokenizer (Chinese-ready), BM25 scoring
  3. TF-IDF — bigram Chinese tokenization, cosine similarity
  4. Fuzzy — edit-distance fallback for typos and partial matches
  5. Query expansion — synonym/hypernym augmentation
  6. Cross-encoder reranking — precision-focused reordering

Encryption

All memory content is encrypted with AES-256-GCM at rest. The encryption key is stored separately from the database. Even if an attacker obtains the SQLite file, they cannot read the memories without the key file.

This makes dsh-mindforge suitable for enterprise and compliance-sensitive use cases that no other DSH memory plugin supports.

Federated Memory

Multiple agents can share memories through MindForge's federated layer:

  • ACL rules — fine-grained per-principal, per-resource, per-operation
  • Conflict resolution — LWW (last-write-wins) or branch (keep-both)
  • Default deny — access requires explicit allow rule

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Watch mode
pnpm dev

Project Structure

dsh-mindforge/
├── src/
│   ├── index.ts        # Plugin entry — apply(ctx)
│   ├── bridge.ts       # MindForge CLI subprocess bridge
│   ├── tools.ts        # ctx.tools registration (10 tools)
│   ├── commands.ts     # /mindforge command registration
│   ├── inject.ts       # agent/pre-step context injection
│   ├── config.ts       # Config schema & defaults
│   └── types.ts        # TypeScript type definitions
├── tests/
│   └── bridge.test.ts  # Unit tests
├── cordis.patch.yml    # DSH configuration patch
├── package.json
├── tsconfig.json
├── tsdown.config.ts
└── vitest.config.ts

Comparison with dsh-mnemon

dsh-mnemon is the other memory plugin in the DSH ecosystem. Both follow the same architecture (TypeScript plugin + external CLI). Key differences:

dsh-mindforgedsh-mnemon
EngineMindForge (Python)mnemon (Go)
Memory layers43
EncryptionAES-256-GCMNone
Search6-way fusionSemantic recall
Knowledge graphYesYes (4-graph)
Federated ACLYesNo
Memory evolutionDecay + cluster + link + reinforce + reflectCapacity maintenance
CLI commands201~10
MCP tools320
Tests88 (Python) + vitestvitest

Choose dsh-mindforge if you need encryption, federated memory, or the richest search. Choose dsh-mnemon if you prefer a single Go binary with no Python dependency.

Roadmap

  • M1: CLI bridge + 3 core tools (add/search/context) — in progress
  • M2: /mindforge commands + agent.inject auto-injection
  • M3: Full 10-tool registration + knowledge graph
  • M4: WebUI memory management panel
  • M5: npm publish + DSH plugin store listing
  • Future: PyInstaller standalone binary (no Python dependency)
  • Future: MCP server mode (persistent process for high-frequency search)

License

MIT — see LICENSE.

Powered by