dsh-zcode-project-memory: DSH Project-Level Long-Term Memory

Preface

When engaging in multi-turn collaboration within the same repository in DeepSeek Harness (DSH), the model often relies solely on the context of the current session. Knowledge that cannot be deduced from the code—such as architectural conventions, debugging pitfalls, and deployment constraints—is lost when the session ends. The next time a new process or window is opened, everything must be explained from scratch again.

The community has already adapted the project memory concepts from the ZCode project to DSH. Below is an introduction to dsh-zcode-project-memory, released by maintainer ffyfox: a long-term, disk-based memory isolated by project. Once installed, memories are written via tools, and the index is automatically injected into the context at the start of new sessions. It is categorized as “Memory” with a current GitHub star count of 0; this is an unofficial community port and has no affiliation with Z.AI (ZCode) or DeepSeek.

What is this

dsh-zcode-project-memory is a Cordis plugin: it registers the save_project_memory tool and injects two segments of content into the system prompt—memory usage guidelines (when to write, format, how to delete) and a snapshot of the MEMORY.md index. The mechanism replicates that of zai-org/ZCode, while the interface on the DSH side conforms to the DeepSeek Harness official documentation.

Memory is isolated by project dimension: the directory name is derived via sha256 from the canonical absolute path of the project root. The same project hits the same data across different processes and sessions; different projects are mutually invisible. Data is written to ~/.dsh by default and does not enter the project repository.

Core Features

The plugin performs three tasks at runtime (summarized from source materials):

  1. Register save_project_memory —— Writes a memory entry (an independent Markdown file + index maintenance).
  2. Inject memory guidelines —— Via ctx.systemPrompt.section(), explaining when to save, body format, and deletion methods.
  3. Inject memory index —— Via ctx.systemPrompt.context(), carrying the directory lines of existing memories into the context at the start of a new session.

It is ready to use without additional configuration after installation; optional configurations are listed in the “Configuration” section below. The plugin injects tools and systemPrompt, provided by dsh-base. It is effective in profiles inheriting dsh-base, such as web, headless, and tui. In deployments lacking these two services, the plugin remains in PENDING state without causing side effects.

Memory types are classified into four kinds in the frontmatter: user, feedback, project, reference. Saving the same memory repeatedly replaces the corresponding file and index line, preventing stacking of duplicate entries. If the index exceeds 200 lines or 25,000 characters, it is truncated with a notice upon injection.

Parts not mounted by default: The repository provides subsystem modules for manifest scanning, automatic extraction, and background summarization in src/subsystems/ for separate import. The default behavior is strictly “tool + two injections” to avoid token and concurrency pressure (see README section “Differences from ZCode”).

Installation and Activation

Install from npm (command from README):

dsh plugin --profile <your_profile> add dsh-zcode-project-memory

dsh plugin add forwards arguments to pnpm within the profile directory. Since the package declares dsh.bundle.patch, the plugin is automatically added to the bundle layer of the profile.

To modify source code locally and apply changes immediately, you can install via an absolute path (must be an absolute path, as pnpm creates a symbolic link):

dsh plugin --profile <your_profile> add /absolute/path/to/dsh-zcode-project-memory

Runtime requires Node.js >=20 (see engines in package.json). The package version in the materials is 0.1.0, and the license is MIT AND Apache-2.0.

Installing the plugin reads and writes to ~/.dsh/memories/ with the permissions of the current dsh process user. It is recommended to review the source code and NOTICE.md on GitHub before installation to ensure compliance with your security and compliance requirements.

Typical Usage

Daily usage involves normal conversation; no dedicated CLI needs to be memorized. The example prompts below are from the README.

Letting the model remember

Explain directly, or have the model proactively save when encountering non-obvious conventions, architectural decisions, or debugging pitfalls:

Remember: migrations for this project must run successfully on staging for 24 hours before being promoted to production.

After the model calls save_project_memory, it writes a single .md file and updates the MEMORY.md index. The guidelines explicitly exclude: temporary task states, and facts already present in the repository (code structure, git history, AGENTS.md, etc.).

Recalling in a new session

The index is injected at the start, so you can ask directly:

What is in the long-term memory of this project?
What was that migration constraint mentioned last time?

The model reads the corresponding memory file on demand based on index lines; this works across sessions and processes because the data is on disk.

Letting the model forget

There is no separate deletion tool. According to the README, you can say:

Forget that memory about migrations.

The model should delete the memory file and remove the corresponding line from MEMORY.md. Deleting only the file leaves a dangling index; both lines must be handled together.

Manual viewing and cleaning

Memories are pure Markdown:

M=~/.dsh/memories/projects/<project_base_name>-<hash>/memory
cat "$M/MEMORY.md"
ls "$M"

To clear a project’s memories, delete the entire memory/ directory; if the directory does not exist, the plugin degrades silently.

Optional profile configuration (illegal values fail at load time, no silent degradation):

- id: project-memory
  config:
    indexLineLimit: 200
    indexCharacterLimit: 25000
    maxMemoryChars: 8000

End-to-end manual verification (requires available model credentials, from README):

cd /your/project
dsh --profile headless "Save this lesson to project memory: <...>, then reply DONE"
dsh --profile headless "What does the long-term memory of this project say? Quote the index lines verbatim."

Scenarios and Notes

Suitable for: Teams or individuals maintaining the same DSH workspace long-term, hoping to precipitate “lessons and conventions” at the project dimension without committing memory files to the repository.

Differences from ZCode saving paths (noted in materials): This plugin uses save_project_memory for unified writing and maintains MEMORY.md via code. Index concurrency employs queuing and file locking to avoid the single save failure caused by optimistic concurrency on the ZCode side; the index is not stuffed into the # agentsMd header (on the DSH side, dsh-agent-instructions is responsible for the instruction block).

Notes:

  • Unofficial project; zcode in the package name merely indicates the source of the implementation.
  • Memory is an enhancement capability: if reading fails, an empty string is injected; if the project directory cannot be obtained, the tool returns saved: false. It should not crash the session.
  • Reading rejects symbolic links and non-regular files; single file size limit is 5 MiB. The writing side employs atomic rename and file locking to reduce the risk of entry loss during concurrency.
  • The DSH ecosystem is “everything is a plugin”; community directories like SkillHub are independent sites, not official DeepSeek / High-Flyer app stores.

Links

Through the steps above, you can install this plugin in your DSH profile, use conversation to accomplish “write—recall across sessions—forget on demand,” and keep project-level knowledge in ~/.dsh without polluting the git working tree.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye