dsh-tui-compact-carry: TUI Compaction Progress Visible, /carry Brings Summaries into New Sessions

# Preface

When working with long sessions in the DeepSeek Harness (`dsh`) TUI, context compaction is common: it compresses automatically when the window is full, or you can manually use `/compact`. However, in the TUI main interface, automatic compaction often lacks obvious feedback; the history of past compactions is not intuitive; and more commonly, after starting a new session with `/new`, the freshly generated full summary remains in the old session while the current session starts blank.

The community plugin **dsh-tui-compact-carry** (maintainer: sailoflight, category: Client) targets **TUI-only** scenarios (`@deepseek-harness-tui/dsh-tui`). It displays the compaction count and ongoing progress in the status line. After a manual `/compact`, it caches the summary and uses `/carry` to write it into the **current** session. Web and headless modes lack `ctx.tuiStatus`; installing the plugin won't cause errors, but there will be no status line. The commands themselves work on both ends, but the plugin is intentionally designed to serve TUI only.

Below is an introduction to the problems it solves, how to use it, and the constraints to be aware of before installation.

# What is this

**dsh-tui-compact-carry** is a zero-dependency plugin (using only Node built-in modules) that does three things by listening to `session/event`:

1.  **Status Line Display**: Shows the **number of compactions** (and tokens recovered in the most recent one). When compaction is in progress, it displays "Compacting... (Attempt N · Ns)".
2.  **Summary Caching**: Identifies the summary generated after a **user-initiated `/compact`** ends, caches it short-term within the process, and indicates "Summary pending carry" in the status line.
3.  **`/carry` Command**: Provides commands like **`/carry`** to append the cached summary to the current agent session. It attempts to use official checkpoint markers so the TUI renders it as a collapsed "Compaction Checkpoint" line.

It does not trigger compaction or interfere with the `/new` switching transaction; compaction is still performed by the official `/compact` command. The plugin only "takes the existing summary + transports it".

# Core Functions

## Status Line: Count and Progress

| Capability | Description |
| --- | --- |
| Compaction Count | Listens for `compaction/summary` and updates the status line via `ctx.tuiStatus.set('compact-carry', …)`. |
| In Progress | Enters progress state on `compaction/start`, exits on `summary` / `end`; refreshes approximately every 1 second. `progressMaxMs` acts as a fallback to prevent event loss. |

Automatic compaction is originally almost silent in the TUI main interface; the plugin surfaces `compaction/start|end` signals to the status line, making it easier to confirm "compaction in progress" rather than assuming the interface is frozen.

## Post-Manual Compaction Caching and /carry

After a manual `/compact` completes, the plugin marks the state as **pending** upon `compaction/end` based on event signatures (`sourceCommandId === undefined && turn == null`). It can prompt the user to use `/carry` via a toast (silently skipped if `ctx.get('tuiToast')` is unavailable).

Common commands (all executed in the **session where you want the summary to land**; writing to `invocation.agent.session`):

| Command | Function |
| --- | --- |
| `/carry` | Default `merged`: Carries the last full summary (the official engine merges previous checkpoints into the new summary). |
| `/carry show` | Previews the source session, recovery volume, and the first 400 characters of the body. |
| `/carry all` | Concatenates every compaction record in order. |
| `/carry last` | Only carries the last one (related to the default `merged` semantics, see README). |
| `/carry now` | Creates a new independent session `carry-<uuid>`, writes to it, then use `/resume` to select. |
| `/carry off` | Clears the pending carry state without deleting existing session records. |
| `/compactstats` | Shows counts, cumulative recovery, and pending/carried status. |

The summary cache is valid for **30 minutes** by default (configurable via `autoArmWindowMs`); if expired, you must run `/compact` again. The cache is **in-process**: if you restart the TUI without running `/carry` after compaction, you will need to compact again. If there is no summary to carry, `/carry` will error out; it will not perform compaction on your behalf.

## Typical Three-Step Usage

The reproducible flow provided in the README:

/compact # ① Official manual compaction (Get the latest full summary including recent turns)
/new # ② Start a new session —— Native behavior of dsh-tui, plugin does not participate
/carry # ③ In the new session: Write the just-cached summary into this session

The order of ② and ③ can be swapped, but the key is that ③ must be executed in the target session. Use `/carry show` to preview content; use `/carry all` to carry full history; use `/carry off` to change your mind.

## Design Constraints (Useful for usage and troubleshooting)

1.  **Does not subscribe to TUI decision events** (such as `tui/session-switched`). Ordinary plugin subscriptions using raw `ctx.on` are rejected by decision guards, manifesting as "status line updates but nothing written to the new session" — this plugin routes counting, progress, and caching entirely through ordinary `session/event`.
2.  **Never triggers compaction itself**. The TUI treats manual compaction as a transaction that must be settled before switching; if the plugin bypasses this, it races with `/new`, potentially causing input bar unresponsiveness. Offline smoke tests assert `engineCalls.length === 0` to ensure the plugin does not touch the engine.
3.  **Does not participate in `/new` switching**. The optional `autoCarryOnNew` (disabled by default) only listens for `session/created` to write with a delay; manual `/carry` is still recommended by default.

Aligned with the host's **session format V4** (Plugin version **0.6.0**): `/carry` writes use `kind: 'compact-checkpoint'` or `plugin:dsh-tui-compact-carry` to avoid rejection of the V3-era `kind: 'plugin'`; history reading uses `snapshotEvents()` instead of the removed `Session.events`.

# Installation and Activation

Requirements: **Node.js** `^22.19.0 || >=24.0.0`, and `dsh` is in the PATH.

## Method A: Install via Bundle (Recommended)

`package.json` declares `dsh.bundle`. The installation command is:
```bash
dsh plugin --profile dsh-tui add github:sailoflight/dsh-tui-compact-carry

Restart the profile after installation to take effect (manifest/package metadata is not hot-reloaded; only user-specific cordis.patch.yml supports hot-reload).

Method B: Mount via Absolute Path

For zero external dependencies, you can place index.js in a local directory and insert a line with the absolute path in $DSH_HOME/profiles/dsh-tui/cordis.patch.yml (default $DSH_HOME = ~/.dsh). The README provides mkdir, cp, and YAML examples. Choose either Method A or B; mounting the same id repeatedly will result in a duplicate loader entry id error.

The maintainer provides offline smoke tests: node smoke.mock.mjs or npm test (60 assertions, including engine gate, decision event gate, V4 message source gate, and session snapshot gate). It is recommended to run these after upgrading dsh / dsh-tui.

Configuration (Excerpt)

Adjustable via CONFIG at the top of index.js, for example:

Key Default Meaning
carryMode 'merged' 'merged' for the last full summary, 'all' for all in order.
maxCarryChars 0 Max characters for injected body, 0 means no truncation.
showProgress / progressMaxMs true / 900000 Progress display and fallback timeout.
useCheckpointMarker true true uses official compact-checkpoint collapsed line; false uses plugin kind.
autoCarryOnNew Disabled Auto carry with delay after new session creation.

See the GitHub README for the full table.

Use Cases and Notes

Suitable for: People developing agents in dsh-tui long-term, relying on compaction to continue conversations, and needing to bridge the freshly compacted summary to a new session after /new.

Must Know:

  • The plugin runs with the current dsh process permissions; please read the GitHub repository source code and the MIT license before installation to judge whether to include it in your profile.
  • Status line experience is available only in TUI; Web / headless do not have tuiStatus.
  • /carry now creates a new session without attaching the TUI workspace registry (only meta.cwd), but it may still appear in the /resume list for the same cwd; a forged compactionId without a corresponding compaction/summary mainly affects the display layer.
  • The DeepSeek Harness ecosystem emphasizes “Everything is a plugin”; the SkillHub directory page is a community collection and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-tui-compact-carry does not replace official compaction but makes three things visible and operable in the TUI: “how many times compacted”, “compaction in progress”, and “how to carry it to a new session after compaction”: /compact → /new (optional) → /carry. For details, configuration, and limitation tables, please refer to the repository README.

  • Directory Page: https://www.skillhub.cn/plugins/sailoflight/dsh-tui-compact-carry
  • GitHub: https://github.com/sailoflight/dsh-tui-compact-carry
    ```
羽毛球分组比赛记分
小程序二维码

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

Xiaoye