@sciagent/cli 1.0.70 → 1.0.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/bin/sciagent.js +31 -10
- package/package.json +3 -3
- package/scripts/postinstall.js +1 -1
package/bin/sciagent.js
CHANGED
|
@@ -11,7 +11,7 @@ const fs = require('fs');
|
|
|
11
11
|
const os = require('os');
|
|
12
12
|
|
|
13
13
|
// 当前版本号 - 与 postinstall.js 和 package.json 保持同步
|
|
14
|
-
const CURRENT_VERSION = '1.0.
|
|
14
|
+
const CURRENT_VERSION = '1.0.72';
|
|
15
15
|
|
|
16
16
|
// 平台和架构映射
|
|
17
17
|
const PLATFORM_MAP = {
|
|
@@ -26,6 +26,22 @@ const ARCH_MAP = {
|
|
|
26
26
|
amd64: 'x64'
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 比较语义化版本号
|
|
31
|
+
* 返回: -1 (a<b), 0 (a==b), 1 (a>b)
|
|
32
|
+
*/
|
|
33
|
+
function compareVersions(a, b) {
|
|
34
|
+
const pa = a.split('.').map(Number);
|
|
35
|
+
const pb = b.split('.').map(Number);
|
|
36
|
+
for (let i = 0; i < 3; i++) {
|
|
37
|
+
const na = pa[i] || 0;
|
|
38
|
+
const nb = pb[i] || 0;
|
|
39
|
+
if (na < nb) return -1;
|
|
40
|
+
if (na > nb) return 1;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
/**
|
|
30
46
|
* 获取当前平台的二进制文件路径
|
|
31
47
|
*/
|
|
@@ -63,31 +79,36 @@ function getBinaryPath() {
|
|
|
63
79
|
const versionFile = path.join(homeBinDir, '.version');
|
|
64
80
|
if (fs.existsSync(versionFile)) {
|
|
65
81
|
const installedVersion = fs.readFileSync(versionFile, 'utf8').trim();
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
const cmp = compareVersions(installedVersion, CURRENT_VERSION);
|
|
83
|
+
if (cmp < 0) {
|
|
84
|
+
// 安装版本低于预期版本 → 旧版有bug,删除
|
|
85
|
+
console.error(`[ERROR] Binary version outdated: installed=${installedVersion}, expected=${CURRENT_VERSION}`);
|
|
68
86
|
console.error(` The cached binary is outdated and may have critical bugs (e.g., 405 error on login).`);
|
|
69
87
|
console.error(` Deleting cached binary and exiting. Please run 'npm install -g @sciagent/cli' again.`);
|
|
70
|
-
// 自动删除旧版二进制,下次安装时 postinstall 会重新下载
|
|
71
88
|
try {
|
|
72
89
|
fs.unlinkSync(homeBinPath);
|
|
73
90
|
fs.unlinkSync(versionFile);
|
|
74
|
-
console.error(`
|
|
75
|
-
console.error(`
|
|
91
|
+
console.error(` [OK] Deleted: ${homeBinPath}`);
|
|
92
|
+
console.error(` [OK] Deleted: ${versionFile}`);
|
|
76
93
|
} catch (e) {
|
|
77
|
-
console.error(`
|
|
94
|
+
console.error(` [WARN] Failed to delete: ${e.message}`);
|
|
78
95
|
console.error(` Please manually delete: ${homeBinDir}`);
|
|
79
96
|
}
|
|
80
97
|
process.exit(1);
|
|
98
|
+
} else if (cmp > 0) {
|
|
99
|
+
// 安装版本高于预期 → 用户手动装了新版,允许运行
|
|
100
|
+
console.log(`[INFO] Binary version ${installedVersion} is newer than npm package version ${CURRENT_VERSION}, using it.`);
|
|
81
101
|
}
|
|
102
|
+
// cmp === 0 → 版本匹配,正常使用
|
|
82
103
|
} else {
|
|
83
104
|
// 没有 .version 文件,说明是极旧版本(v1.0.64之前),可能有405 bug
|
|
84
|
-
console.error(
|
|
105
|
+
console.error(`[ERROR] Binary version unknown (no .version file). This binary may be outdated.`);
|
|
85
106
|
console.error(` Deleting cached binary and exiting. Please run 'npm install -g @sciagent/cli' again.`);
|
|
86
107
|
try {
|
|
87
108
|
fs.unlinkSync(homeBinPath);
|
|
88
|
-
console.error(`
|
|
109
|
+
console.error(` [OK] Deleted: ${homeBinPath}`);
|
|
89
110
|
} catch (e) {
|
|
90
|
-
console.error(`
|
|
111
|
+
console.error(` [WARN] Failed to delete: ${e.message}`);
|
|
91
112
|
}
|
|
92
113
|
process.exit(1);
|
|
93
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sciagent/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.72",
|
|
4
4
|
"description": "SciAgent CLI - AI Research Assistant",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"postinstall": "node scripts/postinstall.js"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@sciagent/cli-linux-x64": "1.0.
|
|
18
|
+
"@sciagent/cli-linux-x64": "1.0.71",
|
|
19
19
|
"@sciagent/cli-linux-arm64": "1.0.39",
|
|
20
20
|
"@sciagent/cli-darwin-x64": "1.0.39",
|
|
21
21
|
"@sciagent/cli-darwin-arm64": "1.0.39",
|
|
22
|
-
"@sciagent/cli-win32-x64": "1.0.
|
|
22
|
+
"@sciagent/cli-win32-x64": "1.0.72",
|
|
23
23
|
"@sciagent/cli-win32-arm64": "1.0.39"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
package/scripts/postinstall.js
CHANGED
|
@@ -27,7 +27,7 @@ const ARCH_MAP = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// 当前版本号 - 每次发布时同步更新
|
|
30
|
-
const CURRENT_VERSION = '1.0.
|
|
30
|
+
const CURRENT_VERSION = '1.0.72';
|
|
31
31
|
|
|
32
32
|
// GitHub Releases 回退版本列表(当当前版本的 release 不存在时尝试)
|
|
33
33
|
const GITHUB_FALLBACK_VERSIONS = ['1.0.50', '1.0.48', '1.0.46', '1.0.40', '1.0.38', '1.0.36'];
|