Preface

When using DeepSeek Harness (DSH) for long sessions, the official context compaction compresses a large portion of history into a summary when the context approaches its limit. Only the summary remains in the session; the folded user messages, model responses, and the reasoning context at that time cannot be recovered from the Harness by default.

If you need to reference “what was actually said before compaction” afterward—for auditing or review purposes—relying solely on the summary is often insufficient. The community plugin dafiyu-fold (maintainer cazhaniyyah603-ui) addresses exactly this: without replacing the official compaction engine, it writes the entire text being folded to local Markdown just before the official summarize() call. The summary is still generated by the official pipeline, and session behavior is identical to when the plugin is not installed; what you get additionally is an archive on disk.

What Is This

dafiyu-fold is categorized as “Memory” on SkillHub, currently has about 3 stars on GitHub, is at version v1.0.0, and is licensed under MIT. The README summarizes its capability in one sentence: archive the raw context before DSH compaction replaces it with a summary, implemented by wrapping the official summarize(), without modifying the engine itself.

The plugin does not connect to the network, does not upload data, and does not modify session files; compaction is still performed by the official engine—it merely makes a copy alongside it.

Core Features

Before each compaction round is triggered, the plugin generates a Markdown file with a path like:

~/.dsh/fold-archive/折叠-插件-2026-10-18T06-19-18.md

The file preserves message entries by role, with content identical to the input passed to summarize(). The official summary is generated and appears in the session as usual.

The implementation injects into the compaction service: it obtains the engine prototype in the ctx.inject(['compaction']) callback, overrides only summarize(), archives first, then calls the original method. Prompts, thresholds (such as thresholdRatio, retainTokens), etc. are all configured by the official @deepseek-ai/dsh-compaction-basic, which the plugin does not touch.

What it explicitly does not do includes: replacing the compaction engine, modifying prompts or thresholds, or automatically cleaning up the archive directory.

Installation and Activation

The following covers one-click installation from GitHub (the README notes it is tested and working on DSH 0.2.0, with v1.0.0 installed in about 8 seconds):

dsh plugin --profile desktop add github:cazhaniyyah603-ui/dafiyu-fold

After installation, two more steps are required; without either one, the plugin will not work:

  1. In the package.json of the profile you are using, add dafiyu-fold to the dsh.profile.bundles array;
  2. In cordis.patch.yml, write - id: dafiyu-fold under the config within the compaction group, at the same level as compaction-basic.

You can also install manually: place the repository directory in the plugin directory, and write "dafiyu-fold": "link:/绝对路径/到/dafiyu-fold" in the dependencies of the profile’s package.json.

Must Be Placed in the Compaction Group

DSH places the compaction service in a group with isolate.compaction: true; plugins outside this group cannot inject(['compaction']). If dafiyu-fold is written at the outermost level of the profile, errors such as cannot get property "compaction" without inject will occur.

Correct configuration example (excerpt):

- id: compaction
  name: cordis:group
  group: true
  isolate:
    compaction: true
    toolResultPruner: true
  config:
    - id: compaction-basic
      name: '@deepseek-ai/dsh-compaction-basic'
      config:
        thresholdRatio: 0.22
        retainTokens: 40000
    - id: dafiyu-fold
      name: dafiyu-fold

Verification and Configuration

After installation and patch configuration, you can use the log to confirm it is active:

tail -f ~/.dsh/dafiyu-fold.log

The normal log output shown in the README should include apply 进来了 (the apply callback fired), inject('compaction') 的回调进来了 (the inject(‘compaction’) callback fired), and a message such as “every future compaction will first persist the raw text to disk”. After that, each compaction adds one more 折叠-插件-*.md file to the archive directory.

Optional environment variables:

Environment variable Default Purpose
DAFIYU_FOLD_DIR ~/.dsh/fold-archive Raw text archive directory
DAFIYU_FOLD_LOG ~/.dsh/dafiyu-fold.log Log path

Use Cases and Cautions

Suitable for: users of desktop profiles with long sessions that frequently trigger compaction, who need to retain searchable raw text beyond the summary; scenarios requiring a “pre-compaction snapshot” for compliance or review purposes.

Notes:

  • The plugin depends on wrapping the summarize hook inside the official engine, and may stop working after a major DSH version upgrade; if the log shows “没有 summarize” (no summarize found), you can remove the corresponding line in cordis.patch.yml, which generally does not affect startup.
  • A file is written for each summarize call; if the official engine makes multiple calls within one compaction round, you will get multiple archive files, which is expected behavior.
  • The archive directory will grow continuously; the plugin does not delete files automatically, so you need to clean it up yourself.
  • The plugin runs with the current dsh process privileges; before installing, it is recommended to read the repository source code and the MIT license to confirm that paths and data remain on your local machine.

The DSH ecosystem emphasizes “everything is a plugin”; the SkillHub directory page is a community site with no official affiliation with DeepSeek / High-Flyer.

Conclusion

dafiyu-fold has a very focused value: before the official engine performs compaction, it copies the raw text about to be replaced by a summary into ~/.dsh/fold-archive/, without changing the compaction strategy. When configuring, make sure to place the plugin in the compaction isolate group. For more information, see the GitHub repository and the SkillHub plugin page.