From 7e89cc7ebca43ac49e0906a8987a6a64d233b1ee Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Tue, 9 Dec 2025 02:01:22 -0500 Subject: [PATCH 1/2] Add showUpdateToasts and autoUpdate config options Previously, update notifications were always shown and auto-update was always attempted. This change gives users control over both behaviors: - showUpdateToasts (default: true) - Control whether update toasts appear - autoUpdate (default: false) - Opt-in to automatic config version updates With autoUpdate disabled (the new default), users are simply notified of available updates without any config modifications. This is less intrusive and gives users explicit control over when their config changes. --- index.ts | 5 ++++- lib/config.ts | 14 ++++++++++++ lib/version-checker.ts | 48 +++++++++++++++++++++++++++--------------- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/index.ts b/index.ts index b8d8083d..b7713e53 100644 --- a/index.ts +++ b/index.ts @@ -53,7 +53,10 @@ const plugin: Plugin = (async (ctx) => { // Check for updates after a delay setTimeout(() => { - checkForUpdates(ctx.client, logger).catch(() => { }) + checkForUpdates(ctx.client, logger, { + showToast: config.showUpdateToasts ?? true, + autoUpdate: config.autoUpdate ?? false + }).catch(() => { }) }, 5000) // Show migration toast if there were config migrations diff --git a/lib/config.ts b/lib/config.ts index 73e70605..02084d52 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -13,6 +13,8 @@ export interface PluginConfig { protectedTools: string[] model?: string showModelErrorToasts?: boolean + showUpdateToasts?: boolean + autoUpdate?: boolean strictModelSelection?: boolean pruning_summary: "off" | "minimal" | "detailed" nudge_freq: number @@ -32,6 +34,8 @@ const defaultConfig: PluginConfig = { debug: false, protectedTools: ['task', 'todowrite', 'todoread', 'prune', 'batch', 'edit', 'write'], showModelErrorToasts: true, + showUpdateToasts: true, + autoUpdate: false, strictModelSelection: false, pruning_summary: 'detailed', nudge_freq: 10, @@ -47,6 +51,8 @@ const VALID_CONFIG_KEYS = new Set([ 'protectedTools', 'model', 'showModelErrorToasts', + 'showUpdateToasts', + 'autoUpdate', 'strictModelSelection', 'pruning_summary', 'nudge_freq', @@ -110,6 +116,10 @@ function createDefaultConfig(): void { // "model": "anthropic/claude-haiku-4-5", // Show toast notifications when model selection fails "showModelErrorToasts": true, + // Show toast notifications when a new version is available + "showUpdateToasts": true, + // Automatically update to new versions (restart required to apply) + "autoUpdate": false, // Only run AI analysis with session model or configured model (disables fallback models) "strictModelSelection": false, // AI analysis strategies (deduplication runs automatically on every request) @@ -199,6 +209,8 @@ export function getConfig(ctx?: PluginInput): ConfigResult { protectedTools: [...new Set([...config.protectedTools, ...(globalConfig.protectedTools ?? [])])], model: globalConfig.model ?? config.model, showModelErrorToasts: globalConfig.showModelErrorToasts ?? config.showModelErrorToasts, + showUpdateToasts: globalConfig.showUpdateToasts ?? config.showUpdateToasts, + autoUpdate: globalConfig.autoUpdate ?? config.autoUpdate, strictModelSelection: globalConfig.strictModelSelection ?? config.strictModelSelection, strategies: mergeStrategies(config.strategies, globalConfig.strategies as any), pruning_summary: globalConfig.pruning_summary ?? config.pruning_summary, @@ -230,6 +242,8 @@ export function getConfig(ctx?: PluginInput): ConfigResult { protectedTools: [...new Set([...config.protectedTools, ...(projectConfig.protectedTools ?? [])])], model: projectConfig.model ?? config.model, showModelErrorToasts: projectConfig.showModelErrorToasts ?? config.showModelErrorToasts, + showUpdateToasts: projectConfig.showUpdateToasts ?? config.showUpdateToasts, + autoUpdate: projectConfig.autoUpdate ?? config.autoUpdate, strictModelSelection: projectConfig.strictModelSelection ?? config.strictModelSelection, strategies: mergeStrategies(config.strategies, projectConfig.strategies as any), pruning_summary: projectConfig.pruning_summary ?? config.pruning_summary, diff --git a/lib/version-checker.ts b/lib/version-checker.ts index 191a85cc..7e2bf718 100644 --- a/lib/version-checker.ts +++ b/lib/version-checker.ts @@ -109,8 +109,11 @@ export function updateConfigVersion(newVersion: string, logger?: { info: (compon export async function checkForUpdates( client: any, - logger?: { info: (component: string, message: string, data?: any) => void } + logger?: { info: (component: string, message: string, data?: any) => void }, + options: { showToast?: boolean; autoUpdate?: boolean } = {} ): Promise { + const { showToast = true, autoUpdate = false } = options + try { const local = getLocalVersion() const npm = await getNpmVersion() @@ -125,22 +128,33 @@ export async function checkForUpdates( return } - logger?.info("version", "Update available", { local, npm }) - - // Update any configs found - const updated = updateConfigVersion(npm, logger) - - if (updated) { - await client.tui.showToast({ - body: { - title: "DCP: Update available", - message: `v${local} → v${npm}\nRestart OpenCode to apply`, - variant: "info", - duration: 6000 - } - }) - } else { - // Config update failed or plugin not found in config, show manual instructions + logger?.info("version", "Update available", { local, npm, autoUpdate }) + + if (autoUpdate) { + // Attempt config update + const updated = updateConfigVersion(npm, logger) + + if (updated && showToast) { + await client.tui.showToast({ + body: { + title: "DCP: Updated!", + message: `v${local} → v${npm}\nRestart OpenCode to apply`, + variant: "success", + duration: 6000 + } + }) + } else if (!updated && showToast) { + // Config update failed or plugin not found in config, show manual instructions + await client.tui.showToast({ + body: { + title: "DCP: Update available", + message: `v${local} → v${npm}\nUpdate opencode.jsonc:\n"${PACKAGE_NAME}@${npm}"`, + variant: "info", + duration: 8000 + } + }) + } + } else if (showToast) { await client.tui.showToast({ body: { title: "DCP: Update available", From 785f1a34c2d0e073218a52abeaf3b2991e8aa6e9 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Tue, 9 Dec 2025 02:01:41 -0500 Subject: [PATCH 2/2] v0.4.10 - Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 218e35d0..bea7dfb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tarquinen/opencode-dcp", - "version": "0.4.9", + "version": "0.4.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tarquinen/opencode-dcp", - "version": "0.4.9", + "version": "0.4.10", "license": "MIT", "dependencies": { "@ai-sdk/openai-compatible": "^1.0.28", diff --git a/package.json b/package.json index 709930f1..02cb8ce3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@tarquinen/opencode-dcp", - "version": "0.4.9", + "version": "0.4.10", "type": "module", "description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context", "main": "./dist/index.js",