diff --git a/README.md b/README.md index 1d0d99e..113c8ff 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,10 @@ Add to your OpenCode config: ```jsonc // opencode.jsonc { - "plugin": ["@tarquinen/opencode-dcp@latest"], - "experimental": { - "primary_tools": ["prune"] - } + "plugin": ["@tarquinen/opencode-dcp@latest"] } ``` -The `experimental.primary_tools` setting ensures the `prune` tool is only available to the primary agent (not subagents). - Using `@latest` ensures you always get the newest version automatically when OpenCode starts. Restart OpenCode. The plugin will automatically start optimizing your sessions. diff --git a/index.ts b/index.ts index 1328d3c..0677d42 100644 --- a/index.ts +++ b/index.ts @@ -75,6 +75,18 @@ const plugin: Plugin = (async (ctx) => { } return { + config: async (opencodeConfig) => { + // Add prune to primary_tools by mutating the opencode config + // This works because config is cached and passed by reference + if (config.strategies.onTool.length > 0) { + const existingPrimaryTools = opencodeConfig.experimental?.primary_tools ?? [] + opencodeConfig.experimental = { + ...opencodeConfig.experimental, + primary_tools: [...existingPrimaryTools, "prune"], + } + logger.info("plugin", "Added 'prune' to experimental.primary_tools via config mutation") + } + }, event: createEventHandler(ctx.client, janitorCtx, logger, config, toolTracker), "chat.params": createChatParamsHandler(ctx.client, state, logger, toolTracker), tool: config.strategies.onTool.length > 0 ? { diff --git a/lib/pruning-tool.ts b/lib/pruning-tool.ts index 9c1ff13..d88baea 100644 --- a/lib/pruning-tool.ts +++ b/lib/pruning-tool.ts @@ -4,7 +4,7 @@ import type { PluginConfig } from "./config" import type { ToolTracker } from "./fetch-wrapper/tool-tracker" import type { ToolMetadata, PruneReason } from "./fetch-wrapper/types" import { resetToolTrackerCount } from "./fetch-wrapper/tool-tracker" -import { isSubagentSession, findCurrentAgent } from "./hooks" +import { findCurrentAgent } from "./hooks" import { getActualId } from "./state/id-mapping" import { sendUnifiedNotification, type NotificationContext } from "./ui/notification" import { formatPruningResultForTool } from "./ui/display-utils" @@ -51,10 +51,6 @@ export function createPruningTool( const { client, state, logger, config, notificationCtx } = ctx const sessionId = toolCtx.sessionID - if (await isSubagentSession(client, sessionId)) { - return "Pruning is unavailable in subagent sessions. Do not call this tool again. Continue with your current task - if you were in the middle of work, proceed with your next step. If you had just finished, provide your final summary/findings to return to the main agent." - } - if (!args.ids || args.ids.length === 0) { return "No IDs provided. Check the list for available IDs to prune." } diff --git a/package-lock.json b/package-lock.json index 32e3914..b96f03c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "zod": "^4.1.13" }, "devDependencies": { - "@opencode-ai/plugin": ">=0.13.7", + "@opencode-ai/plugin": "^1.0.143", "@types/node": "^24.10.1", "tsx": "^4.21.0", "typescript": "^5.9.3" @@ -1251,12 +1251,12 @@ "license": "MIT" }, "node_modules/@opencode-ai/plugin": { - "version": "1.0.128", - "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.0.128.tgz", - "integrity": "sha512-M5vjz3I6KeoBSNduWmT5iHXRtTLCqICM5ocs+WrB3uxVorslcO3HVwcLzrERh/ntpxJ/1xhnHQaeG6Mg+P744A==", + "version": "1.0.143", + "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.0.143.tgz", + "integrity": "sha512-yzaCmdazVJMDADJLbMM8KGp1X+Hd/HVyIXMlNt9qcvz/fcs/ET4EwHJsJaQi/9m/jLJ+plwBJAeIW08BMrECPg==", "dev": true, "dependencies": { - "@opencode-ai/sdk": "1.0.128", + "@opencode-ai/sdk": "1.0.143", "zod": "4.1.8" } }, @@ -1271,9 +1271,9 @@ } }, "node_modules/@opencode-ai/sdk": { - "version": "1.0.128", - "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.0.128.tgz", - "integrity": "sha512-Kow3Ivg8bR8dNRp8C0LwF9e8+woIrwFgw3ZALycwCfqS/UujDkJiBeYHdr1l/07GSHP9sZPmvJ6POuvfZ923EA==" + "version": "1.0.143", + "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.0.143.tgz", + "integrity": "sha512-dtmkBfJ7IIAHzL6KCzAlwc9GybfJONVeCsF6ePYySpkuhslDbRkZBJYb5vqGd1H5zdsgjc6JjuvmOf0rPWUL6A==" }, "node_modules/@opentelemetry/api": { "version": "1.9.0", diff --git a/package.json b/package.json index c3c9bd8..43673c2 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "zod": "^4.1.13" }, "devDependencies": { - "@opencode-ai/plugin": ">=0.13.7", + "@opencode-ai/plugin": "^1.0.143", "@types/node": "^24.10.1", "tsx": "^4.21.0", "typescript": "^5.9.3"