dsh-global-memory: Write Cross-Session Requirements into Every System Prompt

Preface

When using agents or daily coding assistants in DeepSeek Harness (DSH), the same constraints often repeat: reply in Simplified Chinese, run tests after code changes, and admit uncertainty when unsure. Repeating these instructions when starting a new session, switching tasks, or changing agents is error-prone, and handoffs become unstable.

The ecological approach of DSH is “Everything is a Plugin”: capabilities are assembled via bundles in a profile rather than modifying the host core. The community plugin directory is maintained on sites like SkillHub, with no official affiliation to DeepSeek or High-Flyer. Below, we introduce the memory plugin dsh-global-memory (GitHub: 07vvvv/dsh-global-memory) published by maintainer 07vvvv. It solidifies “a global requirement” into a local JSON file and automatically injects it when the host assembles the system prompt, achieving the “write once, follow in every subsequent session” goal.

What is this

dsh-global-memory is a global memory plugin for DSH: a piece of persistent text spanning sessions and tasks that is injected into the system prompt of every session, ensuring the model sees the same set of constraints in every task.

The plugin provides three links for reading and writing the same source of truth: automatic injection, the global_memory Agent tool, the “Global Memory” panel on the settings page, and the homologous HTTP API /global-memory/api/*. The license is MIT, requiring Node.js >=22; the package version in the repository’s package.json is 0.1.0.

It benchmarks against the global total memory feature of the similar plugin memory-eternal, but the implementation is completely independent: this plugin uses $DSH_HOME/global-memory.json, with the prompt segment named global-memory and order 555; memory-eternal uses its own storage and segment order 600. Both can be installed simultaneously without reading or writing each other’s modules.

Core Features

Automatic Injection per Turn

When the host assembles the system prompt for each turn of dialogue, the plugin injects the body via ctx.systemPrompt.section({ name: 'global-memory', order: 555, text }). Once the text or toggle changes, the segment content is rebuilt immediately, taking effect on the next request (next message) without needing a host restart.

When text is an empty string, injection is skipped; when enabled: false at runtime, injection is also skipped, but the body remains preserved in the file.

Agent Tool global_memory

The model can call this when the user requests to “remember a global requirement,” “do this every time in the future,” or needs to confirm current global requirements. The parameter is { action: string, text?: string }, where action is required and has 7 types:

action text required? Function
get No Read status and body
set Yes Replace body entirely (does not change enabled)
append Yes Append an entry to the end and auto-enable
clear No Set body to empty
reset No Restore built-in default body and enable
enable / disable No Turn injection on or off (body preserved)

After a successful write, the prompt segment is also rebuilt immediately.

Settings Page and HTTP API

A Global Memory section appears in DSH Settings: you can edit the body, view character count and update time, save (supports Ctrl/⌘ + S), enable/disable, restore defaults, and reload.

The homologous API prefix is /global-memory/api, for example, querying status:

curl -s http://127.0.0.1:<host-port>/global-memory/api/state

On success, it returns JSON containing fields like ok, enabled, text, chars, updatedAt, path. <host-port> is the port used when opening the GUI.

Storage and Switches

The default storage path is $DSH_HOME/global-memory.json; if DSH_HOME is not set, it falls back to ~/.dsh (Windows: %USERPROFILE%\.dsh).

Field Description
version Structure version, currently 1
enabled Whether to inject at runtime
text Global memory body text
updatedAt ISO 8601 time of the last write

When reading fails (file missing, JSON corrupted, incorrect type), it falls back to default values without throwing exceptions; it does not automatically overwrite the original file when corrupted. Writing uses an atomic method involving a temporary file followed by rename.

The semantics of the two layers of switches differ:

  • Config Layer config.enabled: false in cordis.patch.yml: The entire plugin is not loaded; injection, tools, and API do not exist.
  • Runtime enabled: false in global-memory.json or turned off via tools/settings page/HTTP: Only injection stops; tools and routes remain available.

Uninstalling the plugin does not delete global-memory.json; if you wish for it to be “empty and not injected,” you should first clear the body and turn off the runtime switch, then delete the file as needed. If only the file is deleted, the plugin will fall back to the built-in default body and enable itself.

Installation and Activation

Prerequisites (see repository README):

  • DSH host version >=0.1.5-alpha.2 <0.2.0, profile is web or desktop.
  • Node.js >=22.
  • Profile directory: ~/.dsh/profiles/<profile>/ (Windows: %USERPROFILE%\.dsh\profiles\<profile>\).

The repository does not provide a one-click command like dsh plugin add github:...; the common practice is to manually integrate into the profile or use an installed plugin manager/injector.

Method A: Register in profile’s package.json

1. Obtain the plugin source directory (path recorded as <plugin-directory>, must contain index.js and cordis.patch.yml).

2. Edit the profile’s package.json, add a link: dependency in dependencies, and append dsh-global-memory to the dsh.profile.bundles array (do not replace the entire bundles section to avoid removing other plugins):

{
  "dependencies": {
    "dsh-global-memory": "link:<plugin-directory>"
  },
  "dsh": {
    "profile": {
      "bundles": [
        "dsh-global-memory"
      ]
    }
  }
}

It is recommended to use forward slashes / for paths to facilitate cross-platform compatibility.

3. Create a node_modules link in the profile directory (skip if the package manager already supports link: and has completed installation). Unix-like example:

cd ~/.dsh/profiles/<profile>
mkdir -p node_modules
ln -s "<plugin-directory>" node_modules/dsh-global-memory

4. Restart the host. dependencies and bundles are resolved during the host startup phase; a restart is required after adding a new bundle.

5. Verify: Logs show [global-memory] loaded: injecting, <N> chars, storage <path>; the settings page has “Global Memory”; the above curl returns ok: true.

If src/client/** was modified, you need to run npm install and npm run build:client in the plugin directory to rebuild lib/client.js; by default, the build artifacts committed to the repository are used, so this is usually skipped.

Method B: Plugin Management UI / Runtime Injector

If there is already a plugin with installation capabilities in the environment (e.g., dsh-super-injector), you can pass the plugin directory to its installation entry, for example, assembling it in one go:

dev_install_package(dir = "<plugin-directory>")

For temporary trial without writing to the profile, use dev_inject_plugin(dir = "<plugin-directory>"); for uninstallation, use the corresponding dev_uninject_plugin entry provided by that plugin. Refer to that plugin’s documentation for specific parameters; if no such tool is available, use Method A.

The config layer can override config.enabled by the id global-memory in the profile’s cordis.patch.yml.

Typical Usage

Maintain body text in the Settings page
Open Settings → Global Memory, write something like “Reply in Simplified Chinese; run project tests after modifying code; conclusions without basis must be marked as uncertain.” After saving, the system prompt starting from the next message will include this segment.

Append constraints via tools
When the user says “Update OpenAPI comments every time the API is changed from now on,” the model can call global_memory with action=append and text as the specific sentence; upon success, refreshing the settings page will show the merged result.

Temporarily disable injection
If you do not want to affect the current session style, turn off “Enabled” on the settings page, or POST /global-memory/api/enabled with body {"enabled":false}; the body is preserved and can be re-enabled later via enable.

Coexist with memory-eternal
Their segment orders differ (this plugin 555, memory-eternal 600), allowing both to carry memory strategies of different levels without sharing storage files.

Applicable Scenarios and Notes

Suitable for teams or individuals who need stable, auditable global behavioral constraints: coding standards, language preferences, testing and disclosure principles, etc., and wish to avoid repeating instructions in new sessions.

Please note before installation:

  • The plugin runs with the current DSH process permissions; permission declarations are low-level, only reading and writing $DSH_HOME/global-memory.json, no network access, no subprocesses. It is still recommended to read the repository source code and the MIT license before installation.
  • The host version must fall within the compatibility range declared in the README; behavior is not guaranteed in the documentation if it does not match.
  • Global memory enters the system prompt of every session; excessively long body text will occupy context, so it should be kept short and executable.

Conclusion

dsh-global-memory implements the “write once, follow every time” global requirement into local JSON, maintaining consistency through three links: the injection segment, the global_memory tool, and the settings page/API. If you are already using DSH’s web or desktop profile, you can manually link according to the profile or use an injector to assemble it, then confirm activation via logs, /global-memory/api/state, and the settings page.

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

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

Xiaoye