rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:wisyh/dsh-session-compaction
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A floating ball for the DeepSeek Harness Web UI that shows how full the current context is, and compacts the conversation early — at a threshold you set — without interrupting a running turn.

Harness already compacts on its own: compaction-basic runs between steps once context pressure reaches thresholdRatio (0.8 by default). That is a safety fence, not a control. By the time it fires, the conversation is already at the edge, and there is no way to see the pressure coming or to decide where the line should be.
This plugin moves that line earlier and makes it visible:
Reading pressure. Occupancy comes from the Harness token meter, not from an estimate:
sessions.binding(sessionId)
.session.projections.faceOf("contextPressure")
.getSnapshot() // { projectedTokens, pressureTokens, contextWindow }
That projection is wire.summary: false, so it is read per session rather than from the session list. The widget subscribes to both the session face and the projection, so every token sample repaints the ball. Occupancy is projectedTokens / contextWindow, clamped to 0–1.
Triggering compaction. No compaction logic is reimplemented. The widget calls the same seam the composer's slash command uses:
ctx.remote.commands.execute(sessionId, "/compact", [])
So the compaction lock, the command/run and command/done journal entries, and the summary itself all belong to @deepseek-ai/dsh-compaction-basic.
Not interrupting a turn. /compact refuses to run while the agent is busy, so the widget never sends it then. Above the threshold with a turn in flight, the trigger is armed — a pulsing dot on the ball — and the command is dispatched on the first render where the session is idle. A "not idle yet" answer right after a turn retries in 8 seconds; a successful compaction holds a 45-second cooldown so a still-high reading cannot chain into repeated model calls.
The package is not published on npm yet; install it from a checkout.
git clone https://github.com/wisyh/dsh-session-compaction.git
Then either use the dsh CLI:
dsh plugin add ./dsh-session-compaction
or the in-app Plugin Manager (install_bundle) pointing at the same directory. The bundle inserts one Loader row, wisyh-session-compaction; the Host half is an intentionally empty apply(), because every behavior lives in the Client half.
After installation, reload the page (Ctrl+Shift+R) so the browser picks up client.js.
Clicking the ball opens a small panel anchored to it — the panel follows while you drag the ball, flips below the ball near the top edge, and scrolls its body instead of overflowing the viewport. Only four blocks, no explanatory copy:
152k / 200k;auto/manual, and the result.Press ×, Esc, or click outside to close.
Stored in localStorage, per browser:
| Key | Value |
|---|---|
dsh-session-compact.settings.v1 |
{ auto: boolean, threshold: number } |
dsh-session-compact.ball.v1 |
{ left, top } |
The 80% ceiling on the slider is deliberate: it is where compaction-basic already compacts, so a higher user threshold could never fire first.
--dsw-alias-* theme tokens only, so light and dark themes follow the host.data-dsh-plugin, data-dsh-surface and data-dsh-part semantic attributes.dsh-plugin.naming.json declares the community coordinate wisyh/session-compaction; it is an advisory declaration, not an official manifest.Communication with the Harness goes through two documented seams only — the contextPressure projection and remote.commands — so a future rename of either surfaces as a visible error in the panel rather than silent breakage.
node test/render-smoke.mjs # 52 behavioral assertions, no dependencies
The test drives the real Client half through a small React runtime written for the purpose (hooks, synchronous re-render, effect commit), so it covers interactions rather than string snapshots: the panel opening, the threshold round-tripping to localStorage, a manual compaction sending exactly one command, the six result texts, a queued trigger firing once at turn end, the cooldown, the anchor flipping, and drag persistence.
| File | Purpose |
|---|---|
package.json |
bundle manifest, dsh.bundle, dsh.client |
cordis.patch.yml |
inserts the Loader row |
index.js |
Host half: empty apply() |
client.js |
the whole Web UI and trigger logic |
locale/*.json |
Plugin Manager title and description |
icon.svg |
plugin artwork |
test/render-smoke.mjs |
behavioral test suite |
docs/preview.png |
the screenshot above |
MIT © W.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。