Skip to content

Commit fecca94

Browse files
authored
Merge pull request #181 from Opencode-DCP/refactor/config-restructuring
Refactor config schema to consolidate tool settings
2 parents ca93ad0 + 7136d20 commit fecca94

File tree

7 files changed

+229
-291
lines changed

7 files changed

+229
-291
lines changed

README.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,35 @@ DCP uses its own config file:
6060
"enabled": true,
6161
// Enable debug logging to ~/.config/opencode/logs/dcp/
6262
"debug": false,
63-
// Summary display: "off", "minimal", or "detailed"
64-
"pruningSummary": "detailed",
65-
// Strategies for pruning tokens from chat history
63+
// Notification display: "off", "minimal", or "detailed"
64+
"pruneNotification": "detailed",
65+
// Protect from pruning for <turns> message turns
66+
"turnProtection": {
67+
"enabled": false,
68+
"turns": 4
69+
},
70+
// LLM-driven context pruning tools
71+
"tools": {
72+
// Shared settings for all prune tools
73+
"settings": {
74+
// Nudge the LLM to use prune tools (every <nudgeFrequency> tool results)
75+
"nudgeEnabled": true,
76+
"nudgeFrequency": 10,
77+
// Additional tools to protect from pruning
78+
"protectedTools": []
79+
},
80+
// Removes tool content from context without preservation (for completed tasks or noise)
81+
"discard": {
82+
"enabled": true
83+
},
84+
// Distills key findings into preserved knowledge before removing raw content
85+
"extract": {
86+
"enabled": true,
87+
// Show distillation content as an ignored message notification
88+
"showDistillation": false
89+
}
90+
},
91+
// Automatic pruning strategies
6692
"strategies": {
6793
// Remove duplicate tool calls (same tool with same arguments)
6894
"deduplication": {
@@ -74,40 +100,6 @@ DCP uses its own config file:
74100
"supersedeWrites": {
75101
"enabled": true
76102
},
77-
// Removes tool content from context without preservation (for completed tasks or noise)
78-
"discardTool": {
79-
"enabled": true,
80-
// Additional tools to protect from pruning
81-
"protectedTools": [],
82-
// Protect from pruning for <turn protection> message turns
83-
"turnProtection": {
84-
"enabled": false,
85-
"turns": 4
86-
},
87-
// Nudge the LLM to use the discard tool (every <frequency> tool results)
88-
"nudge": {
89-
"enabled": true,
90-
"frequency": 10
91-
}
92-
},
93-
// Distills key findings into preserved knowledge before removing raw content
94-
"extractTool": {
95-
"enabled": true,
96-
// Additional tools to protect from pruning
97-
"protectedTools": [],
98-
// Protect from pruning for <turn protection> message turns
99-
"turnProtection": {
100-
"enabled": false,
101-
"turns": 4
102-
},
103-
// Nudge the LLM to use the extract tool (every <frequency> tool results)
104-
"nudge": {
105-
"enabled": true,
106-
"frequency": 10
107-
},
108-
// Show distillation content as an ignored message notification
109-
"showDistillation": false
110-
},
111103
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
112104
"onIdle": {
113105
"enabled": false,
@@ -126,12 +118,19 @@ DCP uses its own config file:
126118

127119
</details>
128120

121+
### Turn Protection
122+
123+
When enabled, turn protection prevents tool outputs from being pruned for a configurable number of message turns. This gives the AI time to reference recent tool outputs before they become prunable. Applies to both `discard` and `extract` tools, as well as automatic strategies.
124+
129125
### Protected Tools
130126

131127
By default, these tools are always protected from pruning across all strategies:
132128
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`
133129

134-
The `protectedTools` arrays in each strategy add to this default list.
130+
The `protectedTools` arrays in each section add to this default list:
131+
- `tools.settings.protectedTools` — Protects tools from the `discard` and `extract` tools
132+
- `strategies.deduplication.protectedTools` — Protects tools from deduplication
133+
- `strategies.onIdle.protectedTools` — Protects tools from on-idle analysis
135134

136135
### Config Precedence
137136

index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const plugin: Plugin = (async (ctx) => {
2727

2828
return {
2929
"experimental.chat.system.transform": async (_input: unknown, output: { system: string[] }) => {
30-
const discardEnabled = config.strategies.discardTool.enabled
31-
const extractEnabled = config.strategies.extractTool.enabled
30+
const discardEnabled = config.tools.discard.enabled
31+
const extractEnabled = config.tools.extract.enabled
3232

3333
let promptName: string
3434
if (discardEnabled && extractEnabled) {
@@ -51,7 +51,7 @@ const plugin: Plugin = (async (ctx) => {
5151
config
5252
),
5353
tool: {
54-
...(config.strategies.discardTool.enabled && {
54+
...(config.tools.discard.enabled && {
5555
discard: createDiscardTool({
5656
client: ctx.client,
5757
state,
@@ -60,7 +60,7 @@ const plugin: Plugin = (async (ctx) => {
6060
workingDirectory: ctx.directory
6161
}),
6262
}),
63-
...(config.strategies.extractTool.enabled && {
63+
...(config.tools.extract.enabled && {
6464
extract: createExtractTool({
6565
client: ctx.client,
6666
state,
@@ -74,8 +74,8 @@ const plugin: Plugin = (async (ctx) => {
7474
// Add enabled tools to primary_tools by mutating the opencode config
7575
// This works because config is cached and passed by reference
7676
const toolsToAdd: string[] = []
77-
if (config.strategies.discardTool.enabled) toolsToAdd.push("discard")
78-
if (config.strategies.extractTool.enabled) toolsToAdd.push("extract")
77+
if (config.tools.discard.enabled) toolsToAdd.push("discard")
78+
if (config.tools.extract.enabled) toolsToAdd.push("extract")
7979

8080
if (toolsToAdd.length > 0) {
8181
const existingPrimaryTools = opencodeConfig.experimental?.primary_tools ?? []

0 commit comments

Comments
 (0)