Package Exports
- @tarquinen/opencode-dcp
- @tarquinen/opencode-dcp/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tarquinen/opencode-dcp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Dynamic Context Pruning Plugin
OpenCode plugin that optimizes token usage by analyzing conversation history and pruning obsolete tool outputs from requests.
Features
- Zero Configuration: Uses the free
opencode/big-picklemodel - no API keys required - Automatic Optimization: Runs in the background when sessions become idle
- Smart Analysis: Uses AI to identify truly obsolete context
- Debug Logging: Optional file-based logging for troubleshooting
How It Works
- When a session becomes idle, the Janitor analyzes the conversation using shadow inference
- It identifies tool call outputs that are no longer relevant to the conversation
- These IDs are stored in memory for that session
- On subsequent requests, a custom fetch function filters out the obsolete tool responses
- Result: Fewer tokens sent to the LLM, lower costs, faster responses
Installation
Via NPM (Recommended)
Add the plugin to your OpenCode configuration:
Global: ~/.config/opencode/opencode.json
Project: .opencode/opencode.json
{
"plugin": [
"@tarquinen/opencode-dcp"
]
}Then restart OpenCode. The plugin will automatically:
- Analyze conversations when sessions become idle
- Identify obsolete tool outputs
- Prune them from future requests
- Save you tokens and money!
Local Development
If you want to modify the plugin, you can clone this repository and use a local path:
{
"plugin": [
"./plugin/dynamic-context-pruning"
]
}Configuration
No configuration required! The plugin works out of the box with:
- Zero-config setup using
opencode/big-picklemodel - Automatic background optimization
- Smart AI-powered analysis
Optional: Enable debug logging by creating ~/.config/opencode/dynamic-context-pruning-config.json:
{
"debug": true
}Debug logs will be written to the plugin's logs/ directory.
Architecture
- Janitor: Background process that analyzes sessions using opencode/big-pickle model
- State Manager: In-memory store for pruned tool call IDs per session
- Fetch Injector: Injects custom fetch via
chat.paramshook - Pruning Fetch Wrapper: Filters request bodies based on session state
- Logger: File-based debug logging system
Development Status
Current implementation status: Step 1 - Project Scaffolding ✅
See @notes/dynamic-context-pruning/IMPLEMENTATION-PLAN.md for full implementation details.
License
MIT