chatccc 0.2.71 → 0.2.72
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 +2 -1
- package/scripts/postinstall-sharp-check.mjs +59 -0
- package/src/im-skills.ts +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chatccc",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.72",
|
|
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
|
+
}
|
package/src/im-skills.ts
CHANGED
|
@@ -70,37 +70,6 @@ export async function buildImSkillsPrompt(input: BuildImSkillsPromptInput): Prom
|
|
|
70
70
|
.join("\n\n");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
// ---------------------------------------------------------------------------
|
|
74
|
-
// 会话级缓存:相同 session_id + cwd 的渲染结果完全相同,避免每轮重复读文件+渲染
|
|
75
|
-
// ---------------------------------------------------------------------------
|
|
76
|
-
|
|
77
|
-
const promptCache = new Map<string, string>();
|
|
78
|
-
|
|
79
|
-
function promptCacheKey(input: BuildImSkillsPromptInput): string {
|
|
80
|
-
const names = input.enabledSkillNames
|
|
81
|
-
? [...input.enabledSkillNames].sort().join(",")
|
|
82
|
-
: "*";
|
|
83
|
-
const { session_id, cwd } = input.variables;
|
|
84
|
-
return `${input.skillsDir ?? DEFAULT_IM_SKILLS_DIR}|${names}|${session_id}|${cwd}`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** 带会话级缓存的 buildImSkillsPrompt。同 session + 同 cwd 时直接返回缓存的渲染结果。 */
|
|
88
|
-
export async function buildImSkillsPromptCached(input: BuildImSkillsPromptInput): Promise<string> {
|
|
89
|
-
const key = promptCacheKey(input);
|
|
90
|
-
const cached = promptCache.get(key);
|
|
91
|
-
if (cached !== undefined) return cached;
|
|
92
|
-
const result = await buildImSkillsPrompt(input);
|
|
93
|
-
promptCache.set(key, result);
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** 清除指定会话的缓存(如 /cd 后 cwd 变了,旧 key 不再需要) */
|
|
98
|
-
export function clearImSkillsPromptCache(sessionId: string): void {
|
|
99
|
-
for (const key of promptCache.keys()) {
|
|
100
|
-
if (key.includes(`|${sessionId}|`)) promptCache.delete(key);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
73
|
/**
|
|
105
74
|
* 渲染技能目录下的子文档(skill.md 除外)并写入 outputDir。
|
|
106
75
|
* 返回写入的文件路径列表。通常在会话初始化时调用,写入的文档供 Agent 按需读取。
|