Skip to content

Commit 896a669

Browse files
authored
Merge pull request #180 from Opencode-DCP/dev
v1.1.1-beta.1 - Split prune into discard/extract, assistant-role injection, config restructure
2 parents b39ef03 + 39db021 commit 896a669

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4174
-5356
lines changed

.github/workflows/pr-checks.yml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
name: PR Checks
22

33
on:
4-
pull_request:
5-
branches: [master, dev]
4+
pull_request:
5+
branches: [master, dev]
66

77
jobs:
8-
validate:
9-
name: Type Check, Build & Audit
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v4
15-
16-
- name: Setup Node.js
17-
uses: actions/setup-node@v4
18-
with:
19-
node-version: '20'
20-
cache: 'npm'
21-
22-
- name: Install dependencies
23-
run: npm ci
24-
25-
- name: Type check
26-
run: npm run typecheck
27-
28-
- name: Build
29-
run: npm run build
30-
31-
- name: Security audit
32-
run: npm audit --audit-level=high
33-
continue-on-error: false
8+
validate:
9+
name: Type Check, Build & Audit
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "20"
20+
cache: "npm"
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Format check
26+
run: npm run format:check
27+
28+
- name: Type check
29+
run: npm run typecheck
30+
31+
- name: Build
32+
run: npm run build
33+
34+
- name: Security audit
35+
run: npm audit --audit-level=high
36+
continue-on-error: false

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ Thumbs.db
3232
tests/
3333
notes/
3434
test-update.ts
35+
36+
# Documentation (local development only)
37+
docs/
38+
SCHEMA_NOTES.md

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": false,
3+
"singleQuote": false,
4+
"tabWidth": 4,
5+
"useTabs": false,
6+
"trailingComma": "all",
7+
"printWidth": 100,
8+
"bracketSpacing": true,
9+
"arrowParens": "always"
10+
}

README.md

Lines changed: 68 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Add to your OpenCode config:
1313
```jsonc
1414
// opencode.jsonc
1515
{
16-
"plugin": ["@tarquinen/opencode-dcp@latest"]
16+
"plugin": ["@tarquinen/opencode-dcp@latest"],
1717
}
1818
```
1919

@@ -29,7 +29,9 @@ DCP uses multiple strategies to reduce context size:
2929

3030
**Supersede Writes** — Prunes write tool inputs for files that have subsequently been read. When a file is written and later read, the original write content becomes redundant since the current file state is captured in the read result. Runs automatically on every request with zero LLM cost.
3131

32-
**Prune Tool** — Exposes a `prune` tool that the AI can call to manually trigger pruning when it determines context cleanup is needed.
32+
**Discard Tool** — Exposes a `discard` tool that the AI can call to remove completed or noisy tool outputs from context. Use this for task completion cleanup and removing irrelevant outputs.
33+
34+
**Extract Tool** — Exposes an `extract` tool that the AI can call to distill valuable context into concise summaries before removing the raw outputs. Use this when you need to preserve key findings while reducing context size.
3335

3436
**On Idle Analysis** — Uses a language model to semantically analyze conversation context during idle periods and identify tool outputs that are no longer relevant.
3537

@@ -54,59 +56,82 @@ DCP uses its own config file:
5456

5557
```jsonc
5658
{
57-
// Enable or disable the plugin
58-
"enabled": true,
59-
// Enable debug logging to ~/.config/opencode/logs/dcp/
60-
"debug": false,
61-
// Summary display: "off", "minimal", or "detailed"
62-
"pruningSummary": "detailed",
63-
// Strategies for pruning tokens from chat history
64-
"strategies": {
65-
// Remove duplicate tool calls (same tool with same arguments)
66-
"deduplication": {
67-
"enabled": true,
68-
// Additional tools to protect from pruning
69-
"protectedTools": []
59+
// Enable or disable the plugin
60+
"enabled": true,
61+
// Enable debug logging to ~/.config/opencode/logs/dcp/
62+
"debug": false,
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,
7069
},
71-
// Prune write tool inputs when the file has been subsequently read
72-
"supersedeWrites": {
73-
"enabled": true
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+
},
7490
},
75-
// Exposes a prune tool to your LLM to call when it determines pruning is necessary
76-
"pruneTool": {
77-
"enabled": true,
78-
// Additional tools to protect from pruning
79-
"protectedTools": [],
80-
// Nudge the LLM to use the prune tool (every <frequency> tool results)
81-
"nudge": {
82-
"enabled": true,
83-
"frequency": 10
84-
}
91+
// Automatic pruning strategies
92+
"strategies": {
93+
// Remove duplicate tool calls (same tool with same arguments)
94+
"deduplication": {
95+
"enabled": true,
96+
// Additional tools to protect from pruning
97+
"protectedTools": [],
98+
},
99+
// Prune write tool inputs when the file has been subsequently read
100+
"supersedeWrites": {
101+
"enabled": true,
102+
},
103+
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
104+
"onIdle": {
105+
"enabled": false,
106+
// Additional tools to protect from pruning
107+
"protectedTools": [],
108+
// Override model for analysis (format: "provider/model")
109+
// "model": "anthropic/claude-haiku-4-5",
110+
// Show toast notifications when model selection fails
111+
"showModelErrorToasts": true,
112+
// When true, fallback models are not permitted
113+
"strictModelSelection": false,
114+
},
85115
},
86-
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
87-
"onIdle": {
88-
"enabled": false,
89-
// Additional tools to protect from pruning
90-
"protectedTools": [],
91-
// Override model for analysis (format: "provider/model")
92-
// "model": "anthropic/claude-haiku-4-5",
93-
// Show toast notifications when model selection fails
94-
"showModelErrorToasts": true,
95-
// When true, fallback models are not permitted
96-
"strictModelSelection": false
97-
}
98-
}
99116
}
100117
```
101118

102119
</details>
103120

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+
104125
### Protected Tools
105126

106127
By default, these tools are always protected from pruning across all strategies:
107-
`task`, `todowrite`, `todoread`, `prune`, `batch`
128+
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`
129+
130+
The `protectedTools` arrays in each section add to this default list:
108131

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

111136
### Config Precedence
112137

0 commit comments

Comments
 (0)