chatccc 0.2.71 → 0.2.73

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.71",
3
+ "version": "0.2.73",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,6 +11,7 @@
11
11
  "files": [
12
12
  "src/",
13
13
  "bin/",
14
+ "scripts/postinstall-sharp-check.mjs",
14
15
  "demo/ilink_echo_probe.ts",
15
16
  "im-skills/",
16
17
  "images/img_readme_*.jpg",
@@ -0,0 +1,59 @@
1
+ // postinstall 检测 sharp 原生模块是否可用(常见于 Linux 缺少 libvips)
2
+ import { createRequire } from "node:module";
3
+
4
+ const require = createRequire(import.meta.url);
5
+ let ok = false;
6
+
7
+ try {
8
+ require("sharp");
9
+ ok = true;
10
+ } catch (err) {
11
+ const msg = err.message;
12
+ const platform = process.platform;
13
+
14
+ console.warn("");
15
+ console.warn("============================================================");
16
+ console.warn(" ChatCCC: sharp 图像处理模块检测失败");
17
+ console.warn("============================================================");
18
+
19
+ if (platform === "linux") {
20
+ if (msg.includes("libvips") || msg.includes("vips") || msg.includes("libglib")) {
21
+ console.warn(" 原因:系统缺少 libvips 图像处理库。");
22
+ console.warn("");
23
+ console.warn(" 请先安装 libvips 然后重建 sharp:");
24
+ console.warn("");
25
+ console.warn(" Debian / Ubuntu:");
26
+ console.warn(" sudo apt install libvips-dev");
27
+ console.warn("");
28
+ console.warn(" CentOS / RHEL / Fedora:");
29
+ console.warn(" sudo yum install vips-devel");
30
+ console.warn("");
31
+ console.warn(" Alpine:");
32
+ console.warn(" sudo apk add vips-dev");
33
+ console.warn("");
34
+ console.warn(" 安装 libvips 后重建 sharp:");
35
+ console.warn(" npm install -g chatccc --force");
36
+ } else if (msg.includes("Cannot find module")) {
37
+ console.warn(" 原因:sharp 模块未成功安装。");
38
+ console.warn("");
39
+ console.warn(" 请尝试重建(可能需要先安装 libvips):");
40
+ console.warn(" npm install -g chatccc --force");
41
+ } else {
42
+ console.warn(" 错误详情:", msg);
43
+ }
44
+ } else {
45
+ console.warn(" 错误详情:", msg);
46
+ console.warn(" 平台:", platform);
47
+ console.warn(" 请尝试:npm install -g chatccc --force");
48
+ }
49
+
50
+ console.warn("");
51
+ console.warn(" 缺少 sharp 不影响消息收发,但群聊头像状态指示");
52
+ console.warn(" (运行中/空闲/新建)将不会更新。");
53
+ console.warn("============================================================");
54
+ console.warn("");
55
+ }
56
+
57
+ if (!ok && process.env.npm_config_verbose) {
58
+ process.exitCode = 0; // 永远不阻塞安装
59
+ }
@@ -3,7 +3,12 @@ import { join } from "node:path";
3
3
  import { tmpdir } from "node:os";
4
4
  import { afterEach, describe, expect, it } from "vitest";
5
5
 
6
- import { buildImSkillsPrompt, exportSkillSubDocs } from "../im-skills.ts";
6
+ import {
7
+ buildImSkillsPrompt,
8
+ buildImSkillsPromptCached,
9
+ clearImSkillsPromptCache,
10
+ exportSkillSubDocs,
11
+ } from "../im-skills.ts";
7
12
 
8
13
  let tempRoot: string | null = null;
9
14
 
@@ -97,4 +102,24 @@ describe("IM skills prompt rendering", () => {
97
102
  expect(prompt).toContain("[ChatCCC IM skill: wechat-skill]");
98
103
  expect(exported.length).toBeGreaterThanOrEqual(2);
99
104
  });
105
+
106
+ it("exports cached prompt helpers used by session startup", async () => {
107
+ tempRoot = await mkdtemp(join(tmpdir(), "chatccc-im-skills-cache-"));
108
+ const skillDir = join(tempRoot, "feishu-skill");
109
+ await mkdir(skillDir);
110
+ await writeFile(join(skillDir, "skill.md"), "cwd={{cwd}}", "utf-8");
111
+
112
+ const input = {
113
+ skillsDir: tempRoot,
114
+ variables: { cwd: "C:/first", session_id: "sid_cache" },
115
+ };
116
+ const first = await buildImSkillsPromptCached(input);
117
+ await writeFile(join(skillDir, "skill.md"), "cwd={{cwd}} changed", "utf-8");
118
+ const cached = await buildImSkillsPromptCached(input);
119
+ clearImSkillsPromptCache("sid_cache");
120
+ const refreshed = await buildImSkillsPromptCached(input);
121
+
122
+ expect(cached).toBe(first);
123
+ expect(refreshed).toContain("changed");
124
+ });
100
125
  });