Skip to content

Commit 628bd40

Browse files
committed
docs: sweep CLAUDE.md, README, roadmap, guide for /compact
CLAUDE.md tree gains agent/compaction.rs, slash/compact.rs, chat/blocks/compacted.rs and notes Entry::Compact alongside the other JSONL variants. README slash-command list and the user-guide table both gain /compact. The roadmap moves the manual half of context compression from Current Focus to Working Today and renames the deferred half to "Auto-Compaction" with the threshold-math notes.
1 parent 441fdb9 commit 628bd40

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ox # Start an interactive session
2525
.
2626
├── agent.rs # Agent turn loop, stream accumulation, tool dispatch
2727
├── agent/
28+
│ ├── compaction.rs # /compact driver: stripped-transcript summarization request + summary-prefix wrapping
2829
│ └── event.rs # AgentEvent, UserAction, AgentSink trait, StdioSink
2930
├── client.rs # Client module root
3031
├── client/
@@ -55,7 +56,7 @@ ox # Start an interactive session
5556
│ ├── actor.rs # Session actor task body + SessionCmd protocol + receive-and-drain batching loop
5657
│ ├── chain.rs # ChainBuilder: UUID-DAG message-chain reconstruction (fork-aware tip pick + parent walk)
5758
│ ├── display.rs # Shared session-listing formatters (relative time, `id · when · N msgs · branch · project` line)
58-
│ ├── entry.rs # JSONL entry types (Header, Message, Title, Summary) and metadata structs
59+
│ ├── entry.rs # JSONL entry types (Header, Message, Title, Summary, Compact, ToolResultMetadata, FileSnapshot) and metadata structs
5960
│ ├── handle.rs # SessionHandle (cheap-to-clone async API), SharedState, start / resume / roll lifecycle
6061
│ ├── handle/
6162
│ │ └── testing.rs # Cfg-test SessionHandle constructors for sibling test modules (dead, acks_then_drops)
@@ -71,6 +72,7 @@ ox # Start an interactive session
7172
├── slash.rs # Slash-command surface root: re-exports + dispatch
7273
├── slash/
7374
│ ├── clear.rs # /clear (new, reset) — forwards UserAction::Clear, resets ChatView, drops the AI title
75+
│ ├── compact.rs # /compact [<instructions>] — forwards UserAction::Compact; agent loop drives the summarization
7476
│ ├── config.rs # /config — opens a KvOverview modal of resolved config + layered file paths
7577
│ ├── confirm.rs # ConfirmDeleteSessionModal — destructive-action gate; runs the unlink synchronously on Y, sticky inline error on failure
7678
│ ├── context.rs # SlashContext (borrowed ChatView + LiveSessionInfo + modal slot) handed to each command's execute
@@ -107,6 +109,7 @@ ox # Start an interactive session
107109
│ │ │ ├── blocks.rs # ChatBlock trait + RenderCtx + icon-prefix helpers
108110
│ │ │ └── blocks/
109111
│ │ │ ├── assistant.rs # AssistantText + AssistantThinking
112+
│ │ │ ├── compacted.rs # CompactedBlock — bordered surface; bold accent header (count + optional focus) + markdown summary body
110113
│ │ │ ├── error.rs # ErrorBlock
111114
│ │ │ ├── git_diff.rs # GitDiffBlock — unified-diff render reusing the Edit-tool `+` / `-` row-bg + line-number gutter
112115
│ │ │ ├── interrupted.rs # InterruptedMarker — dim italic `(interrupted)` line on cancel

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Early development. What works today:
2020
- Agent loop with extended thinking and tool-use round-trip
2121
- File and search tools: `read`, `write`, `edit`, `glob`, `grep`, `bash`
2222
- Turn interruption (Esc / Ctrl+C) plus mid-turn queued follow-up prompts that splice into the same turn between tool calls, with double-press Ctrl+C exit confirmation
23-
- Slash commands with `/`-triggered autocomplete (name and curated-arg modes): `/clear`, `/config`, `/delete`, `/diff`, `/effort`, `/help`, `/init`, `/model`, `/rename`, `/resume`, `/status`, `/theme`
23+
- Slash commands with `/`-triggered autocomplete (name and curated-arg modes): `/clear`, `/compact`, `/config`, `/delete`, `/diff`, `/effort`, `/help`, `/init`, `/model`, `/rename`, `/resume`, `/status`, `/theme`
2424
- `CLAUDE.md` / `AGENTS.md` instruction-file discovery
2525
- Session persistence with JSONL conversation logs, listing, and resume
2626
- Per-session file-change tracking with a Read-before-Edit gate and on-disk drift detection

docs/guide/slash-commands.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ For commands with curated arguments (`/model`, `/effort`, `/theme`), the popup s
99
| Command | Description |
1010
| ------------------------------------------- | ------------------------------------------------------------------------------------ |
1111
| `/clear` (aliases `/new`, `/reset`) | Start a fresh session. The previous one stays resumable via `ox -c`. |
12+
| `/compact [<instructions>]` | Compress the conversation into a summary; trailing text steers the focus. |
1213
| `/config` | Open the resolved configuration and its layered file paths in a read-only modal. |
1314
| `/delete <id-prefix>` | Delete a saved session by id prefix, with a Y/N confirm modal before the unlink. |
1415
| `/diff` | Show `git diff HEAD` plus untracked files in chat, capped at 64 KB. |
@@ -27,14 +28,24 @@ Double the leading slash. Typing `//etc` sends the literal `/etc`.
2728

2829
## Mid-Turn Behavior
2930

30-
State-mutating commands (`/clear`, `/delete`, `/init`, and the typed-arg forms of `/effort`, `/model`, `/rename`, `/resume`, `/theme`) wait for the current turn to finish. Read-only commands and the bare modal-opening forms run anytime.
31+
State-mutating commands (`/clear`, `/compact`, `/delete`, `/init`, and the typed-arg forms of `/effort`, `/model`, `/rename`, `/resume`, `/theme`) wait for the current turn to finish. Read-only commands and the bare modal-opening forms run anytime.
3132

3233
## Model and Effort
3334

3435
Bare `/model` and `/effort` open pickers; both apply on Enter, cancel on Esc.
3536

3637
`/model <id>` accepts aliases (`opus`, `sonnet`, `haiku` — append `[1m]` for the 1M-context variants), full ids, or any unique suffix or substring. Haiku has no effort tier, so `/effort` on Haiku errors with a recovery hint. See [Configuration](configuration.md) for tier defaults.
3738

39+
## Compaction
40+
41+
`/compact` streams a one-shot summarization request through the live model, then replaces the in-memory transcript with a single boundary block: a header (`Compacted N messages → 1 summary`) plus the rendered summary. The next prompt continues from the summary rather than the full prior chat.
42+
43+
`/compact <instructions>` appends free-text focus instructions to the rubric (e.g., `/compact focus on the build error and how we fixed it`). Useful when only a slice of the work matters going forward.
44+
45+
The summary lands in the JSONL as a `compact` boundary entry plus a synthetic continuation message. Resuming the session via `ox -c` shows only the post-compact tail; the pre-compact transcript stays on disk for archival but is not replayed in chat. The file-change tracker resets on compact, so any `Edit` after a `/compact` requires a fresh `Read`. Queued prompts survive the compaction.
46+
47+
`/compact` refuses on sessions with fewer than 4 messages, when the model returns an empty summary, or while a turn is in flight (it waits for the current reply to finish first).
48+
3849
## Sessions
3950

4051
`/rename` opens a modal pre-filled with the current title; `/rename <title>` sets it directly. The chosen title sticks and replaces the auto-generated AI title for the rest of the session.

docs/roadmap.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ The direction is simple:
6363

6464
### Slash Commands
6565

66-
- Built-in: `/clear` (aliases `/new`, `/reset`), `/config`, `/delete`, `/diff`, `/effort`, `/help`, `/init`, `/model`, `/rename`, `/resume` (alias `/continue`), `/status`, `/theme`. See the [user guide](guide/slash-commands.md).
66+
- Built-in: `/clear` (aliases `/new`, `/reset`), `/compact`, `/config`, `/delete`, `/diff`, `/effort`, `/help`, `/init`, `/model`, `/rename`, `/resume` (alias `/continue`), `/status`, `/theme`. See the [user guide](guide/slash-commands.md).
6767
- Autocomplete popup on typing `/`, with ranked filter, Tab completion, and arg-mode completion for commands with curated rosters (`/model`, `/effort`, `/theme`).
6868
- Mid-session swaps (`/model`, `/effort`, `/rename`, `/resume`, `/theme`) are session-only, and no slash command writes user config files.
6969
- Destructive ops (`/delete <id-prefix>`, or Ctrl+D / Delete inside the `/resume` picker) gate behind a Y/N confirm modal. Only finalized sessions can be deleted.
7070
- Modal UI primitive: focus-grabbing overlays above the input for picker, slider, editor, and read-only kv-overview forms; nested modals layer cleanly. Esc / Ctrl+C cancels any modal.
7171

72+
### Context Compression
73+
74+
- Manual `/compact [instructions]` streams a one-shot summarization through the live model and replaces the in-memory transcript with a synthetic continuation. Optional trailing instructions steer the focus.
75+
- Persisted as a dedicated `compact` JSONL boundary plus the synthetic post-compact message; resume sees only the post-compact tail.
76+
- File tracker resets on compact — Edits after `/compact` require a fresh Read.
77+
7278
### Authentication & Configuration
7379

7480
- Anthropic API key via `ANTHROPIC_API_KEY` or config file.
@@ -83,15 +89,15 @@ The direction is simple:
8389
- Project-level allowlists to auto-approve trusted commands.
8490
- Plan mode: read-only review of the agent's proposed changes before any tool runs.
8591

86-
### Context Compression
92+
### Auto-Compaction
8793

88-
- Summarize older messages when approaching the context limit so long sessions keep responding.
94+
- Fire `/compact` automatically when the running token usage approaches the model's context window. Threshold math (effective context window minus reserved-output buffer), per-turn check at sampling boundaries, single-turn circuit breaker, and a config knob for opt-out.
8995

9096
### Slash Commands (continuation)
9197

9298
Remaining surface beyond Working Today:
9399

94-
- Deferred: `/compact`, `/cost`, `/login` / `/logout`, custom user commands, `/init` multi-phase flow.
100+
- Deferred: `/cost`, `/login` / `/logout`, custom user commands, `/init` multi-phase flow.
95101

96102
Persistence stance: `/model`, `/effort`, and `/theme` mutate session state only, and restart returns to user-declared config. Cross-session persistence will land as an **explicit subcommand** writing to a user-opted-in path, never as a silent merge into a `~/.claude.json`-style mega-file.
97103

0 commit comments

Comments
 (0)