@tencent-connect/openclaw-qqbot 1.6.6 → 1.6.7
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/README.md +6 -1
- package/README.zh.md +6 -1
- package/dist/src/api.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/gateway.js +1 -1
- package/dist/src/request-context.d.ts +7 -0
- package/dist/src/request-context.js +7 -0
- package/dist/src/slash-commands.js +362 -38
- package/dist/src/tools/remind.js +17 -9
- package/dist/src/types.d.ts +9 -2
- package/dist/src/update-checker.d.ts +3 -1
- package/dist/src/update-checker.js +13 -2
- package/dist/src/utils/pkg-version.js +19 -9
- package/package.json +4 -1
- package/scripts/postinstall-link-sdk.js +22 -9
- package/scripts/upgrade-via-npm.ps1 +9 -0
- package/scripts/upgrade-via-npm.sh +154 -30
- package/scripts/upgrade-via-source.sh +124 -38
- package/skills/qqbot-remind/SKILL.md +21 -11
- package/src/api.ts +1 -1
- package/src/config.ts +1 -1
- package/src/gateway.ts +1 -1
- package/src/request-context.ts +10 -0
- package/src/slash-commands.ts +354 -36
- package/src/tools/remind.ts +17 -9
- package/src/types.ts +9 -2
- package/src/update-checker.ts +14 -2
- package/src/utils/pkg-version.ts +18 -8
package/src/utils/pkg-version.ts
CHANGED
|
@@ -8,10 +8,22 @@ import { createRequire } from "node:module";
|
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** 已定位到的 package.json 路径,避免重复遍历目录树 */
|
|
12
|
+
let _resolvedPkgPath: string | null = null;
|
|
12
13
|
|
|
13
14
|
export function getPackageVersion(metaUrl?: string): string {
|
|
14
|
-
|
|
15
|
+
// 如果之前已定位到 package.json 路径,直接重新读取(快速路径)
|
|
16
|
+
if (_resolvedPkgPath) {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(_resolvedPkgPath, "utf8"));
|
|
19
|
+
if (pkg.name === "@tencent-connect/openclaw-qqbot" && pkg.version) {
|
|
20
|
+
return pkg.version as string;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
// 文件可能已被删除(升级过程中),清除路径缓存,走完整查找
|
|
24
|
+
_resolvedPkgPath = null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
|
|
16
28
|
// Strategy 1: 从调用者的 import.meta.url(或本模块)向上遍历找 package.json
|
|
17
29
|
const startFile = metaUrl ? fileURLToPath(metaUrl) : fileURLToPath(import.meta.url);
|
|
@@ -25,8 +37,8 @@ export function getPackageVersion(metaUrl?: string): string {
|
|
|
25
37
|
const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
|
|
26
38
|
// 确认是我们自己的包(避免找到其他 package.json)
|
|
27
39
|
if (pkg.name === "@tencent-connect/openclaw-qqbot" && pkg.version) {
|
|
28
|
-
|
|
29
|
-
return
|
|
40
|
+
_resolvedPkgPath = candidate;
|
|
41
|
+
return pkg.version as string;
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
} catch {
|
|
@@ -42,13 +54,11 @@ export function getPackageVersion(metaUrl?: string): string {
|
|
|
42
54
|
try {
|
|
43
55
|
const pkg = require(rel);
|
|
44
56
|
if (pkg?.version) {
|
|
45
|
-
|
|
46
|
-
return _cached;
|
|
57
|
+
return pkg.version as string;
|
|
47
58
|
}
|
|
48
59
|
} catch { /* next */ }
|
|
49
60
|
}
|
|
50
61
|
} catch { /* fallback */ }
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
return _cached;
|
|
63
|
+
return "unknown";
|
|
54
64
|
}
|