Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Using `@latest` ensures you always get the newest version automatically when Ope

Restart OpenCode. The plugin will automatically start optimizing your sessions.

> **Important:** DCP is designed for the TUI (terminal) version of OpenCode. It auto-disables on Desktop/Web clients (see [Known Issues](#known-issues)).

## How Pruning Works

DCP uses multiple tools and strategies to reduce context size:
Expand Down Expand Up @@ -147,6 +149,25 @@ When enabled, turn protection prevents tool outputs from being pruned for a conf

### Protected Tools

## Known Issues

### Desktop / Web App Incompatibility

DCP is currently incompatible with OpenCode's desktop and web clients. This is a known issue tracked in [Issue #304](https://github.com/Opencode-DCP/opencode-dynamic-context-pruning/issues/304).

**Symptoms on Desktop/Web:**

- `/dcp` commands fail with `TypeError: {} is not iterable`
- `discard` and `extract` tools fail with the same error
- Pruning notifications don't display correctly

**Solution:**

- DCP automatically detects when running on Desktop (Electron-based clients) and **auto-disables itself** with a console message
- Use the TUI version of OpenCode for full DCP functionality

**Status:** The plugin is designed for TUI usage only. Desktop/Web clients have breaking changes in their `@opencode-ai/plugin` implementation that haven't been addressed yet.

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

Expand Down
11 changes: 11 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ import {
createSystemPromptHandler,
} from "./lib/hooks"

function isDesktop(): boolean {
return process.env.ELECTRON_RUN_AS_NODE !== undefined
}

const plugin: Plugin = (async (ctx) => {
const config = getConfig(ctx)

if (!config.enabled) {
return {}
}

if (isDesktop()) {
console.log(
"DCP: Auto-disabled on Desktop – use the TUI version for full DCP functionality",
)
return {}
}

const logger = new Logger(config.debug)
const state = createSessionState()

Expand Down