Skip to content

Commit 7730dc4

Browse files
committed
readme
1 parent b47fec3 commit 7730dc4

File tree

1 file changed

+55
-28
lines changed

1 file changed

+55
-28
lines changed

README.md

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ Restart OpenCode. The plugin will automatically start optimizing your sessions.
2323

2424
## How Pruning Works
2525

26-
DCP uses two complementary techniques:
26+
DCP uses multiple strategies to reduce context size:
2727

28-
**Automatic Deduplication**Silently identifies repeated tool calls (e.g., reading the same file multiple times) and keeps only the most recent output. Runs on every request with zero LLM cost.
28+
**Deduplication**Identifies repeated tool calls (e.g., reading the same file multiple times) and keeps only the most recent output. Runs automatically on every request with zero LLM cost.
2929

30-
**AI Analysis**Uses a language model to semantically analyze conversation context and identify tool outputs that are no longer relevant to the current task.
30+
**Prune Thinking Blocks**Removes LLM thinking/reasoning blocks from the conversation history.
3131

32-
## Context Pruning Tool
32+
**On Idle Analysis** — Uses a language model to semantically analyze conversation context during idle periods and identify tool outputs that are no longer relevant.
3333

34-
When `strategies.onTool` is enabled, DCP exposes a `prune` tool to Opencode that the AI can call to trigger pruning on demand.
35-
36-
Adjust `nudgeFreq` to control how aggressively the AI is prompted to prune — lower values trigger reminders sooner and more often.
34+
**Prune Tool** — Exposes a `prune` tool that the AI can call to manually trigger pruning when it determines context cleanup is needed.
3735

3836
## How It Works
3937

@@ -49,35 +47,64 @@ LLM providers like Anthropic and OpenAI cache prompts based on exact prefix matc
4947

5048
DCP uses its own config file (`~/.config/opencode/dcp.jsonc` or `.opencode/dcp.jsonc`), created automatically on first run.
5149

52-
### Options
53-
54-
| Option | Default | Description |
55-
|--------|---------|-------------|
56-
| `enabled` | `true` | Enable/disable the plugin |
57-
| `debug` | `false` | Log to `~/.config/opencode/logs/dcp/` |
58-
| `model` | (session) | Model for analysis (e.g., `"anthropic/claude-haiku-4-5"`) |
59-
| `showModelErrorToasts` | `true` | Show notifications on model fallback |
60-
| `showUpdateToasts` | `true` | Show notifications when a new version is available |
61-
| `strictModelSelection` | `false` | Only run AI analysis with session or configured model (disables fallback models) |
62-
| `pruningSummary` | `"detailed"` | `"off"`, `"minimal"`, or `"detailed"` |
63-
| `nudgeFreq` | `10` | How often to remind AI to prune (lower = more frequent) |
64-
| `protectedTools` | `["task", "todowrite", "todoread", "prune", "batch", "write", "edit"]` | Tools that are never pruned |
65-
| `strategies.onIdle` | `["ai-analysis"]` | Strategies for automatic pruning |
66-
| `strategies.onTool` | `["ai-analysis"]` | Strategies when AI calls `prune` |
67-
68-
**Strategies:** `"ai-analysis"` uses LLM to identify prunable outputs. Empty array disables that trigger. Deduplication runs automatically on every request.
50+
<details>
51+
<summary><strong>Default Configuration</strong> (click to expand)</summary>
6952

7053
```jsonc
7154
{
55+
// Enable or disable the plugin
7256
"enabled": true,
57+
// Enable debug logging to ~/.config/opencode/logs/dcp/
58+
"debug": false,
59+
// Show toast notifications when a new version is available
60+
"showUpdateToasts": true,
61+
// Summary display: "off", "minimal", or "detailed"
62+
"pruningSummary": "detailed",
63+
// Strategies for pruning tokens from chat history
7364
"strategies": {
74-
"onIdle": ["ai-analysis"],
75-
"onTool": ["ai-analysis"]
76-
},
77-
"protectedTools": ["task", "todowrite", "todoread", "prune", "batch", "write", "edit"]
65+
// Remove duplicate tool calls (same tool with same arguments)
66+
"deduplication": {
67+
"enabled": true,
68+
// Additional tools to protect from pruning
69+
"protectedTools": []
70+
},
71+
// Remove thinking/reasoning LLM blocks
72+
"pruneThinkingBlocks": {
73+
"enabled": true
74+
},
75+
// Run an LLM to analyze what tool calls are no longer relevant on idle
76+
"onIdle": {
77+
"enabled": true,
78+
// Override model for analysis (format: "provider/model")
79+
// "model": "anthropic/claude-haiku-4-5",
80+
// Show toast notifications when model selection fails
81+
"showModelErrorToasts": true,
82+
// When true, fallback models are not permitted
83+
"strictModelSelection": false,
84+
// Additional tools to protect from pruning
85+
"protectedTools": []
86+
},
87+
// Exposes a prune tool to your LLM to call when it determines pruning is necessary
88+
"pruneTool": {
89+
"enabled": false,
90+
// Additional tools to protect from pruning
91+
"protectedTools": [],
92+
// How often to nudge the AI to prune (every N tool results, 0 = disabled)
93+
"nudgeFrequency": 10
94+
}
95+
}
7896
}
7997
```
8098

99+
</details>
100+
101+
### Protected Tools
102+
103+
By default, these tools are always protected from pruning across all strategies:
104+
`task`, `todowrite`, `todoread`, `prune`, `batch`, `write`, `edit`
105+
106+
The `protectedTools` arrays in each strategy add to this default list.
107+
81108
### Config Precedence
82109

83110
Settings are merged in order: **Defaults****Global** (`~/.config/opencode/dcp.jsonc`) → **Project** (`.opencode/dcp.jsonc`). Each level overrides the previous, so project settings take priority over global, which takes priority over defaults.

0 commit comments

Comments
 (0)