You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-31Lines changed: 61 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,19 +23,15 @@ Restart OpenCode. The plugin will automatically start optimizing your sessions.
23
23
24
24
## How Pruning Works
25
25
26
-
DCP uses two complementary techniques:
26
+
DCP uses multiple strategies to reduce context size:
27
27
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.
29
29
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
+
**On Idle Analysis** — Uses a language model to semantically analyze conversation context during idle periods and identify tool outputs that are no longer relevant.
31
31
32
-
## Context Pruning Tool
32
+
**Prune Tool** — Exposes a `prune` tool that the AI can call to manually trigger pruning when it determines context cleanup is needed.
33
33
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 `nudge_freq` to control how aggressively the AI is prompted to prune — lower values trigger reminders sooner and more often.
37
-
38
-
## How It Works
34
+
*More strategies coming soon.*
39
35
40
36
Your session history is never modified. DCP replaces pruned outputs with a placeholder before sending requests to your LLM.
41
37
@@ -47,40 +43,74 @@ LLM providers like Anthropic and OpenAI cache prompts based on exact prefix matc
47
43
48
44
## Configuration
49
45
50
-
DCP uses its own config file (`~/.config/opencode/dcp.jsonc` or `.opencode/dcp.jsonc`), created automatically on first run.
46
+
DCP uses its own config file:
51
47
52
-
### Options
48
+
- Global: `~/.config/opencode/dcp.jsonc` (or `dcp.json`), created automatically on first run
49
+
- Custom config directory: `$OPENCODE_CONFIG_DIR/dcp.jsonc` (or `dcp.json`), if `OPENCODE_CONFIG_DIR` is set
50
+
- Project: `.opencode/dcp.jsonc` (or `dcp.json`) in your project’s `.opencode` directory
53
51
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
-
|`pruning_summary`|`"detailed"`|`"off"`, `"minimal"`, or `"detailed"`|
63
-
|`nudge_freq`|`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.
52
+
<details>
53
+
<summary><strong>Default Configuration</strong> (click to expand)</summary>
69
54
70
55
```jsonc
71
56
{
57
+
// Enable or disable the plugin
72
58
"enabled":true,
59
+
// Enable debug logging to ~/.config/opencode/logs/dcp/
60
+
"debug":false,
61
+
// Show toast notifications when a new version is available
62
+
"showUpdateToasts":true,
63
+
// Summary display: "off", "minimal", or "detailed"
64
+
"pruningSummary":"detailed",
65
+
// Strategies for pruning tokens from chat history
The `protectedTools` arrays in each strategy add to this default list.
108
+
81
109
### Config Precedence
82
110
83
-
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.
111
+
Settings are merged in order:
112
+
Defaults → Global (`~/.config/opencode/dcp.jsonc`) → Config Dir (`$OPENCODE_CONFIG_DIR/dcp.jsonc`) → Project (`.opencode/dcp.jsonc`).
113
+
Each level overrides the previous, so project settings take priority over config-dir and global, which take priority over defaults.
0 commit comments