Skip to content
Open
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
33 changes: 31 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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,
}
},

Expand All @@ -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 === "on" || args.startsWith("on ")) {
autoEnabled = true
output.parts = [{
type: "text" as const,
text: isZh ? "✅ 自动审查已开启" : "✅ Auto-review is now ON",
}]
} else if (args === "off" || args.startsWith("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()
Expand Down