diff --git a/README.md b/README.md index e76250e..381a645 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,8 @@ opencode/ │ ├── mqtts-quick-reference.md # 快速参考 │ └── USAGE_EXAMPLES.md # 使用示例 │ -├── plugin/ # 插件扩展系统 -│ └── notification.ts # 通知插件(邮件、Slack、钉钉等) -│ ├── README.md # 项目说明文档(当前文件) ├── AGENTS.md # 全局开发规范和指南 ├── opencode.json # 项目配置文件 -├── package.json # Node.js 依赖配置 └── .gitignore # Git 忽略文件配置 ``` - diff --git a/opencode.json b/opencode.json index 496b3d7..117f383 100644 --- a/opencode.json +++ b/opencode.json @@ -1,5 +1,8 @@ { "$schema": "https://opencode.ai/config.json", + "mcp": {}, + "permission": "allow", + "plugin": ["@mohak34/opencode-notifier@latest"], "provider": { "opencode": { "models": { @@ -10,19 +13,15 @@ "budgetTokens": 16000 } } - }, - "claude-sonnet-4-5": { - "options": { - "thinking": { - "type": "enabled", - "budgetTokens": 16000 - } - } } } + }, + "zhipuai-coding-plan": { + "options": { + "apiKey": "0f76aea86295476dbfa98724013b0fe8.o2EaJVqcl4Cf7WLP" + } } }, - "mcp": { - }, - "permission": "allow" + "model": "zhipuai-coding-plan/glm-4.7", + "small_model": "zhipuai-coding-plan/glm-4.7" } diff --git a/plugin/notification.ts b/plugin/notification.ts deleted file mode 100644 index 4e1c2c5..0000000 --- a/plugin/notification.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { Plugin } from "@opencode-ai/plugin" - -/** - * 通知 Plugin - * 在会话完成或发生错误时发送系统通知 - */ -export const NotificationPlugin: Plugin = async ({ project, client, $ }) => { - // 检测操作系统 - const platform = process.platform - - /** - * 发送系统通知 - * @param title 通知标题 - * @param message 通知内容 - * @param isError 是否为错误通知 - */ - const sendNotification = async (title: string, message: string, isError: boolean = false) => { - try { - if (platform === "darwin") { - // macOS - 使用 osascript - const sound = isError ? ' sound name "Basso"' : '' - await $`osascript -e 'display notification "${message}" with title "${title}"${sound}'` - } else if (platform === "linux") { - // Linux - 使用 notify-send - const urgency = isError ? "-u critical" : "" - await $`notify-send "${title}" "${message}" ${urgency}` - } else if (platform === "win32") { - // Windows - 使用 PowerShell - const script = `Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('${message}', '${title}')` - await $`powershell -Command "& {${script}}"` - } - - // 记录日志 - await client.app.log({ - service: "notification", - level: "info", - message: `已发送通知: ${title} - ${message}`, - }) - } catch (error) { - // 如果通知发送失败,记录错误但不中断流程 - await client.app.log({ - service: "notification", - level: "error", - message: `发送通知失败: ${error}`, - }) - } - } - - return { - event: async ({ event }) => { - const projectName = project?.name || "OpenCode" - - // 会话完成时发送通知 - if (event.type === "session.idle") { - await sendNotification( - projectName, - "会话已完成!", - false - ) - } - - // 会话错误时发送通知 - if (event.type === "session.error") { - await sendNotification( - projectName, - "会话发生错误!", - true - ) - } - }, - } -}