@sciagent/cli 1.0.86 → 1.0.88
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 +4 -28
- package/package.json +2 -9
- package/scripts/postinstall.js +20 -87
package/bin/sciagent.js
CHANGED
|
@@ -23,7 +23,7 @@ const fs = require('fs');
|
|
|
23
23
|
const os = require('os');
|
|
24
24
|
|
|
25
25
|
// 当前版本号 - 与 postinstall.js 和 package.json 保持同步
|
|
26
|
-
const CURRENT_VERSION = '1.0.
|
|
26
|
+
const CURRENT_VERSION = '1.0.88';
|
|
27
27
|
|
|
28
28
|
// 极狐GitLab下载配置
|
|
29
29
|
const JIHULAB_URL = 'https://jihulab.com';
|
|
@@ -104,11 +104,11 @@ function getBinaryPath() {
|
|
|
104
104
|
|
|
105
105
|
if (cmp === 0) {
|
|
106
106
|
// 版本精确匹配 → 直接使用
|
|
107
|
-
console.log(`[INFO] SciAgent v${installedVersion} (
|
|
107
|
+
console.log(`[INFO] SciAgent v${installedVersion} (${(stats.size / (1024 * 1024)).toFixed(1)} MB, ${stats.mtime.toISOString().slice(0,10)})`);
|
|
108
108
|
return binPath;
|
|
109
109
|
} else if (cmp < 0) {
|
|
110
110
|
// 版本过低 → 自动下载新版本
|
|
111
|
-
console.log(`[INFO] SciAgent version outdated: v${installedVersion} → v${CURRENT_VERSION}`);
|
|
111
|
+
console.log(`[INFO] SciAgent version outdated: v${installedVersion} (${(stats.size / (1024 * 1024)).toFixed(1)} MB) → v${CURRENT_VERSION}`);
|
|
112
112
|
console.log(`[INFO] Downloading new version from JiHuLab...`);
|
|
113
113
|
try { fs.unlinkSync(binPath); fs.unlinkSync(versionFile); } catch (e) {}
|
|
114
114
|
const downloaded = downloadBinary(platform, arch, CURRENT_VERSION);
|
|
@@ -117,7 +117,7 @@ function getBinaryPath() {
|
|
|
117
117
|
process.exit(1);
|
|
118
118
|
} else {
|
|
119
119
|
// 版本更高 → 允许运行(用户可能手动安装了新版)
|
|
120
|
-
console.log(`[INFO] SciAgent v${installedVersion} (newer than package v${CURRENT_VERSION})`);
|
|
120
|
+
console.log(`[INFO] SciAgent v${installedVersion} (newer than package v${CURRENT_VERSION}, ${(stats.size / (1024 * 1024)).toFixed(1)} MB)`);
|
|
121
121
|
return binPath;
|
|
122
122
|
}
|
|
123
123
|
} else {
|
|
@@ -136,30 +136,6 @@ function getBinaryPath() {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
// 检查 npm optionalDependencies 包路径
|
|
140
|
-
const packageName = `@sciagent/cli-${platform}-${arch}`;
|
|
141
|
-
try {
|
|
142
|
-
const npmBinPath = require.resolve(`${packageName}/bin/${binName}`);
|
|
143
|
-
if (fs.existsSync(npmBinPath)) {
|
|
144
|
-
const stats = fs.statSync(npmBinPath);
|
|
145
|
-
if (stats.size > 10 * 1024 * 1024) {
|
|
146
|
-
console.log(`[INFO] SciAgent v${CURRENT_VERSION} (npm package)`);
|
|
147
|
-
// 复制到本地安装目录以便后续版本检查
|
|
148
|
-
try {
|
|
149
|
-
fs.mkdirSync(installDir, { recursive: true });
|
|
150
|
-
const localCopy = path.join(installDir, binName);
|
|
151
|
-
fs.copyFileSync(npmBinPath, localCopy);
|
|
152
|
-
fs.writeFileSync(path.join(installDir, '.version'), CURRENT_VERSION);
|
|
153
|
-
} catch (e) {
|
|
154
|
-
// 复制失败不影响运行,直接使用npm包路径
|
|
155
|
-
}
|
|
156
|
-
return npmBinPath;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} catch (e) {
|
|
160
|
-
// npm 包未安装
|
|
161
|
-
}
|
|
162
|
-
|
|
163
139
|
// 开发模式:从本地packages目录查找
|
|
164
140
|
const localPath = path.join(__dirname, '..', 'packages', `sciagent-${platform}-${arch}`, 'bin', binName);
|
|
165
141
|
if (fs.existsSync(localPath)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sciagent/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.88",
|
|
4
4
|
"description": "SciAgent CLI - AI Research Assistant",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,14 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"postinstall": "node scripts/postinstall.js"
|
|
16
16
|
},
|
|
17
|
-
"optionalDependencies": {
|
|
18
|
-
"@sciagent/cli-linux-x64": "1.0.86",
|
|
19
|
-
"@sciagent/cli-linux-arm64": "1.0.86",
|
|
20
|
-
"@sciagent/cli-darwin-x64": "1.0.86",
|
|
21
|
-
"@sciagent/cli-darwin-arm64": "1.0.86",
|
|
22
|
-
"@sciagent/cli-win32-x64": "1.0.86",
|
|
23
|
-
"@sciagent/cli-win32-arm64": "1.0.86"
|
|
24
|
-
},
|
|
17
|
+
"optionalDependencies": {},
|
|
25
18
|
"keywords": [
|
|
26
19
|
"ai",
|
|
27
20
|
"research",
|
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.88';
|
|
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'];
|
|
@@ -35,7 +35,7 @@ const GITHUB_FALLBACK_VERSIONS = ['1.0.50', '1.0.48', '1.0.46', '1.0.40', '1.0.3
|
|
|
35
35
|
// Releases 服务器配置
|
|
36
36
|
// 优先使用环境变量,否则使用默认服务器
|
|
37
37
|
const RELEASE_SERVER_URL = process.env.RELEASE_SERVER_URL ||
|
|
38
|
-
'https://u250924-
|
|
38
|
+
'https://u250924-bfd4-44855e5c.westb.seetacloud.com:8443';
|
|
39
39
|
|
|
40
40
|
// PyPI 镜像源列表(国内优先)
|
|
41
41
|
const PYPI_MIRRORS = [
|
|
@@ -127,21 +127,11 @@ function checkBinaryInstalled(platform, arch) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const stats = fs.statSync(packagePath);
|
|
136
|
-
if (stats.size > 10 * 1024 * 1024) {
|
|
137
|
-
return { installed: true, path: packagePath };
|
|
138
|
-
} else {
|
|
139
|
-
console.log(` ℹ️ npm 包中的二进制文件太小 (${stats.size} bytes),是空壳包`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
} catch (e) {
|
|
143
|
-
// 包未安装
|
|
144
|
-
}
|
|
130
|
+
// 不再从 npm optionalDependencies 查找二进制,原因:
|
|
131
|
+
// 1. npm 缓存中的旧包可能包含旧版二进制(如 1.0.40 的 194MB 旧 exe)
|
|
132
|
+
// 2. npm 可能修改 package.json 版本号来匹配请求,但二进制文件仍是旧的
|
|
133
|
+
// 3. 超过 250MB 的包无法发布到 npm,只有空壳包
|
|
134
|
+
// 所有二进制统一从极狐GitLab下载,确保版本正确
|
|
145
135
|
|
|
146
136
|
return { installed: false };
|
|
147
137
|
}
|
|
@@ -662,60 +652,9 @@ async function downloadFromServer(platform, arch, version) {
|
|
|
662
652
|
}
|
|
663
653
|
}
|
|
664
654
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
// 1.0.40/1.0.38/1.0.36 包含完整的二进制文件
|
|
669
|
-
const FALLBACK_VERSIONS = [CURRENT_VERSION, '1.0.63', '1.0.61', '1.0.48', '1.0.46', '1.0.40', '1.0.38', '1.0.36'];
|
|
670
|
-
|
|
671
|
-
let npmCmd = 'npm';
|
|
672
|
-
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
673
|
-
process.env.npm_lifecycle_event === 'postinstall';
|
|
674
|
-
|
|
675
|
-
for (const version of FALLBACK_VERSIONS) {
|
|
676
|
-
const packageName = `@sciagent/cli-${platform}-${arch}@${version}`;
|
|
677
|
-
console.log(`\n Installing platform binary: ${packageName}`);
|
|
678
|
-
console.log(' This may take a moment...\n');
|
|
679
|
-
|
|
680
|
-
try {
|
|
681
|
-
let installArgs = ['install', '-g', packageName];
|
|
682
|
-
|
|
683
|
-
if (!isGlobal) {
|
|
684
|
-
installArgs = ['install', packageName];
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
execSync(`${npmCmd} ${installArgs.join(' ')}`, {
|
|
688
|
-
stdio: 'inherit',
|
|
689
|
-
timeout: 300000
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
// 关键修复:npm install 成功不等于二进制文件存在
|
|
693
|
-
// 空壳包(423 bytes)也会返回成功,但没有实际二进制
|
|
694
|
-
const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
|
|
695
|
-
try {
|
|
696
|
-
const resolvedPath = require.resolve(`@sciagent/cli-${platform}-${arch}/bin/${binName}`);
|
|
697
|
-
if (fs.existsSync(resolvedPath)) {
|
|
698
|
-
const stats = fs.statSync(resolvedPath);
|
|
699
|
-
// 二进制文件应该至少 10MB
|
|
700
|
-
if (stats.size > 10 * 1024 * 1024) {
|
|
701
|
-
console.log(` ✅ Verified binary: ${resolvedPath} (${(stats.size / (1024 * 1024)).toFixed(1)} MB)`);
|
|
702
|
-
return true;
|
|
703
|
-
} else {
|
|
704
|
-
console.log(` ⚠️ Binary too small (${stats.size} bytes), likely a stub package`);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
} catch (e) {
|
|
708
|
-
// require.resolve 失败说明 bin 目录不存在
|
|
709
|
-
}
|
|
710
|
-
console.log(` ⚠️ ${packageName} installed but has no binary, trying next version...`);
|
|
711
|
-
} catch (e) {
|
|
712
|
-
console.log(` ⚠️ ${packageName} not available, trying next version...`);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
console.error(`\n ❌ Failed to install platform binary for ${platform}-${arch}`);
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
655
|
+
// installBinaryPackage 已移除
|
|
656
|
+
// 原因:npm optionalDependencies 缓存旧包导致版本错乱
|
|
657
|
+
// 所有二进制统一从极狐GitLab下载
|
|
719
658
|
|
|
720
659
|
async function main() {
|
|
721
660
|
console.log('[postinstall] Starting postinstall script...');
|
|
@@ -774,22 +713,16 @@ async function main() {
|
|
|
774
713
|
const serverSuccess = await downloadFromServer(platform, arch, CURRENT_VERSION);
|
|
775
714
|
|
|
776
715
|
if (!serverSuccess) {
|
|
777
|
-
|
|
778
|
-
console.
|
|
779
|
-
console.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
console.error('');
|
|
788
|
-
console.error(' Please run this command manually:');
|
|
789
|
-
console.error(` npm install -g ${packageName}@${CURRENT_VERSION}`);
|
|
790
|
-
console.error('');
|
|
791
|
-
process.exit(1);
|
|
792
|
-
}
|
|
716
|
+
console.error('');
|
|
717
|
+
console.error('╔══════════════════════════════════════════════════════════╗');
|
|
718
|
+
console.error('║ Manual Installation Required ║');
|
|
719
|
+
console.error('╚══════════════════════════════════════════════════════════╝');
|
|
720
|
+
console.error('');
|
|
721
|
+
console.error(' All download sources failed. Please try again later or:');
|
|
722
|
+
console.error(` 1. Check your network connection`);
|
|
723
|
+
console.error(` 2. Visit: https://jihulab.com/13996615495-group/research-agent/-/packages`);
|
|
724
|
+
console.error('');
|
|
725
|
+
process.exit(1);
|
|
793
726
|
}
|
|
794
727
|
}
|
|
795
728
|
|