dsh-shared-memories: Using Git for Full DSH State Snapshots and Cross-Machine Restore

Introduction

In DSH, connecting memory-type plugins usually involves remembering dialogue snippets or vector retrieval, but rarely covers the “Agent state across the entire machine”: persona, rules, workspace session indices, versioned memory trees. When changing computers or reinstalling environments, one often relies on exporting JSON and manually importing it, and it is hard to guarantee consistency with the moment before shutting down.

dsh-shared-memories (maintained by Thousand-Beam, categorized as “Memory” in the community directory) treats personality, memory, and workspace sessions as versionable state, using a local Git repository (optionally pushed to your own private remote) as the transport layer: on the shutdown path, package a snapshot and commit; on the startup path, pull, verify sha256, replay the journal, and then allow new conversations. Below is an explanation of usage based on positioning, capabilities, installation, and the two running modes.

What is it

The plugin’s full name is DSH-Shared-Memories, described as a “Git-based native external cloud brain · full state roaming engine”: shutdown is a snapshot, boot is a restore. The state scope includes persona profiles, memory time trees, rules, workspace session indices, skills, and session-related indices (stated in README as memory, personality, skills, session indices, user personas), stored in the Git repository in the form of append-only event logs.

The shutdown flow for Device A is: quiesce → capture → sha256 → commit → tag → rotate → push (if remote is configured). The startup flow for Device B is: pull → verify → replay → rehydrate persona → ready. Before recovery is complete, new conversations are rejected; restore.blockUntilReady defaults to true, and the write path goes through the RestoreBarrier.assertWritable() gate. If recovery is incomplete, it may throw restore-blocked instead of continuing to write on a half-finished persona.

License: MIT; current package version 0.6.4; runtime requirements Node >= 22.5 (depends on node:sqlite), DSH >= 0.2.1-rc.3 (package.json also contains >=0.2.2-rc.0 <0.3.0 range). The package is not published to the public npm registry; it must be installed from GitHub Release.

Core Features

Full State Snapshot & Cold Start

The snapshot pool carries the entire state, not a single-file JSON export. The cold start state machine is: cold → pulling → verifying → replaying → ready; when verification or replay fails, it can enter degraded (read-only), with default offline policy restore.offlinePolicy: degraded-readonly.

Temporal Tree Memory

Memory is represented by a timeline with valid_from / valid_until. When correcting cognition, close the old version, open a new version, increment seq, and write to the journal; history is retained for easy rollback.

Multi-Agent Isolation

Isolated at the SQL layer by workspace_id + agent_id; ScopedQuery is the query entry point. Cross-Agent retrieval is disabled by default; enabling it requires an explicit token and leaves an audit record. Configuration option isolation.strict defaults to true.

Save Triggers

Trigger Timing Description
shutdown Before process exit Primary channel, packaging after quiesce
interval Every sync.intervalSec seconds Fallback
idle / manual Idle or manual Manual save available via console

The console side has zero external links and zero CDN (as stated in the README). The plugin comes with a “Shared Memory” sidebar and a memory console UI.

Mode Explanation

  • Mode A (Pure Local, Default): repo.remote is left empty, snapshots only go to the local machine ~/.dsh/shared-memories and are not pushed; time trees, snapshot pools, pins, rollbacks, isolation areas, and console capabilities are still present, but cross-machine roaming is not supported.
  • Mode B (Cloud Git, Experimental): remote points to a self-hosted GitHub private repository; GitHub acts as a relay, data stays in your own repository. The README states that multi-device roaming is experimental, and cross-device clock offsets may cause journal sorting issues (see KNOWN-ISSUES.md #1 in the repo); single-machine Mode A has no such issue.

Installation and Enabling

The environment must first meet the Node and DSH version requirements. Install steps follow the README:

# Requires Node >= 22.5 (node:sqlite), DSH >= 0.2.1-rc.3
# 1. Open https://github.com/Thousand-Beam/dsh-shared-memories/releases to download the latest dsh-shared-memories-*.tgz
# 2. Run in the directory where the tgz is located (example filename corresponds to 0.6.4):
npm i ./dsh-shared-memories-0.6.4.tgz

Mount the plugin in the profile’s cordis.patch.yml (a cordis.patch.yml is included in the repo for reference):

- insert:
    - id: dsh-shared-memories
      name: dsh-shared-memories

After starting DSH, if a “Shared Memory” sidebar appears on the left, the plugin is mounted. This article does not write commands like dsh plugin add github:... which are not provided in the README.

Typical Usage

Mode A · Pure Local

First perform minimal mounting, then add configuration as needed:

- insert:
    - id: dsh-shared-memories
      name: dsh-shared-memories
      config:
        repo:
          path: ~/.dsh/shared-memories
          remote: ''
        sync:
          intervalSec: 300
        snapshot:
          keep: 5

An empty remote means no network interaction; the default scheduled snapshot interval is 300 seconds, and the sliding window retains 5 snapshots (Pin protected items have snapshot.pinProtected separately).

Mode B · Private Remote (Experimental)

After familiarizing yourself with the plugin via the local configuration above, if you want to restore the same Agent state on a second machine, follow the “Mode B” sequence in the README:

  1. Create a private empty repository on GitHub (memory is private data, must be Private).
  2. Configure SSH (default authMode: ssh-agent), add your public key to GitHub.
  3. Fill in remote, branch, sync, etc., in cordis.patch.yml, for example:
- insert:
    - id: dsh-shared-memories
      name: dsh-shared-memories
      config:
        repo:
          path: ~/.dsh/shared-memories
          remote: git@github.com:you/ai-brain.git
          branch: main
          authMode: ssh-agent
          credentialRef: shared-memories/git-token
        sync:
          enabled: true
          intervalSec: 300
          pushOnCommit: true
          pullStrategy: ff-only
        snapshot:
          keep: 5
        restore:
          offlinePolicy: degraded-readonly
  1. Restart DSH and use “Test Connection” in the top bar of the console to confirm network, credentials, and branch permissions.
  2. On another machine, install the same plugin and the same remote and SSH; on the first startup, it will pull, verify file sha256 from the manifest, replay the journal, rebuild the persona, and enter ready.

When multiple ends coexist, repo.deviceId should ensure uniqueness (if left empty, hostname is used). credentialRef is just a reference name in the keychain, not the token plaintext.

Common configuration defaults (excerpt, full table in README):

Key Default Description
repo.path ~/.dsh/shared-memories Local Git repository directory
sync.pullStrategy ff-only Cold start pull strategy
restore.verifyHashes true Verify sha256 before restore
snapshot.maxBytes 268435456 Single snapshot limit, reject commit if exceeded

Scenarios and Notes

Suitable for developers who need to maintain the same Agent persona and workspace memory long-term within DSH and wish to use Git for versioned snapshots on a single machine. If syncing across multiple machines, you need to accept the experimental constraints of Mode B and ensure NTP clock synchronization on each machine.

The DSH ecosystem philosophy is “Everything is a plugin”; the SkillHub Directory Page is a community site with no official affiliation to DeepSeek / H-Factor. The plugin runs with the current DSH process permissions. Before installing, read Source Code and LICENSE, confirm the license and data disk path (default ~/.dsh/shared-memories and optional private remote).

Conclusion

dsh-shared-memories treats Agent state as Git-managed snapshots and event logs, emphasizes a strong consistency write gate before recovery is complete, and supports time trees, snapshots, and console without relying on the external network in single-machine mode. For further details, known issues, and the complete Schema in src/config.ts, see the project README.

  • Directory Page: https://www.skillhub.cn/plugins/Thousand-Beam/dsh-shared-memories
  • Repository: https://github.com/Thousand-Beam/dsh-shared-memories
羽毛球分组比赛记分
小程序二维码

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

Xiaoye