Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
df06fa8
Add turn-based tool protection (protectedTurns config)
Tarquinen Dec 18, 2025
ed2d32d
Add stricter validation for prune tool IDs
Tarquinen Dec 18, 2025
c317f38
Add prune cooldown to prevent immediate re-pruning
Tarquinen Dec 19, 2025
5419c04
Clarify prunable-tools list behavior in prompts
Tarquinen Dec 19, 2025
520370c
Refactor protectedTurns to turnProtection with enabled/turns options
Tarquinen Dec 19, 2025
f4ae605
Update turn protection comments for clarity
Tarquinen Dec 19, 2025
3d926eb
Merge pull request #167 from Opencode-DCP/feat/turn-based-tool-protec…
Tarquinen Dec 19, 2025
421eb5f
update pruning guidance to encourage consolidation and discourage fre…
Tarquinen Dec 19, 2025
6532e3f
Merge pull request #172 from Opencode-DCP/feature/consolidated-pruning
Tarquinen Dec 19, 2025
ac67023
Refactor prompt loading and rename pruning prompt files
Tarquinen Dec 19, 2025
c728879
Merge pull request #173 from Opencode-DCP/refactor/consolidate-prompts
Tarquinen Dec 19, 2025
f3d7e1c
feat: implement hidden distillation in prune tool
Tarquinen Dec 19, 2025
138f795
refactor: use metadata object for prune tool reason and distillation
Tarquinen Dec 19, 2025
fa111c9
Merge pull request #174 from Opencode-DCP/feature/hidden-distillation
Tarquinen Dec 19, 2025
e2cf9c9
Update prune distillation guidelines for high fidelity
Tarquinen Dec 19, 2025
60dffe3
Merge pull request #176 from Opencode-DCP/feat/high-fidelity-pruning
Tarquinen Dec 19, 2025
0e3a28d
Update config and state management for discard and extract tools
Tarquinen Dec 20, 2025
ef0f25d
Register discard/extract tools and update system prompts
Tarquinen Dec 20, 2025
c351d20
Update documentation and remove obsolete prune-tool-spec
Tarquinen Dec 20, 2025
46c623a
feat: dynamically load system and nudge prompts based on enabled tools
Tarquinen Dec 20, 2025
bd96bdf
cleanup
Tarquinen Dec 20, 2025
36ed1ef
refactor: rename prune-tool.ts to tools.ts to better reflect its cont…
Tarquinen Dec 20, 2025
7a91b9b
refactor: consolidate and clarify tool prompts for standalone use
Tarquinen Dec 20, 2025
571ba30
refactor: add task completion scenario to extract-tool-spec for parit…
Tarquinen Dec 20, 2025
95cf48c
fix: improve extract prompts with correct wording and format section
Tarquinen Dec 21, 2025
e34a9da
fix: make cooldown message dynamic based on enabled tools
Tarquinen Dec 21, 2025
a3eb386
docs: clarify discardTool and extractTool comments
Tarquinen Dec 21, 2025
5cbc483
fix: only register enabled prune tools
Tarquinen Dec 21, 2025
de76de1
feat: add showDistillation option to display extracted findings as no…
Tarquinen Dec 21, 2025
55926d9
Merge pull request #178 from Opencode-DCP/feat/split-prune-into-disca…
Tarquinen Dec 21, 2025
1b6ce7e
v1.1.0-beta.1 - Bump version
Tarquinen Dec 21, 2025
ca93ad0
Merge pull request #179 from Opencode-DCP/release/v1.1.0-beta.1
Tarquinen Dec 21, 2025
f51109e
refactor: restructure config schema to consolidate tool settings
Tarquinen Dec 21, 2025
0643888
refactor: update all consumers to use new config paths
Tarquinen Dec 21, 2025
7136d20
docs: update README with new config schema
Tarquinen Dec 21, 2025
fecca94
Merge pull request #181 from Opencode-DCP/refactor/config-restructuring
Tarquinen Dec 22, 2025
a36c650
fix: correctly prune edit tool inputs (oldString/newString instead of…
Tarquinen Dec 22, 2025
7a9b519
Merge pull request #182 from Opencode-DCP/fix/edit-tool-pruning
Tarquinen Dec 22, 2025
28fb22c
chore: add prettier for code formatting
Tarquinen Dec 22, 2025
f399b79
style: apply prettier formatting to codebase
Tarquinen Dec 22, 2025
8201162
Merge pull request #183 from Opencode-DCP/prettier
Tarquinen Dec 22, 2025
953d8eb
feat: add debug context logging for session messages
Tarquinen Dec 22, 2025
481aef9
chore: add SCHEMA_NOTES.md to gitignore
Tarquinen Dec 22, 2025
114a6c0
Merge pull request #184 from Opencode-DCP/feat/debug-context-logging
Tarquinen Dec 22, 2025
8b5cac0
v1.1.0-beta.2 - Bump version
Tarquinen Dec 22, 2025
936a1b5
Merge pull request #186 from Opencode-DCP/release/v1.1.0-beta.2
Tarquinen Dec 22, 2025
16b86c7
refactor: use assistant role for prunable-tools injection
Tarquinen Dec 23, 2025
2886029
feat: add reasoning model support for synthetic message injection
Tarquinen Dec 23, 2025
2c80d03
fix: update injected prompts to use first-person language for assista…
Tarquinen Dec 23, 2025
74257ab
fix: update tool specs and injected prompts for assistant-role injection
Tarquinen Dec 23, 2025
fa47430
fix: preserve agent context in synthetic user messages and remove obs…
Tarquinen Dec 23, 2025
1960877
cleanup
Tarquinen Dec 23, 2025
8f8a5c6
Merge pull request #187 from Opencode-DCP/feat/assistant-role-injection
Tarquinen Dec 23, 2025
16b4d72
v1.1.0-beta.3 - Bump version
Tarquinen Dec 23, 2025
276ad40
Merge pull request #188 from Opencode-DCP/release/v1.1.0-beta.3
Tarquinen Dec 23, 2025
92bff5e
Simplify extract distillation to array format
Tarquinen Dec 23, 2025
8228514
Merge pull request #193 from Opencode-DCP/refactor/simplify-extract-d…
Tarquinen Dec 23, 2025
a8bec37
v1.1.1-beta.1 - Bump version
Tarquinen Dec 23, 2025
39db021
Merge pull request #194 from Opencode-DCP/release/v1.1.1-beta.1
Tarquinen Dec 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
name: PR Checks

on:
pull_request:
branches: [master, dev]
pull_request:
branches: [master, dev]

jobs:
validate:
name: Type Check, Build & Audit
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Type check
run: npm run typecheck

- name: Build
run: npm run build

- name: Security audit
run: npm audit --audit-level=high
continue-on-error: false
validate:
name: Type Check, Build & Audit
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Format check
run: npm run format:check

- name: Type check
run: npm run typecheck

- name: Build
run: npm run build

- name: Security audit
run: npm audit --audit-level=high
continue-on-error: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Thumbs.db
tests/
notes/
test-update.ts

# Documentation (local development only)
docs/
SCHEMA_NOTES.md
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": false,
"singleQuote": false,
"tabWidth": 4,
"useTabs": false,
"trailingComma": "all",
"printWidth": 100,
"bracketSpacing": true,
"arrowParens": "always"
}
111 changes: 68 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Add to your OpenCode config:
```jsonc
// opencode.jsonc
{
"plugin": ["@tarquinen/opencode-dcp@latest"]
"plugin": ["@tarquinen/opencode-dcp@latest"],
}
```

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

**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.

**Prune Tool** — Exposes a `prune` tool that the AI can call to manually trigger pruning when it determines context cleanup is needed.
**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.

**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.

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

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

```jsonc
{
// Enable or disable the plugin
"enabled": true,
// Enable debug logging to ~/.config/opencode/logs/dcp/
"debug": false,
// Summary display: "off", "minimal", or "detailed"
"pruningSummary": "detailed",
// Strategies for pruning tokens from chat history
"strategies": {
// Remove duplicate tool calls (same tool with same arguments)
"deduplication": {
"enabled": true,
// Additional tools to protect from pruning
"protectedTools": []
// Enable or disable the plugin
"enabled": true,
// Enable debug logging to ~/.config/opencode/logs/dcp/
"debug": false,
// Notification display: "off", "minimal", or "detailed"
"pruneNotification": "detailed",
// Protect from pruning for <turns> message turns
"turnProtection": {
"enabled": false,
"turns": 4,
},
// Prune write tool inputs when the file has been subsequently read
"supersedeWrites": {
"enabled": true
// LLM-driven context pruning tools
"tools": {
// Shared settings for all prune tools
"settings": {
// Nudge the LLM to use prune tools (every <nudgeFrequency> tool results)
"nudgeEnabled": true,
"nudgeFrequency": 10,
// Additional tools to protect from pruning
"protectedTools": [],
},
// Removes tool content from context without preservation (for completed tasks or noise)
"discard": {
"enabled": true,
},
// Distills key findings into preserved knowledge before removing raw content
"extract": {
"enabled": true,
// Show distillation content as an ignored message notification
"showDistillation": false,
},
},
// Exposes a prune tool to your LLM to call when it determines pruning is necessary
"pruneTool": {
"enabled": true,
// Additional tools to protect from pruning
"protectedTools": [],
// Nudge the LLM to use the prune tool (every <frequency> tool results)
"nudge": {
"enabled": true,
"frequency": 10
}
// Automatic pruning strategies
"strategies": {
// Remove duplicate tool calls (same tool with same arguments)
"deduplication": {
"enabled": true,
// Additional tools to protect from pruning
"protectedTools": [],
},
// Prune write tool inputs when the file has been subsequently read
"supersedeWrites": {
"enabled": true,
},
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
"onIdle": {
"enabled": false,
// Additional tools to protect from pruning
"protectedTools": [],
// Override model for analysis (format: "provider/model")
// "model": "anthropic/claude-haiku-4-5",
// Show toast notifications when model selection fails
"showModelErrorToasts": true,
// When true, fallback models are not permitted
"strictModelSelection": false,
},
},
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
"onIdle": {
"enabled": false,
// Additional tools to protect from pruning
"protectedTools": [],
// Override model for analysis (format: "provider/model")
// "model": "anthropic/claude-haiku-4-5",
// Show toast notifications when model selection fails
"showModelErrorToasts": true,
// When true, fallback models are not permitted
"strictModelSelection": false
}
}
}
```

</details>

### Turn Protection

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.

### Protected Tools

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

The `protectedTools` arrays in each section add to this default list:

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

### Config Precedence

Expand Down
Loading