From f70d91ecd2daf098c5b6f899756c7fd4706c69cd Mon Sep 17 00:00:00 2001 From: svtter Date: Fri, 22 May 2026 12:13:10 +0800 Subject: [PATCH 1/3] feat: use noReply to skip LLM for /review:auto toggle command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the LLM-dependent toggle flow with a direct command.execute.before hook that parses arguments, toggles state, and returns the result instantly. Before: user types /review:auto off → LLM parses args → LLM calls tool → state changed After: user types /review:auto off → hook parses args → state changed → result shown Requires opencode noReply support (anomalyco/opencode#28792). Closes #5 Co-Authored-By: Claude Opus 4.7 --- src/index.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 87d2a15..96f4118 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,7 +81,8 @@ const opencodeReview: Plugin = async ({ project, client, $, directory, worktree description: config.language === "zh" ? "切换自动审查开关(on/off)" : "Toggle auto-review on/off", - template: buildTogglePrompt(config), + template: "Toggle auto-review", + noReply: true, } }, @@ -93,6 +94,34 @@ const opencodeReview: Plugin = async ({ project, client, $, directory, worktree ), }, + "command.execute.before": async (input, output) => { + if (input.command !== "review:auto") return + + const args = (input.arguments ?? "").trim().toLowerCase() + const isZh = config.language === "zh" + + if (args.includes("on")) { + autoEnabled = true + output.parts = [{ + type: "text" as const, + text: isZh ? "✅ 自动审查已开启" : "✅ Auto-review is now ON", + }] + } else if (args.includes("off")) { + autoEnabled = false + output.parts = [{ + type: "text" as const, + text: isZh ? "✅ 自动审查已关闭" : "✅ Auto-review is now OFF", + }] + } else { + output.parts = [{ + type: "text" as const, + text: isZh + ? `自动审查当前状态:${autoEnabled ? "开启" : "关闭"}\n用法:/review:auto on 或 /review:auto off` + : `Auto-review is currently ${autoEnabled ? "ON" : "OFF"}\nUsage: /review:auto on or /review:auto off`, + }] + } + }, + event: async ({ event }) => { if (event.type === "session.idle" && autoEnabled) { const now = Date.now() From 56bbc26efea73a6c17a182aa38103e5ab796df47 Mon Sep 17 00:00:00 2001 From: svtter Date: Fri, 22 May 2026 20:44:53 +0800 Subject: [PATCH 2/3] fix: exact match on/off args to avoid false positives `args.includes("on")` would match "song", "done", etc. Changed to exact match (`===`) or prefix with space (`startsWith("on ")`). Co-Authored-By: Claude Opus 4.7 --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 96f4118..fd1a146 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,13 +100,13 @@ const opencodeReview: Plugin = async ({ project, client, $, directory, worktree const args = (input.arguments ?? "").trim().toLowerCase() const isZh = config.language === "zh" - if (args.includes("on")) { + if (args === "on" || args.startsWith("on ")) { autoEnabled = true output.parts = [{ type: "text" as const, text: isZh ? "✅ 自动审查已开启" : "✅ Auto-review is now ON", }] - } else if (args.includes("off")) { + } else if (args === "off" || args.startsWith("off ")) { autoEnabled = false output.parts = [{ type: "text" as const, From a8771382e060c24ad4bd5049092c64a7eb9f1832 Mon Sep 17 00:00:00 2001 From: svtter Date: Fri, 22 May 2026 23:13:49 +0800 Subject: [PATCH 3/3] fix: remove unused buildTogglePrompt import Co-Authored-By: Claude Opus 4.7 --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fd1a146..00d3092 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import type { Plugin } from "@opencode-ai/plugin" import { loadConfig } from "./config.ts" -import { buildAgentPrompt, buildFixerPrompt, buildTogglePrompt } from "./agent.ts" +import { buildAgentPrompt, buildFixerPrompt } from "./agent.ts" import { getDimensionPrompts } from "./dimensions/index.ts" import { reviewChanges, createToggleAutoReviewTool } from "./tools/index.ts"