dshbase

插件目录 / Developer / dsh-compact-and-branch

dsh-compact-and-branch

未验证 zeropointnine

✓ 持续维护 基于 8 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

0Stars
0Forks
0未关闭 issue
语言
2026-08-23最近推送
跨平台平台

功能简介

Compact a session and continue the work in a new one

我们的评价
未验证 — 尚未实测

Compact a session and continue the work in a new one 尚未验证——请自行安装测试。

「未验证」表示我们的自动化 CI 尚未安装过该插件。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

你是插件作者? 想拿到「已验证」标签——提交你自己的验证证据(截图、日志或短视频),我们审核通过后即改为「已验证」。

提交验证证据 ↗

README

dsh-compact-and-branch: /compact-and-branch

A focused out-of-tree DeepSeek Harness plugin for treating canonical context
compaction as a clean session branch point.

Motivation

Long-running coding-agent sessions can accumulate a great deal of useful
working context before reaching a natural phase boundary. DSH's /compact
command is useful for reducing that history while preserving the state needed
to continue, but sometimes it is preferable to make that compaction a clean
branch point: continue from the resulting state in a fresh session while
leaving the compacted source session independently resumable.

This is especially useful with relatively limited context windows, as is common
with local LLMs, where long agent trajectories can otherwise require repeated
compactions and make session boundaries more consequential.

/compact-and-branch is intended to have essentially the same model-facing
effect as running /compact and continuing normally in the original session,
except that the continuation occurs in a new root session. It deliberately
reuses DSH's canonical compaction result rather than introducing a separate
handoff summary or another lossy transformation of the session state.

What it does

/compact-and-branch:

  1. Preflights the source session's workspace, active preset, and current model
    selection.
  2. Calls the same operation as built-in /compact:
    ctx.compaction.compactNow(invocation.agent, invocation.signal, invocation.commandId).
  3. Only after that succeeds, snapshots source.session.deriveMessages(). This is
    the canonical checkpoint message plus the complete retained recent tail;
    the plugin never reads or rewrites CompactionResult.summary.
  4. Creates a new root session through the supported Host session.create API,
    with the source workspace, active preset, provider/model/reasoning effort,
    and no parentSession fork lineage.
  5. Adds one minimal preamble followed by exact copies of every canonical
    post-compaction message, preserving message content, ordering, roles,
    identities, provenance, and tool pairs. It then advances the new agent's idle
    turn cursor past the imported turn so the first live response receives a
    distinct turn/step identity, and assigns a pinned handoff title.
  6. Flushes the target, then publishes a typed session projection. The browser
    half waits for the target to appear in sessions.list, refreshes the list to
    replace its provisional blank-session row with the persisted populated
    summary, and calls the supported ctx.sessions.open(targetId) API.
  7. In the fresh session's chat presentation, hides the synthetic imported
    turn's checkpoint and retained recent-tail rows, leaving its native,
    selectable DSH notice row: “Compacted context imported from previous
    session.” The notice keeps the project's standard context typography, color,
    disclosure behavior, and accessibility; durable model-facing messages remain
    unchanged.

Built-in /compact is not registered, shadowed, or modified.

Install

dsh plugin is a thin pnpm forwarder: it runs pnpm inside your profile
directory and then reconciles the profile's dsh.profile.bundles stack for
you, so no hand-editing of any config file is needed. Install the plugin
from GitHub:

dsh plugin --profile web add git+https://github.com/zeropointnine/dsh-compact-and-branch

# or pin a release tag
dsh plugin --profile web add github:zeropointnine/dsh-compact-and-branch#v0.2.0

A first dsh plugin run in a profile initializes it automatically. The
profile's package.json gains the dependency, and DSH appends
dsh-compact-and-branch to dsh.profile.bundles on its own (it detects the
package's dsh.bundle declaration). This package has no build or install
scripts, so git-hosted installs need no allowBuilds entry in the profile's
pnpm-workspace.yaml.

After adding, restarting, updating, or removing the plugin, restart DSH. To
remove it later: dsh plugin --profile web remove dsh-compact-and-branch.

Compatibility

The peer ranges (^0.1.1-rc.2 for the @deepseek-ai/dsh-* packages) reflect
the DSH release line this plugin was written against. It relies on DSH's
canonical compaction, session, projection, and Host API surfaces of that line;
check the peer ranges when DSH ships a new major/minor release.

Usage

In any session, type:

/compact-and-branch

No arguments. The current session is compacted through DSH's canonical
/compact machinery, then a fresh root session is created in the same
workspace and preset with the same model selection, carrying the compacted
context; DSH opens it in the browser. The compacted source session stays
independently resumable. In the fresh session, the imported history is
collapsed behind a native DSH notice row, leaving only live conversation
visible.

Development

pnpm install   # installs the @deepseek-ai/* peer copies and zod
pnpm test      # node --test

The tests load host-side classes (Session, ManualCompactionError, message
creators) from a separate module instance than the plugin's own imports, to
exercise the cross-package error-classification boundary. They resolve that
instance from the DSH_HOME environment variable (point it at a DSH
checkout's node_modules/@deepseek-ai directory, or the checkout root) and
fall back to the package's own pnpm-installed peer copies; if neither is
available, those tests skip with a hint instead of failing.

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-compact-and-branch」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:zeropointnine/dsh-compact-and-branch

Headless(CLI)profile:

dsh plugin --profile headless add github:zeropointnine/dsh-compact-and-branch

实测报告

尚未 L3 验证——若已跑过,见下方失败备注。

状态:pending · 最近测试 2026-08-27 · 标记 webonly
备注:验证: web-only;待 L4 web CDP;L4 web CDP runtime-fail on dsh 0.1.0-rc.8. 浏览全部待验证失败 →
安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7795 个插件 →