dsh-memory-plugin: Workspace-level Memory and Rules, Index Injection + On-demand Retrieval

Preface

When running long sessions or cross-day collaboration in DSH, the model can only rely on the current context. Writing user preferences and project constraints into the system prompt can help, but too many entries consume tokens, and old content can silently get truncated. Tying memory to a specific repository means starting over whenever you switch workspaces.

Below introduces the community plugin dsh-memory-plugin (maintainer: AieXile, category: memory). It loads at DSH startup as a profile bundle and persists across restarts; memory and rules are stored in each workspace’s .dsh-memory/memory-store.json, decoupled from specific project code, so any workspace can use the same set of capabilities.

What This Is

dsh-memory-plugin is a standalone DSH memory/rules persistence plugin. It evolved from the dynamic Cordis plugin in the AnimeTrack project and became independently named starting with v1.4.0; storage paths migrated in the same batch, with old data automatically compatible.

The plugin does three things: injects a memory index and enabled rules into the system prompt each turn; registers memory_* / rule_* tools to the model; and provides a readable/writable management interface in the session title bar and settings page.

Core Features

Index-based Injection (since v1.5.0)

Version 1.4 and earlier injected the full text of the most recent 25 memories into the system prompt; with many entries this consumed context, and anything beyond the limit was silently sliced away by slice(-25). Starting with v1.5.0, this changed to a two-tier structure (benchmarked against Claude Code’s auto memory in the README):

  • Index resident: Each turn only injects a one-line-per-entry index, e.g. - [feedback] Answer in Chinese, no honorifics #style #language (m7);
  • Body on demand: The model uses memory_get(["m7"]) to read full text, and memory_search("keyword") to retrieve entries not listed in the index by keyword, tag, or type;
  • Fixed budget: Index 2400 characters / max 40 entries, rules 1200 characters / max 25 entries. When full, the prompt states “N more entries not shown, use memory_search” instead of silently discarding them;
  • Deduplication: memory_add directly rejects bodies that are identical (ignoring case and whitespace), returning the existing entry’s id.

Search uses local scoring (Latin words + Chinese bigrams + tag/type hits), without introducing embeddings or vector databases.

Memory Types and Tags

Types include user (about the user), feedback (corrections and preferences), project (decisions, constraints, pitfalls), reference (where to find things). Each entry can carry tags and createdAt / updatedAt. Old data loaded without these fields will be auto-filled with project and empty tags.

Model Tools

Tools listed in the README: memory_view, memory_search, memory_get, memory_add, memory_remove, memory_rollback, rule_add, rule_remove, memory_debug.

Turn-End Distillation, Drafts, and Version Chains (v1.6.0)

Automatic distillation is off by default and activates after checking the box on the “Memory” tab in the panel:

  1. Listens for turn-related events on session/event, asynchronously distills at turn end without blocking turn wrap-up;
  2. Only processes turns that reach minChars (default 800); default 5-minute cooldown per workspace;
  3. Sends a helper request using the current session’s provider/model, requiring a JSON array response; locally filters duplicates and invalid supersedes;
  4. Results first enter the draft queue (panel shows “N pending for review”); only after approval are they written as active memories; drafts are not injected and do not participate in search;
  5. When new facts supersede old ones, supersedes: "m3" can be included: the new entry becomes active, the old one is archived, and the panel and memory_rollback support rolling back one step.

Default parameters: minChars: 800, cooldownMs: 300000, maxDraftsPerTurn: 3; the panel currently mainly exposes the auto-distillation toggle, other settings can be changed in settings of memory-store.json.

Interface Entry Points

  • Title bar icon: A 28×28 circular icon in the same row as conversation.session.header.utilities, clicking opens a floating layer anchored below the icon;
  • Settings page: “Memory & Rules” in settings.section.

Workspaces and Data Files

The memory store is split into files per session workspace: <workspace>/.dsh-memory/memory-store.json. The target root is resolved and locked in order at load time: explicit session, current initiator session, pinnedRoot, configuration root sandboxPolicy.workspaceRoot. Each root has its own state, and writes only land on the root belonging to the current state.

Version 1.3.x and earlier wrote to .animetrack/memory-store.json, with consistent format; if the new path does not exist but the old one does, it falls back to reading the old path, and the next write goes to the new path. Old files are not modified or deleted.

Installation and Activation

This is a standard npm package + DSH bundle, installed via plugin_manager install_bundle (do not manually modify the profile’s package.json / cordis.patch.yml, and do not manually run pnpm). Operations require the session to be danger-full-access, or the approval policy to be ask with your approval.

Install from GitHub (release form, current version tag is v1.6.0):

plugin_manager install_bundle
  target: github:AieXile/dsh-memory-plugin#v1.6.0
  # You can also write the full address: git+https://github.com/AieXile/dsh-memory-plugin.git#v1.6.0

Install from npm (after release):

plugin_manager install_bundle
  target: dsh-memory-plugin@1.6.0

Install from local directory (for development):

plugin_manager install_bundle
  target: F:\Projects\dsh-memory-plugin

Local paths are written as link:<absolute-path>. After modifying source code, restart DSH to load the new Host half code; the Client half can be refreshed by refreshing the page.

When upgrading from @animetrack/memory-plugin, you need to remove_bundle and then reinstall dsh-memory-plugin, and restart DSH; if cordis.patch.yml still contains id: animetrack-memory-rules, it should be deleted (the new version’s entry is dsh-memory-rules). Tool names and data formats do not need to be migrated.

Typical Usage

Verify Whether It Is Loaded

  • Host: cordis_inspect_query → host / Config / listConfigs, entry is include:dsh-memory-rules;
  • Tools: A new session’s tool list should show memory_view, memory_search, memory_get, etc.; memory_debug can view known roots, entry counts, injection statistics, etc.;
  • Injection: The system prompt should show Memory index (N of M; …), full text should not appear in bulk; memory_get(["m1"]) can retrieve full text;
  • Routing: GET /dsh-memory/memory-store?sessionId=<session-id> returns the store and preview budget statistics;
  • Interface: Circular icon in the title bar and “Memory & Rules” in the settings page.

Model-Side Memory Read/Write

When full text is needed, call memory_get; when retrieving entries outside the index by keyword or tag, use memory_search; add/remove with memory_add / memory_remove; rules use rule_add / rule_remove.

Automatic Distillation (Optional)

Check “Automatically distill to drafts at turn end” on the “Memory” tab in the panel. After completing a conversation turn with at least 800 characters, approve it in “Pending for Review” before it enters the store. Off by default because it generates additional model calls.

Self-Test Without Modifying DSH

node test/host-harness.mjs

Drives lib/host.js with a real file system and fake ctx, covering tools, injection, routing, old path migration, and other logic.

Use Cases and Notes

Who it’s for: DSH users who need to reuse the same profile across multiple workspaces, want memory to follow project directories, and want to control per-turn prompt size; scenarios requiring rules to be resident, memory to be searchable, optional turn-end distillation, and manual approval.

Structure and dependencies: Dual-face package, Host is ESM (lib/host.js), Client is a classic script (lib/client.js); zero dependencies, zero peers, not participating in DSH version gating. The README reports tested on DSH 0.1.7-rc.2 + pnpm 11.7 (Windows).

Permissions and security: The plugin reads/writes workspace files under the current DSH process permissions and registers HTTP routes and tools. Before installation, you should read the repository source code and the MIT license to confirm it meets your environment policy; automatic distillation sends helper requests to the current session’s model, so pay attention to costs and data export policies.

Always restart DSH after changing code: The Host half’s webServer / tools registrations are in-process and will not be fully released by disable→enable or bundle reinstallation; only a restart guarantees clean single-instance loading.

Conclusion

dsh-memory-plugin makes “memory + rules” a persistent bundle tied to workspaces: index injection controls budget, tools and local search supplement full text, the panel and settings page allow management and review, and v1.6.0 adds optional turn-end distillation and supersedes version chains.

The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer. Stars and versions are based on the repository (current package version 1.6.0).

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

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

Xiaoye