dsh-session-fold

Folds older oversized tool results into spill files and replaces them with short, deterministic stubs at step boundaries, with no LLM call: the stub keeps the first 200 and last 80 characters plus the sequence number, tool name, line/char/size counts and the original file path, and each fold is a real surface replacement accompanied by compaction/prune shadow pricing so token counts stay honest. Triggers on context pressure at 25% of the model window (falling back to 32768 tokens when the window cannot be resolved) or on five accumulated candidates; the last three turns, error results and rich content are never folded. The original is recovered from the session log rather than the spill file, so /folds, /unfold <seq> and /unfold all keep working after spill cleanup; session_fold_recall lets the model fetch a folded result by sequence number or by keyword, and session_fold_diagnose reports the effective settings. /spill-prune removes orphaned spill directories, preview only unless --apply. A Settings page exposes 12 of the 13 options as draft-then-save fields; they are volatile, so saved changes apply without restarting the plugin.

Overview

Folds older oversized tool results into spill files and replaces them with short, deterministic stubs at step boundaries, with no LLM call: the stub keeps the first 200 and last 80 characters plus the sequence number, tool name, line/char/size counts and the original file path, and each fold is a real surface replacement accompanied by compaction/prune shadow pricing so token counts stay honest. Triggers on context pressure at 25% of the model window (falling back to 32768 tokens when the window cannot be resolved) or on five accumulated candidates; the last three turns, error results and rich content are never folded. The original is recovered from the session log rather than the spill file, so /folds, /unfold <seq> and /unfold all keep working after spill cleanup; session_fold_recall lets the model fetch a folded result by sequence number or by keyword, and session_fold_diagnose reports the effective settings. /spill-prune removes orphaned spill directories, preview only unless --apply. A Settings page exposes 12 of the 13 options as draft-then-save fields; they are volatile, so saved changes apply without restarting the plugin.

Installation

Install from GitHub

dsh plugin --profile web add github:kennethfan/dsh-session-fold

Installing from GitHub runs the project's build script, which pnpm blocks until you allowlist it — run the command once and pnpm prints the exact key to add under `allowBuilds` in ~/.dsh/profiles/web/pnpm-workspace.yaml.

Version compatibility

Compatibility is unconfirmed. Check the project documentation for supported versions.