@wu529778790/open-im 1.11.2-beta.15 → 1.11.2-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +62 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -137,6 +137,55 @@ const PLATFORM_DISPLAY_NAMES = {
137
137
  workbuddy: '微信',
138
138
  clawbot: '微信 (ClawBot)',
139
139
  };
140
+ /** 读取已启用的插件列表 */
141
+ function getEnabledPlugins() {
142
+ try {
143
+ const { readFileSync, existsSync } = require("fs");
144
+ const { join } = require("path");
145
+ const { homedir } = require("os");
146
+ const settingsPath = join(homedir(), ".claude", "settings.json");
147
+ if (!existsSync(settingsPath))
148
+ return [];
149
+ const settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
150
+ const plugins = settings.enabledPlugins ?? {};
151
+ return Object.entries(plugins)
152
+ .filter(([, v]) => v === true)
153
+ .map(([k]) => k.split("@")[0]);
154
+ }
155
+ catch {
156
+ return [];
157
+ }
158
+ }
159
+ /**
160
+ * 统一通知格式模板
161
+ * 所有发送给 IM 的通知都使用这个格式,保持一致性
162
+ */
163
+ function buildNotification(opts) {
164
+ const lines = [];
165
+ // 标题行
166
+ lines.push(`${opts.emoji} ${opts.title}`);
167
+ // 详情行
168
+ const details = [];
169
+ if (opts.platform)
170
+ details.push(`📱 平台: ${opts.platform}`);
171
+ if (opts.aiCommand)
172
+ details.push(`🤖 AI: ${opts.aiCommand}`);
173
+ if (opts.dir)
174
+ details.push(`📁 目录: ${opts.dir}`);
175
+ const plugins = getEnabledPlugins();
176
+ if (plugins.length > 0)
177
+ details.push(`🧩 插件: ${plugins.join(", ")}`);
178
+ if (opts.uptime)
179
+ details.push(`⏱️ 运行: ${opts.uptime}`);
180
+ if (details.length > 0) {
181
+ lines.push("", ...details);
182
+ }
183
+ // 额外信息
184
+ if (opts.extra?.length) {
185
+ lines.push("", ...opts.extra);
186
+ }
187
+ return lines.join("\n");
188
+ }
140
189
  function buildStartupMessage(platform, appVersion, aiCommand, defaultWorkDir, sessionManager) {
141
190
  let sessionDir;
142
191
  // Telegram 私聊、企业微信当前实现里,活跃 chatId 可直接对应到 session userId。
@@ -149,41 +198,21 @@ function buildStartupMessage(platform, appVersion, aiCommand, defaultWorkDir, se
149
198
  const platformName = PLATFORM_DISPLAY_NAMES[platform] ?? platform;
150
199
  const toolName = getAIToolDisplayName(aiCommand);
151
200
  const dir = sessionDir ? escapePathForMarkdown(sessionDir) : '发送 `/pwd` 查看';
152
- // 读取插件列表
153
- const pluginLines = [];
154
- try {
155
- const { readFileSync, existsSync } = require("fs");
156
- const { join } = require("path");
157
- const { homedir } = require("os");
158
- const settingsPath = join(homedir(), ".claude", "settings.json");
159
- if (existsSync(settingsPath)) {
160
- const settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
161
- const plugins = settings.enabledPlugins ?? {};
162
- const enabled = Object.entries(plugins)
163
- .filter(([, v]) => v === true)
164
- .map(([k]) => k.split("@")[0]); // 只取插件名,去掉 @scope
165
- if (enabled.length > 0) {
166
- pluginLines.push("", `🧩 插件: ${enabled.join(", ")}`);
167
- }
168
- }
169
- }
170
- catch { /* ignore */ }
171
- return [
172
- `✅ open-im v${appVersion} 已就绪`,
173
- "",
174
- `📱 平台: ${platformName}`,
175
- `🤖 AI: ${toolName}`,
176
- `📁 目录: ${dir}`,
177
- ...pluginLines,
178
- ].join("\n\n");
201
+ return buildNotification({
202
+ emoji: "✅",
203
+ title: `open-im v${appVersion} 已就绪`,
204
+ platform: platformName,
205
+ aiCommand: toolName,
206
+ dir,
207
+ });
179
208
  }
180
209
  function buildShutdownMessage(uptimeMinutes) {
181
- const uptime = uptimeMinutes < 1 ? '< 1' : String(uptimeMinutes);
182
- return [
183
- `🛑 open-im 正在关闭`,
184
- "",
185
- `⏱️ 运行时长: ${uptime} 分钟`,
186
- ].join("\n\n");
210
+ const uptimeStr = uptimeMinutes < 1 ? '< 1 分钟' : `${uptimeMinutes} 分钟`;
211
+ return buildNotification({
212
+ emoji: "🛑",
213
+ title: "open-im 正在关闭",
214
+ uptime: uptimeStr,
215
+ });
187
216
  }
188
217
  export async function main() {
189
218
  const startupCwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.2-beta.15",
3
+ "version": "1.11.2-beta.16",
4
4
  "description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",