dsh-memory-file: Using Markdown Files for Verifiable Long-Term Memory

Introduction

Running agents in DeepSeek Harness (DSH) often requires remembering preferences, project conventions, and stable facts across sessions. Writing content into system prompts or manually pasting it every time is hard to maintain; delegating “what to remember” to a black-box plugin makes it difficult to verify if it read the conversation, accessed the network, or if mistakes can be retracted. Here we introduce the community plugin dsh-memory-file (maintained by wojiao42), categorized as “Memory”: it uses local Markdown files to carry long-term memory, injects content before the first step of each session, and provides tools for reading, writing, and undoing. By default, it does not read conversations or access the network; optionally, it can read only your own messages from local session logs for agent archiving.

What is This

dsh-memory-file is a host-side plugin for DSH (current version 1.2.2, MIT License). Its positioning is “file-based long-term memory”: memory is stored in $DSH_HOME/memory/MEMORY.md (global) or <workspace>/.dsh/memory/MEMORY.md (workspace, default write target). The format is plain Markdown with no private syntax, allowing for manual editing at any time.

The plugin does not perform model calls, summarization, or infer “what is worth remembering”; it is responsible for injecting existing memory, backing up the entire file before writing, managing a pending review queue, undoing operations, and (optionally) incrementally reading your own message snippets from $DSH_HOME/sessions/. The README emphasizes verifiability: a single index.js file, no build step, no third-party network dependencies. The repository’s smoke.mjs performs static and behavioral assertions on claims such as “does not read messages,” “does not scan logs by default,” and “sensitive IO must be registered.”

Core Functions

Session Injection

On the first agent/pre-step of each session, the plugin reads the memory file and injects it (injection happens only once per session). If the size exceeds the configured maxBytes (default 16384 bytes), it will be truncated; the injection block can be configured with a header introductory text. If there are unprocessed items in the pending review queue, a pending reminder will be appended to the end of the injection (v1.2.1).

Agent Tools

Tool Function
memory_add Writes a fact; can include source, date; pending: true only adds to the pending review queue. Backs up the entire file before writing.
memory_recall Plain text keyword search within the memory file (multiple words act as “AND”).
memory_list Lists memory path, size, modification time, number of backups, and number of pending items.
memory_undo Retracts the most recent write and restores the full content from before the write; list: true only lists backups.
memory_pending Pending review queue: list / accept / drop (dropping only changes the flag, does not delete the file).
memory_scan For merging in new conversations: status / preview / scan / ack.
memory_status Reports current DSH_HOME, number of sessions, existence of other homes, and whether the two memory files are in place (used to discover issues like “historical session list disappearing” after installation directory changes).

Design Constraints (README corresponds to source code)

  • By default, does not read messages passed by the Harness; the only subscription is agent/pre-step, and the callback does not destructure messages.
  • Does not read session logs by default: autoScan defaults to false; when enabled, it only reads logs under $DSH_HOME/sessions/**, extracts user messages with source.clientTimeZone, and does not write to session files.
  • No network access: No fetch / http, etc.; dependencies are only Node built-in modules and @deepseek-ai/dsh-llm, @deepseek-ai/dsh-tools.
  • Does not execute commands; does not delete or rename session logs; paths are derived internally by the plugin, and external paths are not accepted.
  • Since v1.1.0: Sensitive operations like readdirSync / copyFileSync / reading sessions must be registered with [audit:...] at the call site, and smoke.mjs verifies the number of registrations against the number of calls.

autoScan (Optional, disabled by default)

When configured with autoScan: true, the first pre-step of each session will incrementally scan session logs (only files with changed sizes are decoded). Unmerged messages (default max 30 items, ≤4000 characters) are appended after the injection, prompting the agent to handle them using memory_add or memory_add(pending: true). After completion, memory_scan(action: 'ack') advances the cursor. Single files >8MB are skipped; single-round total read volume >32MB stops the work; failures are wrapped in try/catch entirely, not affecting normal injection.

Installation and Enablement

The DSH desktop profile is hosted by the application; do not use dsh plugin --profile desktop add ... (it will be rejected). The official channel is the GUI Plugin Market:

Settings (Ctrl+,) → Plugin Market → Custom Installation → Enter github:wojiao42/dsh-memory-file

For local development, you can enter a local absolute path for installation. Installation sources support npm / github / local paths; the plugin has no client UI, so no dsh.client declaration is needed.

Enable and configure in the profile (fields based on README):

- id: memory-file
  name: 'dsh-memory-file'
  config:
    maxBytes: 16384
    dshHome: null
    header: 'The following is the content of the user long-term memory file.'
    autoScan: false
    autoScanMaxTurns: 30
    autoScanMaxChars: 4000

Typical Usage

1. Memory file example (MEMORY.md in workspace or global directory):

# Memory

- [2026-10-02] Prefers concise answers, no lead-in (Source: User's exact words)
- Has fixed appointments every Wednesday evening

2. Let the agent in the conversation record things conveniently (zero extra processes): Specify in the workspace convention file (e.g., AGENTS.md): When discovering persistent facts, if confident, use memory_add (with source); if unsure, use memory_add(pending: true). No need to repeatedly ask the user “do you want to remember this.”

3. Combined with autoScan: When autoScan: true, the beginning of a new session will hand recent snippets of your own messages to the agent; used together with the previous convention, this is the “fully automatic material + judgment with complete context” combination recommended by the README. If you do not want to read session logs, keep autoScan: false; you can manually memory_scan(action: 'scan') if necessary.

4. Verification and Rollback: Use memory_list to check paths and pending counts; use memory_undo for mistakes; use memory_pending’s list / accept / drop for pending items. If the Harness installation directory changes and the session list behaves abnormally, you can let the agent call memory_status to check DSH_HOME and session count.

Verification scripts can be run locally within the repository (no network connection):

node smoke.mjs
node tools/publish-test.mjs

Applicable Scenarios and Notes

Suitable for: Developers who want long-term memory to reside in plaintext Markdown with backup and undo capabilities; want default no conversation reading or network access, with session log reading requiring explicit autoScan activation; need keyword recall on the agent side or troubleshooting for DSH_HOME drift.

Notes:

  1. The plugin runs with the current DSH process permissions. Before installation, you should read the GitHub Source Code and MIT License to judge whether it meets your security requirements.
  2. Injection is only effective during the first pre-step of a session; if the memory file is manually modified mid-session, it will not be re-injected in the current session.
  3. memory_recall is literal matching, not semantic search.
  4. The community directory SkillHub Plugin Page and GitHub are independent information sources, with no official affiliation to DeepSeek / High-Flyer; the DSH ecosystem philosophy is “everything is a plugin.” Facts in this article are subject to the repository README and package.json.

Conclusion

dsh-memory-file turns long-term memory into single-file, manually editable, backed-up-before-writing, and undoable-when-wrong Markdown, and hands the “read session logs or not” decision to the autoScan switch; the judgment of what to remember is still done by the agent in the conversation or your own scripts. The plugin only provides material and guardrails. For further information, please visit the directory page and repository:

  • Directory Page: https://www.skillhub.cn/plugins/wojiao42/dsh-memory-file
  • GitHub: https://github.com/wojiao42/dsh-memory-file
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye