@lexwdex-org/opencode-dcp 3.4.10 → 3.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +54 -253
- package/README.md +67 -246
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +785 -7461
- package/dist/index.js.map +1 -1
- package/dist/lib/auto-prune.d.ts +20 -0
- package/dist/lib/auto-prune.d.ts.map +1 -0
- package/dist/lib/config.d.ts +18 -54
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +29 -28
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/prompts/compaction.d.ts +2 -0
- package/dist/lib/prompts/compaction.d.ts.map +1 -0
- package/dist/lib/prompts/store.d.ts +4 -14
- package/dist/lib/prompts/store.d.ts.map +1 -1
- package/dist/lib/prune-tool.d.ts +15 -0
- package/dist/lib/prune-tool.d.ts.map +1 -0
- package/dist/lib/session-model.d.ts +8 -0
- package/dist/lib/session-model.d.ts.map +1 -0
- package/dist/lib/summarize.d.ts +35 -0
- package/dist/lib/summarize.d.ts.map +1 -0
- package/package.json +2 -3
- package/dist/lib/commands/compression-targets.d.ts +0 -14
- package/dist/lib/commands/compression-targets.d.ts.map +0 -1
- package/dist/lib/commands/context.d.ts +0 -53
- package/dist/lib/commands/context.d.ts.map +0 -1
- package/dist/lib/commands/decompress.d.ts +0 -13
- package/dist/lib/commands/decompress.d.ts.map +0 -1
- package/dist/lib/commands/help.d.ts +0 -18
- package/dist/lib/commands/help.d.ts.map +0 -1
- package/dist/lib/commands/index.d.ts +0 -8
- package/dist/lib/commands/index.d.ts.map +0 -1
- package/dist/lib/commands/manual.d.ts +0 -24
- package/dist/lib/commands/manual.d.ts.map +0 -1
- package/dist/lib/commands/recompress.d.ts +0 -13
- package/dist/lib/commands/recompress.d.ts.map +0 -1
- package/dist/lib/commands/stats.d.ts +0 -16
- package/dist/lib/commands/stats.d.ts.map +0 -1
- package/dist/lib/commands/sweep.d.ts +0 -24
- package/dist/lib/commands/sweep.d.ts.map +0 -1
- package/dist/lib/compress/external-content.d.ts +0 -4
- package/dist/lib/compress/external-content.d.ts.map +0 -1
- package/dist/lib/compress/external-inference.d.ts +0 -15
- package/dist/lib/compress/external-inference.d.ts.map +0 -1
- package/dist/lib/compress/index.d.ts +0 -4
- package/dist/lib/compress/index.d.ts.map +0 -1
- package/dist/lib/compress/message-utils.d.ts +0 -8
- package/dist/lib/compress/message-utils.d.ts.map +0 -1
- package/dist/lib/compress/message.d.ts +0 -4
- package/dist/lib/compress/message.d.ts.map +0 -1
- package/dist/lib/compress/pipeline.d.ts +0 -30
- package/dist/lib/compress/pipeline.d.ts.map +0 -1
- package/dist/lib/compress/protected-content.d.ts +0 -8
- package/dist/lib/compress/protected-content.d.ts.map +0 -1
- package/dist/lib/compress/range-utils.d.ts +0 -10
- package/dist/lib/compress/range-utils.d.ts.map +0 -1
- package/dist/lib/compress/range.d.ts +0 -4
- package/dist/lib/compress/range.d.ts.map +0 -1
- package/dist/lib/compress/search.d.ts +0 -12
- package/dist/lib/compress/search.d.ts.map +0 -1
- package/dist/lib/compress/state.d.ts +0 -9
- package/dist/lib/compress/state.d.ts.map +0 -1
- package/dist/lib/compress/timing.d.ts +0 -20
- package/dist/lib/compress/timing.d.ts.map +0 -1
- package/dist/lib/compress/types.d.ts +0 -95
- package/dist/lib/compress/types.d.ts.map +0 -1
- package/dist/lib/compress-permission.d.ts +0 -6
- package/dist/lib/compress-permission.d.ts.map +0 -1
- package/dist/lib/concurrency.d.ts +0 -2
- package/dist/lib/concurrency.d.ts.map +0 -1
- package/dist/lib/config-env-override.d.ts +0 -3
- package/dist/lib/config-env-override.d.ts.map +0 -1
- package/dist/lib/host-permissions.d.ts +0 -11
- package/dist/lib/host-permissions.d.ts.map +0 -1
- package/dist/lib/message-ids.d.ts +0 -19
- package/dist/lib/message-ids.d.ts.map +0 -1
- package/dist/lib/messages/index.d.ts +0 -9
- package/dist/lib/messages/index.d.ts.map +0 -1
- package/dist/lib/messages/inject/inject.d.ts +0 -8
- package/dist/lib/messages/inject/inject.d.ts.map +0 -1
- package/dist/lib/messages/inject/subagent-results.d.ts +0 -5
- package/dist/lib/messages/inject/subagent-results.d.ts.map +0 -1
- package/dist/lib/messages/inject/utils.d.ts +0 -24
- package/dist/lib/messages/inject/utils.d.ts.map +0 -1
- package/dist/lib/messages/priority.d.ts +0 -13
- package/dist/lib/messages/priority.d.ts.map +0 -1
- package/dist/lib/messages/prune.d.ts +0 -5
- package/dist/lib/messages/prune.d.ts.map +0 -1
- package/dist/lib/messages/query.d.ts +0 -7
- package/dist/lib/messages/query.d.ts.map +0 -1
- package/dist/lib/messages/reasoning-strip.d.ts +0 -8
- package/dist/lib/messages/reasoning-strip.d.ts.map +0 -1
- package/dist/lib/messages/shape.d.ts +0 -5
- package/dist/lib/messages/shape.d.ts.map +0 -1
- package/dist/lib/messages/sync.d.ts +0 -4
- package/dist/lib/messages/sync.d.ts.map +0 -1
- package/dist/lib/messages/utils.d.ts +0 -27
- package/dist/lib/messages/utils.d.ts.map +0 -1
- package/dist/lib/prompts/compress-message.d.ts +0 -2
- package/dist/lib/prompts/compress-message.d.ts.map +0 -1
- package/dist/lib/prompts/compress-range.d.ts +0 -2
- package/dist/lib/prompts/compress-range.d.ts.map +0 -1
- package/dist/lib/prompts/context-limit-nudge.d.ts +0 -2
- package/dist/lib/prompts/context-limit-nudge.d.ts.map +0 -1
- package/dist/lib/prompts/extensions/nudge.d.ts +0 -7
- package/dist/lib/prompts/extensions/nudge.d.ts.map +0 -1
- package/dist/lib/prompts/extensions/system.d.ts +0 -4
- package/dist/lib/prompts/extensions/system.d.ts.map +0 -1
- package/dist/lib/prompts/extensions/tool.d.ts +0 -5
- package/dist/lib/prompts/extensions/tool.d.ts.map +0 -1
- package/dist/lib/prompts/index.d.ts +0 -4
- package/dist/lib/prompts/index.d.ts.map +0 -1
- package/dist/lib/prompts/iteration-nudge.d.ts +0 -2
- package/dist/lib/prompts/iteration-nudge.d.ts.map +0 -1
- package/dist/lib/prompts/system.d.ts +0 -2
- package/dist/lib/prompts/system.d.ts.map +0 -1
- package/dist/lib/prompts/turn-nudge.d.ts +0 -2
- package/dist/lib/prompts/turn-nudge.d.ts.map +0 -1
- package/dist/lib/protected-patterns.d.ts +0 -5
- package/dist/lib/protected-patterns.d.ts.map +0 -1
- package/dist/lib/state/index.d.ts +0 -6
- package/dist/lib/state/index.d.ts.map +0 -1
- package/dist/lib/state/persistence.d.ts +0 -51
- package/dist/lib/state/persistence.d.ts.map +0 -1
- package/dist/lib/state/state.d.ts +0 -10
- package/dist/lib/state/state.d.ts.map +0 -1
- package/dist/lib/state/store.d.ts +0 -38
- package/dist/lib/state/store.d.ts.map +0 -1
- package/dist/lib/state/tool-cache.d.ts +0 -13
- package/dist/lib/state/tool-cache.d.ts.map +0 -1
- package/dist/lib/state/types.d.ts +0 -100
- package/dist/lib/state/types.d.ts.map +0 -1
- package/dist/lib/state/utils.d.ts +0 -25
- package/dist/lib/state/utils.d.ts.map +0 -1
- package/dist/lib/strategies/deduplication.d.ts +0 -10
- package/dist/lib/strategies/deduplication.d.ts.map +0 -1
- package/dist/lib/strategies/index.d.ts +0 -3
- package/dist/lib/strategies/index.d.ts.map +0 -1
- package/dist/lib/strategies/purge-errors.d.ts +0 -13
- package/dist/lib/strategies/purge-errors.d.ts.map +0 -1
- package/dist/lib/subagents/subagent-results.d.ts +0 -5
- package/dist/lib/subagents/subagent-results.d.ts.map +0 -1
- package/dist/lib/token-utils.d.ts +0 -18
- package/dist/lib/token-utils.d.ts.map +0 -1
- package/dist/lib/ui/notification.d.ts +0 -18
- package/dist/lib/ui/notification.d.ts.map +0 -1
- package/dist/lib/ui/utils.d.ts +0 -10
- package/dist/lib/ui/utils.d.ts.map +0 -1
package/README.en.md
CHANGED
|
@@ -1,290 +1,91 @@
|
|
|
1
|
-
# Dynamic Context Pruning
|
|
1
|
+
# Dynamic Context Pruning for OpenCode
|
|
2
2
|
|
|
3
|
-
[](https://ko-fi.com/dansmolsky)
|
|
4
3
|
[](https://www.npmjs.com/package/@lexwdex-org/opencode-dcp)
|
|
5
4
|
|
|
6
|
-
[
|
|
5
|
+
**English** | [中文](./README.md)
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
DCP supplies a semantic-pruning policy and proactive triggers to OpenCode's native compaction lifecycle. It does not own message markers, message IDs, compression blocks, anchors, or placeholders.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
## How it works
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
OpenCode owns one rolling checkpoint. After compaction, the model sees only:
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
opencode plugin @lexwdex-org/opencode-dcp@latest --global
|
|
13
|
+
```text
|
|
14
|
+
latest pruned checkpoint + uncompacted recent tail
|
|
18
15
|
```
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## How It Works
|
|
17
|
+
During `experimental.session.compacting`, DCP asks the summarizer to organize the checkpoint into a fixed three-tier structure:
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
- `## 系统上下文` (System context) — system-level rules such as AGENTS.md, carried forward verbatim from the previous checkpoint;
|
|
20
|
+
- `## 历史概要` (History digest) — early and middle history heavily compressed: one-line outcomes only, no process;
|
|
21
|
+
- Recent tasks — lightly compressed: completed tasks summarized in one line each; in-progress tasks keep full detail (goal, finished steps, file paths, key decisions, blockers, next actions). Details related to the current task are preserved first so work can continue from the checkpoint alone.
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
Unrelated chat, other-project context, tool retries, and repeated edits are folded away as before.
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
## Trigger compaction
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
- **OpenCode automatic compaction** uses the policy automatically.
|
|
28
|
+
- **The `dcp_prune` model tool** — DCP registers an LLM-invokable tool whose description carries heuristic guidance: call it immediately when the topic clearly changes, when a task wraps up, or when the context has grown noticeably.
|
|
29
|
+
- **Heuristic auto-prune** (`autoPrune`) — observes incoming user messages and triggers native compaction at turn boundaries (`session.idle`) on:
|
|
30
|
+
- topic drift: lexical similarity between the newest message and recent history drops sharply (CJK bigrams + Jaccard);
|
|
31
|
+
- message volume since the last prune crossing a threshold;
|
|
32
|
+
- resuming after a long idle gap.
|
|
33
|
+
Auto-triggers respect a cooldown; native `/compact` or host compaction also resets the counters.
|
|
34
|
+
- OpenCode's native `/compact` command uses the same path.
|
|
35
|
+
- `/dcp summarize` calls native `session.summarize()` manually.
|
|
31
36
|
|
|
32
|
-
-
|
|
33
|
-
- `message` mode (experimental) compresses individual raw messages independently, letting the model manage context much more surgically.
|
|
37
|
+
All entries share one coordinator: concurrent requests for the same session share a single native call. A failed call is fail-open and keeps the original context; retries are cooled down for 30 seconds by default.
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
Pruned prefixes stop being sent to the model, but the original session history is not physically deleted from OpenCode's database. A later compaction replaces the previous checkpoint with one merged checkpoint instead of nesting summaries or building a compression-block graph.
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
## Install
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Prunes inputs from errored tool calls after a configurable number of turns (default: 4). Error messages are preserved; only the potentially large input content is removed. Recalculated on compress tool use.
|
|
43
|
+
```bash
|
|
44
|
+
opencode plugin @lexwdex-org/opencode-dcp@latest --global
|
|
45
|
+
```
|
|
44
46
|
|
|
45
47
|
## Configuration
|
|
46
48
|
|
|
47
|
-
DCP
|
|
48
|
-
|
|
49
|
-
1. Global: `~/.config/opencode/dcp.jsonc` (or `dcp.json`), created automatically on first run
|
|
50
|
-
2. Custom config directory: `$OPENCODE_CONFIG_DIR/dcp.jsonc` (or `dcp.json`), if `OPENCODE_CONFIG_DIR` is set
|
|
51
|
-
3. Project: `.opencode/dcp.jsonc` (or `dcp.json`) in your project's `.opencode` directory
|
|
52
|
-
|
|
53
|
-
Each level overrides the previous, so project settings take priority over global. Restart OpenCode after making config changes.
|
|
54
|
-
|
|
55
|
-
> [!NOTE]
|
|
56
|
-
> If you use models with smaller context windows, such as GitHub Copilot models or local models, lower `compress.minContextLimit` and `compress.maxContextLimit` in your configuration to match the available context.
|
|
57
|
-
|
|
58
|
-
> [!IMPORTANT]
|
|
59
|
-
> Defaults are applied automatically. Expand this if you want to review or override settings.
|
|
60
|
-
|
|
61
|
-
<details>
|
|
62
|
-
<summary><strong>Default Configuration</strong> (click to expand)</summary>
|
|
49
|
+
DCP loads global, custom-config-directory, then project configuration:
|
|
63
50
|
|
|
64
51
|
```jsonc
|
|
65
52
|
{
|
|
66
53
|
"$schema": "https://raw.githubusercontent.com/LeXwDeX/opencode-dynamic-context-pruning/master/dcp.schema.json",
|
|
67
|
-
// Enable or disable the plugin
|
|
68
54
|
"enabled": true,
|
|
69
|
-
// Check npm for a newer DCP release and show an update notification.
|
|
70
|
-
// The plugin never deletes or replaces its active installation.
|
|
71
55
|
"autoUpdate": true,
|
|
72
|
-
// Enable debug logging to ~/.config/opencode/logs/dcp/
|
|
73
56
|
"debug": false,
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
"commands": {
|
|
57
|
+
"commands": { "enabled": true },
|
|
58
|
+
"experimental": { "customPrompts": false },
|
|
59
|
+
"summarize": { "failureCooldownMs": 30000 },
|
|
60
|
+
"tool": { "enabled": true },
|
|
61
|
+
"autoPrune": {
|
|
80
62
|
"enabled": true,
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"manualMode": {
|
|
87
|
-
"enabled": false,
|
|
88
|
-
// When true, automatic cleanup (deduplication, purgeErrors)
|
|
89
|
-
// still runs even in manual mode
|
|
90
|
-
"automaticStrategies": true,
|
|
91
|
-
},
|
|
92
|
-
// Protect from pruning for <turns> message turns past tool invocation
|
|
93
|
-
"turnProtection": {
|
|
94
|
-
"enabled": false,
|
|
95
|
-
"turns": 4,
|
|
96
|
-
},
|
|
97
|
-
// Experimental settings
|
|
98
|
-
"experimental": {
|
|
99
|
-
// Allow DCP processing in subagent sessions
|
|
100
|
-
"allowSubAgents": false,
|
|
101
|
-
// Enable user-editable prompt overrides under dcp-prompts directories
|
|
102
|
-
// When false (default), prompt override files/directories are ignored
|
|
103
|
-
"customPrompts": false,
|
|
104
|
-
},
|
|
105
|
-
// Protect file operations from pruning via glob patterns
|
|
106
|
-
// Patterns match tool parameters.filePath (e.g. read/write/edit)
|
|
107
|
-
"protectedFilePatterns": [],
|
|
108
|
-
// Unified context compression tool and behavior settings
|
|
109
|
-
"compress": {
|
|
110
|
-
// Compression mode: "range" (compress spans into block summaries)
|
|
111
|
-
// or experimental "message" (compress individual raw messages)
|
|
112
|
-
"mode": "range",
|
|
113
|
-
// Permission mode: "allow" (no prompt), "ask" (prompt), "deny" (tool not registered)
|
|
114
|
-
"permission": "allow",
|
|
115
|
-
// Show compression content in a chat notification
|
|
116
|
-
"showCompression": false,
|
|
117
|
-
// Let active summary tokens extend the effective maxContextLimit
|
|
118
|
-
"summaryBuffer": true,
|
|
119
|
-
// Soft upper threshold: above this, DCP keeps injecting strong
|
|
120
|
-
// compression nudges (based on nudgeFrequency), so compression is
|
|
121
|
-
// much more likely. Accepts: number or "X%" of model context window.
|
|
122
|
-
"maxContextLimit": "85%",
|
|
123
|
-
// Soft lower threshold for reminder nudges: below this, turn/iteration
|
|
124
|
-
// reminders are off (compression less likely). At/above this, reminders
|
|
125
|
-
// are on. Accepts: number or "X%" of model context window.
|
|
126
|
-
"minContextLimit": "50%",
|
|
127
|
-
// Optional per-model override for maxContextLimit by providerID/modelID.
|
|
128
|
-
// If present, this wins over the global maxContextLimit.
|
|
129
|
-
// Accepts: number or "X%".
|
|
130
|
-
// Example:
|
|
131
|
-
// "modelMaxLimits": {
|
|
132
|
-
// "openai/gpt-5.3-codex": 120000,
|
|
133
|
-
// "anthropic/claude-sonnet-4.6": "80%"
|
|
134
|
-
// },
|
|
135
|
-
// Optional per-model override for minContextLimit.
|
|
136
|
-
// If present, this wins over the global minContextLimit.
|
|
137
|
-
// "modelMinLimits": {
|
|
138
|
-
// "openai/gpt-5.3-codex": 50000,
|
|
139
|
-
// "anthropic/claude-sonnet-4.6": "25%"
|
|
140
|
-
// },
|
|
141
|
-
// How often the context-limit nudge fires (1 = every fetch, 2 = every 2nd)
|
|
142
|
-
"nudgeFrequency": 2,
|
|
143
|
-
// Start adding compression reminders after this many
|
|
144
|
-
// messages have happened since the last user message
|
|
145
|
-
"iterationNudgeThreshold": 15,
|
|
146
|
-
// Controls how likely compression is after user messages
|
|
147
|
-
// ("strong" = more likely, "soft" = less likely)
|
|
148
|
-
"nudgeForce": "strong",
|
|
149
|
-
// Tool names whose completed outputs are appended to the compression
|
|
150
|
-
"protectedTools": [],
|
|
151
|
-
// Preserve text wrapped in <protect>...</protect> when compressed
|
|
152
|
-
"protectTags": false,
|
|
153
|
-
// Preserve your messages during compression.
|
|
154
|
-
// Warning: large copy-pasted prompts will never be compressed away
|
|
155
|
-
"protectUserMessages": false,
|
|
156
|
-
},
|
|
157
|
-
// Automatic pruning strategies
|
|
158
|
-
"strategies": {
|
|
159
|
-
// Remove duplicate tool calls (same tool with same arguments)
|
|
160
|
-
"deduplication": {
|
|
161
|
-
"enabled": true,
|
|
162
|
-
// Additional tools to protect from pruning
|
|
163
|
-
"protectedTools": [],
|
|
164
|
-
},
|
|
165
|
-
// Prune tool inputs for errored tools after X turns
|
|
166
|
-
"purgeErrors": {
|
|
167
|
-
"enabled": true,
|
|
168
|
-
// Number of turns before errored tool inputs are pruned
|
|
169
|
-
"turns": 4,
|
|
170
|
-
// Additional tools to protect from pruning
|
|
171
|
-
"protectedTools": [],
|
|
172
|
-
},
|
|
63
|
+
"minMessages": 8,
|
|
64
|
+
"volumeThreshold": 30,
|
|
65
|
+
"driftThreshold": 0.18,
|
|
66
|
+
"idleGapMs": 1800000,
|
|
67
|
+
"cooldownMs": 300000,
|
|
173
68
|
},
|
|
174
69
|
}
|
|
175
70
|
```
|
|
176
71
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
- `/dcp sweep` — Prunes all tools since the last user message. Accepts an optional count: `/dcp sweep 10` prunes the last 10 tools. Respects `commands.protectedTools`.
|
|
187
|
-
- `/dcp manual [on|off]` — Toggle manual mode or set explicit state. When on, the AI will not autonomously use context management tools.
|
|
188
|
-
- `/dcp compress [focus]` — Trigger a single compress tool execution. Optional focus text directs what content to compress, following the active `compress.mode`.
|
|
189
|
-
- `/dcp decompress <n>` — Restore a specific active compression by ID (for example `/dcp decompress 2`). Running without an argument shows available compression IDs, token sizes, and topics.
|
|
190
|
-
- `/dcp recompress <n>` — Re-apply a user-decompressed compression by ID (for example `/dcp recompress 2`). Running without an argument shows recompressible IDs, token sizes, and topics.
|
|
191
|
-
|
|
192
|
-
### Prompt Overrides
|
|
193
|
-
|
|
194
|
-
DCP exposes six editable prompts:
|
|
195
|
-
|
|
196
|
-
- `system`
|
|
197
|
-
- `compress-range`
|
|
198
|
-
- `compress-message`
|
|
199
|
-
- `context-limit-nudge`
|
|
200
|
-
- `turn-nudge`
|
|
201
|
-
- `iteration-nudge`
|
|
202
|
-
|
|
203
|
-
This feature is disabled by default. Set `experimental.customPrompts` to `true` in your DCP config to activate it.
|
|
204
|
-
|
|
205
|
-
When enabled, managed defaults are written to `~/.config/opencode/dcp-prompts/defaults/` as plain-text prompt files. A single `README.md` in that directory explains each prompt and how to create overrides.
|
|
206
|
-
|
|
207
|
-
To customize behavior, add a file with the same name under an overrides directory and edit it as plain text.
|
|
208
|
-
|
|
209
|
-
To reset an override, delete the matching file from your overrides directory.
|
|
210
|
-
|
|
211
|
-
### Protected Tools
|
|
212
|
-
|
|
213
|
-
By default, these tools are always protected from pruning:
|
|
214
|
-
`task`, `skill`, `todowrite`, `todoread`, `compress`, `batch`, `plan_enter`, `plan_exit`, `write`, `edit`
|
|
215
|
-
|
|
216
|
-
The `protectedTools` arrays in `commands` and `strategies` add to this default list.
|
|
217
|
-
|
|
218
|
-
For the `compress` tool, `compress.protectedTools` ensures specific tool outputs are appended to the compressed summary. By default it includes `task`, `skill`, `todowrite`, and `todoread`.
|
|
219
|
-
|
|
220
|
-
### External Model Compression
|
|
221
|
-
|
|
222
|
-
Offload compression summaries to a cheaper model instead of using the expensive main model.
|
|
223
|
-
|
|
224
|
-
#### Priority Chain
|
|
225
|
-
|
|
226
|
-
| Priority | Source | Description |
|
|
227
|
-
| ------------ | --------------------- | ------------------------------------------------------ |
|
|
228
|
-
| 1 (highest) | Environment variables | `OPENCODE_DCP_EXTERNAL_COMPRESS_*` |
|
|
229
|
-
| 2 | Project config | `<project>/.opencode/dcp.jsonc:compress.externalModel` |
|
|
230
|
-
| 3 | Global config | `~/.config/opencode/dcp.jsonc:compress.externalModel` |
|
|
231
|
-
| 4 (fallback) | Main model | Original behavior unchanged |
|
|
232
|
-
|
|
233
|
-
#### Usage
|
|
234
|
-
|
|
235
|
-
**Method 1 — Environment variables (recommended for quick setup):**
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
export OPENCODE_DCP_EXTERNAL_COMPRESS_URL="http://your-proxy-url/v1"
|
|
239
|
-
export OPENCODE_DCP_EXTERNAL_COMPRESS_MODEL="your-model-name"
|
|
240
|
-
# Optional:
|
|
241
|
-
export OPENCODE_DCP_EXTERNAL_COMPRESS_KEY="your-api-key"
|
|
242
|
-
export OPENCODE_DCP_EXTERNAL_COMPRESS_TIMEOUT="120000"
|
|
243
|
-
export OPENCODE_DCP_EXTERNAL_COMPRESS_RETRIES="1"
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Persist in shell RC (`~/.zshrc`, `~/.bashrc`) for automatic availability across sessions.
|
|
247
|
-
|
|
248
|
-
**Method 2 — Config file (`dcp.jsonc`):**
|
|
249
|
-
|
|
250
|
-
```jsonc
|
|
251
|
-
{
|
|
252
|
-
"compress": {
|
|
253
|
-
"externalModel": {
|
|
254
|
-
"url": "http://your-proxy-url/v1",
|
|
255
|
-
"model": "your-model-name",
|
|
256
|
-
"apiKey": "your-api-key",
|
|
257
|
-
"timeout": 120000,
|
|
258
|
-
"retries": 1,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
#### Behavior
|
|
265
|
-
|
|
266
|
-
| Scenario | Behavior |
|
|
267
|
-
| ---------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
268
|
-
| External model configured + `summary` omitted | Plugin fetches range content → calls external model → stores generated summary |
|
|
269
|
-
| External model configured + `summary` provided | Plugin uses provided `summary` directly (backward compatible) |
|
|
270
|
-
| External model call fails | Tool throws error; main model retries with fallback summary |
|
|
271
|
-
| Not configured | Everything unchanged — main model writes summaries as before |
|
|
272
|
-
| `url` is not OpenAI-compatible | External model call fails → falls to error path above |
|
|
273
|
-
|
|
274
|
-
**Compatibility:** Only OpenAI-compatible `/chat/completions` endpoints are supported (local proxies, OpenAI, DeepSeek, etc.).
|
|
275
|
-
|
|
276
|
-
## Impact on Prompt Caching
|
|
277
|
-
|
|
278
|
-
LLM providers cache prompts based on exact prefix matching. When DCP prunes content, it changes messages, which invalidates cached prefixes from that point forward.
|
|
72
|
+
| Key | Meaning |
|
|
73
|
+
| --------------------------- | --------------------------------------------------------------------------------- |
|
|
74
|
+
| `tool.enabled` | Register the model-invokable `dcp_prune` tool with heuristic usage guidance |
|
|
75
|
+
| `autoPrune.enabled` | Enable plugin-side heuristic auto-compaction |
|
|
76
|
+
| `autoPrune.minMessages` | Minimum user messages before any auto-prune signal is considered |
|
|
77
|
+
| `autoPrune.volumeThreshold` | User messages since the last prune that trigger compaction by volume |
|
|
78
|
+
| `autoPrune.driftThreshold` | Jaccard similarity below which consecutive messages count as a topic change (0–1) |
|
|
79
|
+
| `autoPrune.idleGapMs` | Gap between user messages that counts as resuming after a long break |
|
|
80
|
+
| `autoPrune.cooldownMs` | Minimum interval between two automatic prunes of the same session |
|
|
279
81
|
|
|
280
|
-
|
|
82
|
+
When `experimental.customPrompts` is enabled, copy the generated
|
|
83
|
+
`~/.config/opencode/dcp-prompts/defaults/compaction.md` to a project, custom-config, or global `dcp-prompts/overrides/compaction.md` path.
|
|
281
84
|
|
|
282
|
-
|
|
283
|
-
> In testing, cache hit rates were approximately 85% with DCP vs 90% without.
|
|
85
|
+
## Migrating from the legacy 3.x pipeline
|
|
284
86
|
|
|
285
|
-
|
|
87
|
+
Legacy `compress`, `manualMode`, `strategies`, `turnProtection`, notification, protected-file, and command-protection settings are removed. DCP reports them as deprecated and ignores them.
|
|
286
88
|
|
|
287
|
-
|
|
288
|
-
- **Uniform token pricing** — Providers like Cerebras that bill cached and uncached tokens at the same rate.
|
|
89
|
+
The old model tools, range/message compression, `/dcp compress`, decompression/recompression/sweep commands, message markers, and plugin compression persistence are gone. Existing legacy DCP state files are neither read nor modified; remove them manually only after deciding that you will not roll back.
|
|
289
90
|
|
|
290
|
-
|
|
91
|
+
License: AGPL-3.0-or-later.
|