Skip to main content

dsh-layered-memory/dsh-plugins/dsh-layered-memory

7Stars1Forks0Issues0Watchers

DSH Cross-Session Long-Term Memory Plugin: hierarchical storage (L0 rules/L1 index/L2 facts/L3 SOP) + action-verified writes + automatic distillation candidates + provenance/archiving/rollback, isolated by namespace.

Categories◆ Memory
Evidence5/5methodologySourceInstallMaintenanceDSH versionSecurity scan
Machine-auditedInstall commandRepo verifieddsh-plugin topicLicenseREADMEAI wiki

ⓘ This plugin is a sub-package of the DDDFXYqiming/Agent_Extensions monorepo — stars and activity count the whole repository.

Language
JavaScript
License
MIT
Branch
main
agent-skillsai-agentdeepseek-harnessdsh-pluginprompt-engineeringpythonskillstranslation

Install

cmdweb profile
$ dsh plugin --profile web add dsh-layered-memory

Run the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial

Install via your agent

Install the DeepSeek Harness plugin DDDFXYqiming/Agent_Extensions/dsh-plugins/dsh-layered-memory for me: review the repository at https://github.com/DDDFXYqiming/Agent_Extensions first, then run the install command and verify the plugin loads successfully.

Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.

One-Sentence Positioning

Provides cross-session long-term memory capability for DeepSeek Harness (DSH), with four-layer storage (L0 meta-rules / L1 index / L2 environmental facts / L3 task experience), namespace isolation by default, and mandatory "action verification" requirement before allowing writes.

Core Capabilities

  • Each turn injects L1 existence index into model context, allowing the model to see what reusable experiences it has at any time
  • Provides 12 memory tools, covering read, list, write, modify, archive, rollback, statistics, maintenance, candidate confirmation, and trace expansion
  • Forces "action verification evidence" during writes, filtering out model guesses and common sense contamination
  • Automatically distills each turn's successful tool calls into pending candidates, requiring human or model confirmation before entering formal memory
  • Preserves historical snapshots (supersede) on every memory update; archiving doesn't physically delete, allowing one-click rollback
  • Automatically isolates namespaces by workspace directory name + git branch, preventing memory mixing across projects
  • Automatically runs maintenance every 20 turns (deduplication, L1 compression, statistics, candidate merging)

Technical Implementation

  • Language: JavaScript (ESM single file)
  • Key Dependencies: @deepseek-ai/cordis (host framework), @deepseek-ai/dsh-tools (defineTool), @deepseek-ai/dsh-system-prompt (L1 injection), @deepseek-ai/schemastery (config validation)
  • Architecture Pattern: Injects bundle via cordis.patch.yml; apply hooks into ctx.systemPrompt.context (L1 visible each turn), ctx.skills.register (memory runtime skill), ctx.tools.register (tools), ctx.on('session/event') (turn/end distillation & maintenance), ctx.on('tools/result') (successful tool buffering), ctx.on('agent/disposed') (cleanup)
  • Entry File: lib/index.js (1637 lines, single-file implementation)

Use Cases

When you want DSH Agent to retain machine environment, tool configurations, pitfalls encountered, and other reusable experiences across multiple sessions, avoiding starting from scratch each time. After installation, the Agent can proactively consult historical experiences when starting new tasks, and沉淀 "verified successful" knowledge after task completion for reuse. Suitable for developers maintaining the same machine or group of projects long-term.

Prerequisites & Compatibility

DependencyMin VersionDescription
Node.js>=22.19package.json#engines.node declaration
DSH host (cordis)>=4.0.0-rc <5peerDependencies; plugin injects via cordis.patch.yml
@deepseek-ai/dsh-tools*Provides defineTool, provided by host
@deepseek-ai/dsh-system-prompt*Provides systemPrompt.context injection capability
@deepseek-ai/schemastery*Provides config Schema validation
Native modulesNoneOnly uses node:fs / node:os / node:path / node:crypto / node:child_process
PlatformCross-platformNo OS restrictions declared; autoNamespace calls git command, non-git directories automatically degrade to only using cwd name

Installation

dsh plugin --profile web add dsh-layered-memory

Configuration Options

ConfigTypeDescriptionDefault
memoryDirStringAbsolute path for memory root directory; empty uses <home>/.dsh/memory""
maxIndexLinesNumberL1 index auto-segment line limit; exceeded triggers maintenance phase to compress by access heat30
progressiveBooleanTools use progressive exposure (default only registers memory_activate, 12 tools mounted after skill loads); disabling registers all tools at oncetrue
defaultNamespaceStringFixed namespace to use; empty determined by autoNamespace""
autoNamespaceBooleanWhether to auto-generate namespace from workspace directory name + git branch (only uses directory name when git unavailable)true
autoPendingBooleanWhether to auto-write successful tool calls to pending/ candidate area at end of each turntrue
maintainEveryTurnsNumberHow many turns to auto-run deduplication/compression/statistics/candidate merge; set to 0 to disable auto-maintenance20

FAQ

Q: Where is memory stored after installation?

A: Defaults to user home directory at ~/.dsh/memory/ (macOS/Linux uses ~/.dsh/memory, Windows uses %USERPROFILE%\.dsh\memory). When autoNamespace is enabled, subdirectories are automatically created for isolation using workspace name + git branch; customize by setting memoryDir in profile config.

Q: Must evidence be provided when writing memory?

A: Yes. Both memory_write and memory_accept require evidence; lacking evidence causes the tool to reject outright. Evidence should describe the tool call or measured result that verified this information—unverified information is not allowed to enter formal memory.

Q: Tools like memory_read don't appear in the tool list after installation?

A: Uses progressive exposure mechanism by default (progressive=true), where all 12 tools are only mounted to the current Agent after calling memory_activate or after the memory skill loads. Skill loading usually activates automatically; if tools still don't appear, call memory_activate once.

Q: How to rollback mistaken changes or archived memories?

A: Use the memory_rollback tool, passing topic and entry_type (fact/sop), which automatically restores from the latest snapshot in .history/; memory_archive only hides entries from L1 index and memory_read, files remain in archive/, and can also be restored via memory_rollback.

Q: Does uninstalling delete written memories?

A: No. Memory files are stored as regular Markdown/JSON in ~/.dsh/memory/ (or its namespace subdirectories); uninstalling only removes the plugin itself, memory files can still be browsed or reused in other DSH instances; to completely clear, manually delete that directory.

Q: What happens when L1 index exceeds 30 lines?

A: After writing, it prompts over_limit=true. Running memory_index only rebuilds the index; running memory_maintain compresses L1 auto-segments by access heat, keeping only active entries, compressed fact/sop still exist in files but no longer appear in L1 index.

Q: What is automatic distillation of pending candidates?

A: When autoPending=true (default), each turn's end writes successful tool calls to the pending/ candidate area, not automatically entering formal memory. Use memory_pending to view candidates, memory_accept with topic/entry_type/evidence is required before being written to L2/L3.

Difficulty

Beginner — Works with default configuration, install and use; customize namespace, maintenance frequency, or storage location as needed.

Known Issues & Limitations

  • autoNamespace depends on git command to read current branch (git branch --show-current); non-git directories automatically degrade to only using cwd directory name, cannot differentiate namespace by branch
  • memory_expand requires host to provide sessionQuery service; returns "sessionQuery service unavailable" when not injected, trace information cannot be expanded
  • With progressive: true (default), if memory skill loading doesn't automatically activate current Agent's tools, need to manually call memory_activate; setting progressive to false registers all tools at once but loses the Agent isolation advantage
  • When L1 index exceeds maxIndexLines, only prompts over_limit=true, no automatic compression, requires manually running memory_index or memory_maintain
  • Evidence during write/accept candidate is a string, self-certified by caller; plugin itself doesn't verify evidence actually corresponds to a successful tool call
  • Pending candidates are archived to archive/ and original files deleted after successful memory_accept, but buffer doesn't rollback when accept fails

Read the usage guide →

Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.

Listing badge

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](https://deepseek-plugin.org/plugins/DDDFXYqiming/Agent_Extensions/dsh-plugins/dsh-layered-memory)

Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.

← Back to plugin directory