Cross-session-memory: Turning Programming Lessons into an On-Disk Mistake Book

Introduction

When using AI for coding in DeepSeek Harness (DSH), a common pain point is “amnesia in every new session”: pitfalls encountered last week or fixes already verified must be explained from scratch in the next round of conversation. Some users employ vector databases, knowledge graphs, or automatic extraction pipelines for long-term memory, but these are often too heavy for a personal “mistake notebook” and introduce a larger attack surface.

Here we introduce the community plugin cross-session-memory (repo name GIN0076/cross-session-memory, also known as Agent Lesson Book). It stores lessons as pure Markdown, enforces evidence chains to constrain writing, and automatically injects a small index into every session, allowing the agent to recall and save under gates, rather than treating memory as executable instructions.

What is this

cross-session-memory is a DSH plugin published by maintainer GIN0076, categorized under “Memory”. Its positioning is: zero-dependency cross-session memory for AI coding agents—Lessons on disk, evidence enforced, auto-injected.

The same engine (tools/mem.mjs + tools/mem-core.mjs) has two usage modes: a standalone CLI (e.g., injecting index into AGENTS.md) and a native Harness plugin (prompt injection every turn, mem_recall / mem_save tools, /memory commands, and read-only settings cards). The plugin package name in package.json is @local/dsh-memory, with the current community directory version marked as v0.5.2; the license is MIT. The runtime requirement is Node.js ≥ 18.

Core Features

Four-Part Lessons and Evidence Gates

Each lesson is organized by Symptom / Cause / Fix / Verification. During writing, if a locatable evidence reference (path, filename, section, issue number, etc.) is missing, the store will reject it. One of the design principles is: Memory is data, not instructions.

Auto-Injection and Retrieval

  • Injection Budget Hard Cap: ≤ 2KB index; if over budget, lines are trimmed, and if reading the index fails, it silently degrades to a pointer convention, does not block the session.
  • Retrieval: IDF-weighted three-way search (literal, Chinese n-gram, aliases), with optional two-stage reranking (credibility, freshness, feedback adoption records).
  • Harness Side: mem_recall merges searches from the Lesson Book and Past Session Full Text; mem_save goes through the full write gate and is constrained by Write Mode.

Write Modes and Human Maintenance

Write modes: approval (default, model writes require human confirmation), auto-draft, auto-low-risk, off. Commands executed by humans via CLI or /memory are not restricted by write modes.

The plugin also provides: multiple maintenance subcommands under /memory (e.g., doctor, review, conflicts, resolve, explain, verify, draft / approve / reject, write-mode, etc.); Read-only Settings Card in the Harness UI showing status, credibility distribution, recall hit rates, and entry search (no write access).

Other Documented Capabilities

  • Entry Lifecycle Labels: verified / provisional / needs-review / stale / disputed; review re-checks approximately every 90 days.
  • Conflicts: conflicts lists contradictory pairs; resolve records the adjudication; entries are preserved, and the loser may be derived as stale.
  • Privacy: DSH_MEMORY_TELEMETRY=off disables local telemetry writes; entries containing emails or mainland phone numbers may be rejected by PII scanning.

Installation and Activation

Installation on the DeepSeek Harness side follows the repository’s plugin/README.md, not a simple one-liner like dsh plugin add github:…. The official instruction is to install the bundle via the plugin manager:

plugin_manager → install_bundle → target = <clone>/plugin/dsh-memory

One command attaches prompt injection, mem_recall / mem_save, /memory, and the read-only settings card. If the bundle already exists, the documentation requires remove_bundle before installing again; otherwise, it may trigger ambiguous-install.

Dependency Materialization requires extra attention: the bundle manifest deliberately does not declare npm dependencies; @deepseek-ai/dsh-tool-session-query, etc., must be linked to the local DSH source path via junction / dsh plugin … add "link:…" in the bundle’s node_modules and profile. See plugin/README.md for specific PowerShell examples and alternatives.

Configuration items (cordis.patch.yml):

Key Default Value Meaning
memoryCorePath Resolved relative to ../../tools/mem-core.mjs if empty Needs to be changed to the absolute path of mem-core.mjs if the installation path changes
maxHits 8 Number of entries returned by mem_recall by default

For acceptance, you can refer to the six-item checklist in the documentation, such as: dsh --profile <profile> --dump-config shows no import failures, the first turn prompt contains a ≤2KB index, mem_save does not write to disk without approval, /memory doctor matches node tools/mem.mjs doctor, etc.

If you only want to use the engine as a standalone CLI (without installing the Harness plugin), copy the repo contents to the project root and execute:

node install/setup.mjs --with-sample

Optional smoke test:

node install/smoke.mjs

Typical Usage

Write the First Lesson (CLI)

First draft the four-part skeleton, complete the evidence in the verification section, then store it and run a health check:

node tools/mem.mjs draft ssh-timeout
# edit .memory/drafts/<date>-ssh-timeout.md
node tools/mem.mjs store .memory/drafts/<date>-ssh-timeout.md
node tools/mem.mjs doctor

See the git-autocrlf-breaks-byte-exact-restore sample in the repository README.zh-CN.md for entry front matter and the four-part example.

Recall and Save in Harness

  • The model calls mem_recall to search the lesson book and full session history.
  • When the model calls mem_save, manual approval is required under the default approval mode; you can also maintain it via subcommands like /memory save <file.md> in the chat.
  • Check health status: /memory doctor or CLI node tools/mem.mjs doctor.

Common CLI entries (24 subcommands total):

node tools/mem.mjs search "keyword" --two-stage
node tools/mem.mjs show <name>
node tools/mem.mjs write-mode approval

Use Cases and Cautions

Who it is for: Developers who want a diffable, git-manageable Markdown mistake notebook to reuse verified lessons across multiple DSH sessions; suitable for personal or small team scenarios that do not require vector databases or additional services.

Please note before use:

  • The plugin runs under the current dsh process permissions and will read/write paths like .memory/ under the workspace; before installation, you should read the source code and the MIT license, and assess whether the key/PII scanning meets your compliance requirements.
  • The community directory SkillHub Plugin Page is an independent site with no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem emphasizes “everything is a plugin,” and the directory page facilitates discovery but is not equivalent to an official app store.
  • CJK full-text session retrieval is subject to upstream FTS tokenization limitations, and short words may be unstable; lesson book retrieval is not affected (follow-up improvements are mentioned in the roadmap).
  • mem_save will be rejected if the approval policy is never; you need to switch to manual paths like /memory save.

Conclusion

cross-session-memory uses structured lessons on disk, evidence-enforced writing, and ≤2KB auto-injection to strike a pragmatic middle ground between “heavy memory platforms” and “complete amnesia”: data is readable, auditable, and fails gracefully. If you want to implement a cross-session mistake notebook in DSH, you can get an overview from the community directory and complete installation and acceptance using the GitHub repo’s plugin/README.md and the Chinese README.zh-CN.md.

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

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

Xiaoye