Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 2.46 KB

README.md

File metadata and controls

35 lines (22 loc) · 2.46 KB

Compaction

Writes a handoff document at every context compaction, so a compacted session resumes from a record of what it was doing instead of from the harness's generic summary. A profile chooses what to preserve: default for any session, orchestration for a session that keeps its state in a task directory, and a compaction profile: <name> line in the conversation overrides the choice. The root README's Handoff Compaction section describes the behaviour in both harnesses; this page covers the wiring.

Hooks

The module has no tools.

  • OpenCode: server.ts registers ctx.session.hook('compaction', ...). The handoff, generated with ctx.generate.text on the session's own model, becomes the stored summary.
  • Claude Code: the installer merges two hooks into ~/.claude/settings.json. PreCompact runs cli.js pre-compact and SessionStart (matcher compact) runs cli.js session-start.

CLI

node dist/modules/compaction/cli.js pre-compact --writer-model <model> --writer-context-tokens <n> [--writer-timeout-seconds <n>]
node dist/modules/compaction/cli.js session-start

pre-compact reads the PreCompact hook's JSON on stdin, asks a headless claude -p writer for the handoff and saves it under ~/.claude/handoffs/<session id>/; it always exits 0. session-start reads the SessionStart hook's JSON and prints the directive that tells the resumed session to read the handoff. scripts/link-claude-code.sh installs both with the writer model, its context window and the timeout from scripts/compaction-policy.sh.

Authentication

None of its own. The Claude Code writer runs claude -p, so it uses Claude Code's login; the OpenCode hook uses the session's own model and provider login.

Configuration

Variable Default Purpose
CLAUDE_CONFIG_DIR ~/.claude Where handoffs/<session id>/ is written
CLAUDE_BIN claude (resolved from PATH) The binary the Claude Code handoff writer runs

Where it runs

  • Claude Code: through the two hooks above. The MCP bridge does not load it: the module has no tools and is not in src/modules/registry.ts.
  • OpenCode: as a hooks-only plugin linked by pnpm run symlink:opencode. No agent permission applies, since it has no tools.