โ† Back to home@huangjua

dsh-local-memory

๐Ÿง  Persistent cross-session local memory for DSH agents (Markdown SSOT + self-healing SQLite mirror)

Stars
0
Language
TypeScript
Created
Sep 1, 2026
Updated
Sep 1, 2026
GitHub repo

Introduction

๐Ÿง  dsh-local-memory

Persistent cross-session local memory for DSH agents
100% Local โ€ข Plain Markdown Truth โ€ข Self-Healing SQLite Mirror โ€ข Prefix-Cache Friendly

DSH Suite Storage License

Features โ€ข Quick Start โ€ข DSH Power Suite โ€ข Tools โ€ข Architecture โ€ข ็ฎ€ไฝ“ไธญๆ–‡


๐Ÿ’ก Why dsh-local-memory?

DSH agents are natively stateless. Every new conversation starts from zero, forcing you to repeatedly explain project rules, environment setups, and coding preferences.

dsh-local-memory gives your agent long-term memory that you actually own:

  • ๐Ÿ“ Markdown is the Single Source of Truth: All memories are stored in plain .md files under ~/.dsh/memory/. You can view, edit, or version-control them with Git.
  • โšก Zero Cache Misses: Employs per-session frozen snapshots (WeakMap<Session, ...>) to maintain byte-for-byte prefix cache stability, saving tokens and speeding up responses.
  • ๐Ÿ”’ 100% Local & Fail-Closed: No cloud leaks. Workspace boundaries strictly validated against official workspace registries.
  • ๐Ÿ›ก๏ธ Staged Write Approvals: Global profile edits require explicit user confirmation (memory_pending approve) to prevent hallucinated changes.

๐Ÿš€ Quick Start

Installation

# In your DSH plugin environment
dev_inject_plugin @dsh-external/dsh-local-memory

Typical Usage Flow

  1. Ask agent to remember: "Remember that our project uses pnpm and strict TypeScript."
  2. Review staged memory: Run /local-memory or approve staged entries via memory_pending.
  3. Seamless recall: In any new session, the agent automatically receives the frozen memory context without any extra prompts.

๐Ÿงฉ DSH Power Suite

This plugin is part of the DSH Agent Power Suite โ€” 4 modular, zero-hard-dependency plugins forming a complete closed-loop developer workflow:

flowchart LR
    M["๐Ÿง  dsh-local-memory<br>(1. Remember rules & prefs)"] --> E["โšก dsh-context-economy<br>(2. Save 80%+ tokens reading code)"]
    E --> A["๐Ÿ›ก๏ธ dsh-evidence<br>(3. Tamper-proof audit receipts)"]
    A --> S["๐Ÿ” dsh-session-index<br>(4. CJK search & bookmarks)"]
    S --> M

    style M fill:#e8f4fd,stroke:#2b7de9,stroke-width:2px
    style E fill:#eef9f2,stroke:#1e8e3e,stroke-width:2px
    style A fill:#fef7e0,stroke:#f29900,stroke-width:2px
    style S fill:#f3e8fd,stroke:#8430ce,stroke-width:2px
PluginRole in SuiteSynergy with Local Memory
๐Ÿง  dsh-local-memoryMemory Layer (Current)Curates persistent long-term knowledge, developer profiles, and workspace conventions.
โšก dsh-context-economyContext EconomySlashes code reading tokens by 80โ€“93%, leaving ample prompt budget for memory snapshots.
๐Ÿ›ก๏ธ dsh-evidenceAudit & ReceiptsCreates SHA256 receipts for execution runs, grounding memory entries in verifiable evidence.
๐Ÿ” dsh-session-indexSession SearchIndexes raw .jsonl.zstd logs with CJK support. Memory curation belongs here; log searching belongs there.

๐Ÿ“– Deep Dive & Reference

๐Ÿ› ๏ธ Available Tools & Commands (8 Tools + 1 Command)

Tools

ToolDescriptionScope / Action
memory_writeAdd a new memory entryUser/Profile โžก๏ธ Staged; Workspace โžก๏ธ Direct
memory_updateRevise an entry via memoryId or oldTextPrevious active marked superseded
memory_forgetRemove an entry from active memoryReplaced with minimal tombstone
memory_pendingManage staged approvalslist, approve, reject
memory_append_dailyAppend timestamped block to daily notesAppend-only workspace scratchpad
memory_searchSearch memories with FTS5 trigramAuto pre-syncs modified Markdown
memory_statusDetailed file counts, active entries, DB sizeRead-only diagnostics
memory_distillCollect candidate daily notes for distillationRead-only + state metadata

User Commands

  • /local-memory feedback <receipt-id> bundle <helpful|harmful>: Submit feedback on memory delivery receipts.
๐Ÿ“ Architecture & Storage Layout
~/.dsh/memory/
โ”œโ”€โ”€ user/                       # User-level profile & global memories (MEMORY.md / USER.md)
โ”œโ”€โ”€ workspaces/<WorkspaceId>/   # Workspace-scoped memories (MEMORY.md)
โ”œโ”€โ”€ daily/<WorkspaceId>/        # Daily scratch notes (YYYY-MM-DD.md)
โ”œโ”€โ”€ summaries/                  # Distilled summaries
โ”œโ”€โ”€ pending/memory/             # Staged write approvals
โ”œโ”€โ”€ index/memory.sqlite         # Derived FTS5 SQLite index mirror (Schema v12)
โ””โ”€โ”€ meta.json                   # Metadata & version tracking

Key Architectural Invariants:

  • Markdown is the Single Source of Truth: All text and metadata reside in .md files.
  • SQLite is a Disposable Replica: If corrupted, SQLite automatically recovers from Markdown via buildMemoryIndex.
  • Pre-Search Incremental Sync: memory_search syncs changed files on the fly by content_hash.
โš–๏ธ Design Trade-offs & Boundaries
AdvantageTrade-off / Boundary
SSOT/Replica separation ensures zero data lossSchema v12 migration chain requires strict maintenance
Dual channel: frozen snapshots + real-time tool searchLocal-machine bound (no cloud sync)
Strict workspace fail-closed isolationIndex contains plain text (do not use on untrusted shared machines)
566 test cases with comprehensive coverageforget removes active surfaces, does not do physical disk shredding
๐Ÿงช Building & Testing
# Install dependencies
pnpm install --frozen-lockfile

# Build TypeScript to lib/
bash scripts/build.sh

# Typecheck & Run test suite
npm run typecheck
npm test
๐Ÿ™ Credits & References
  • Hermes Agent (Nous Research, MIT): entries.ts, threat.ts, and approval.ts adapted from memory_tool, threat_patterns, and write_approval.
  • Official dsh-plan-mode (MIT): WeakMap<Session, ...> freezing + systemPrompt.section dynamic provider pattern.
  • Jesse-njx/dsh-memory (MIT): Managed entry inline HTML header metadata format.
  • ben7am1n/dsh-memory (MIT): Live Context test harness architecture.

Part of the DSH Agent Power Suite. Licensed under BSD-3-Clause.