@sciagent/cli 1.0.81 → 1.0.83

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 CHANGED
@@ -13,7 +13,7 @@ const https = require('https');
13
13
  const http = require('http');
14
14
 
15
15
  // 当前版本号 - 与 postinstall.js 和 package.json 保持同步
16
- const CURRENT_VERSION = '1.0.81';
16
+ const CURRENT_VERSION = '1.0.83';
17
17
 
18
18
  // 极狐GitLab下载配置
19
19
  const JIHULAB_URL = 'https://jihulab.com';
@@ -83,25 +83,19 @@ function getBinaryPath() {
83
83
  if (fs.existsSync(homeBinPath)) {
84
84
  const stats = fs.statSync(homeBinPath);
85
85
  if (stats.size > 10 * 1024 * 1024) {
86
- // 严格版本检查:版本不匹配时拒绝运行,避免使用旧版有bug的二进制
86
+ // 版本检查:不匹配时自动下载新版本
87
87
  const versionFile = path.join(homeBinDir, '.version');
88
88
  if (fs.existsSync(versionFile)) {
89
89
  const installedVersion = fs.readFileSync(versionFile, 'utf8').trim();
90
90
  const cmp = compareVersions(installedVersion, CURRENT_VERSION);
91
91
  if (cmp < 0) {
92
- // 安装版本低于预期版本 → 旧版有bug,删除
93
- console.error(`[ERROR] Binary version outdated: installed=${installedVersion}, expected=${CURRENT_VERSION}`);
94
- console.error(` The cached binary is outdated and may have critical bugs (e.g., 405 error on login).`);
95
- console.error(` Deleting cached binary and exiting. Please run 'npm install -g @sciagent/cli' again.`);
96
- try {
97
- fs.unlinkSync(homeBinPath);
98
- fs.unlinkSync(versionFile);
99
- console.error(` [OK] Deleted: ${homeBinPath}`);
100
- console.error(` [OK] Deleted: ${versionFile}`);
101
- } catch (e) {
102
- console.error(` [WARN] Failed to delete: ${e.message}`);
103
- console.error(` Please manually delete: ${homeBinDir}`);
104
- }
92
+ // 安装版本低于预期版本 → 自动下载新版本
93
+ console.log(`[INFO] Binary version outdated: installed=${installedVersion}, expected=${CURRENT_VERSION}`);
94
+ console.log(`[INFO] Downloading new version...`);
95
+ try { fs.unlinkSync(homeBinPath); fs.unlinkSync(versionFile); } catch (e) {}
96
+ const downloaded = downloadBinary(platform, arch, CURRENT_VERSION);
97
+ if (downloaded) return downloaded;
98
+ console.error(`[ERROR] Failed to download v${CURRENT_VERSION}. Please run: npm install -g @sciagent/cli`);
105
99
  process.exit(1);
106
100
  } else if (cmp > 0) {
107
101
  // 安装版本高于预期 → 用户手动装了新版,允许运行
@@ -109,15 +103,12 @@ function getBinaryPath() {
109
103
  }
110
104
  // cmp === 0 → 版本匹配,正常使用
111
105
  } else {
112
- // 没有 .version 文件,说明是极旧版本(v1.0.64之前),可能有405 bug
113
- console.error(`[ERROR] Binary version unknown (no .version file). This binary may be outdated.`);
114
- console.error(` Deleting cached binary and exiting. Please run 'npm install -g @sciagent/cli' again.`);
115
- try {
116
- fs.unlinkSync(homeBinPath);
117
- console.error(` [OK] Deleted: ${homeBinPath}`);
118
- } catch (e) {
119
- console.error(` [WARN] Failed to delete: ${e.message}`);
120
- }
106
+ // 没有 .version 文件 → 自动下载新版本
107
+ console.log(`[INFO] Binary version unknown (no .version file), downloading v${CURRENT_VERSION}...`);
108
+ try { fs.unlinkSync(homeBinPath); } catch (e) {}
109
+ const downloaded = downloadBinary(platform, arch, CURRENT_VERSION);
110
+ if (downloaded) return downloaded;
111
+ console.error(`[ERROR] Failed to download v${CURRENT_VERSION}. Please run: npm install -g @sciagent/cli`);
121
112
  process.exit(1);
122
113
  }
123
114
  return homeBinPath;
@@ -125,9 +116,34 @@ function getBinaryPath() {
125
116
  }
126
117
 
127
118
  // 方法1: 从optionalDependencies安装的包中查找
119
+ // 注意:npm缓存中的旧包可能包含旧版二进制,需要版本校验
128
120
  try {
129
121
  const packagePath = require.resolve(`${packageName}/bin/${binName}`);
130
- return packagePath;
122
+ if (fs.existsSync(packagePath)) {
123
+ const stats = fs.statSync(packagePath);
124
+ if (stats.size > 10 * 1024 * 1024) {
125
+ // 检查npm包的package.json版本号
126
+ try {
127
+ const pkgJsonPath = require.resolve(`${packageName}/package.json`);
128
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
129
+ const pkgVersion = pkgJson.version;
130
+ const cmp = compareVersions(pkgVersion, CURRENT_VERSION);
131
+ if (cmp < 0) {
132
+ // npm包版本低于当前版本 → 跳过,下载新版
133
+ console.log(`[INFO] npm package binary outdated: ${packageName}@${pkgVersion} < ${CURRENT_VERSION}, will download new version`);
134
+ } else {
135
+ // 版本匹配或更高,直接使用
136
+ console.log(`[INFO] Using npm package binary: ${packageName}@${pkgVersion}`);
137
+ return packagePath;
138
+ }
139
+ } catch (e) {
140
+ // 无法读取package.json,保守跳过
141
+ console.log(`[INFO] Cannot read package version from ${packageName}, skipping npm binary`);
142
+ }
143
+ } else {
144
+ console.log(`[INFO] npm package binary too small (${(stats.size / 1024).toFixed(0)} KB), likely a stub`);
145
+ }
146
+ }
131
147
  } catch (e) {
132
148
  // 包未安装,继续尝试其他方法
133
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sciagent/cli",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "SciAgent CLI - AI Research Assistant",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -15,12 +15,12 @@
15
15
  "postinstall": "node scripts/postinstall.js"
16
16
  },
17
17
  "optionalDependencies": {
18
- "@sciagent/cli-linux-x64": "1.0.81",
19
- "@sciagent/cli-linux-arm64": "1.0.81",
20
- "@sciagent/cli-darwin-x64": "1.0.81",
21
- "@sciagent/cli-darwin-arm64": "1.0.81",
22
- "@sciagent/cli-win32-x64": "1.0.81",
23
- "@sciagent/cli-win32-arm64": "1.0.81"
18
+ "@sciagent/cli-linux-x64": "1.0.83",
19
+ "@sciagent/cli-linux-arm64": "1.0.83",
20
+ "@sciagent/cli-darwin-x64": "1.0.83",
21
+ "@sciagent/cli-darwin-arm64": "1.0.83",
22
+ "@sciagent/cli-win32-x64": "1.0.83",
23
+ "@sciagent/cli-win32-arm64": "1.0.83"
24
24
  },
25
25
  "keywords": [
26
26
  "ai",
@@ -27,7 +27,7 @@ const ARCH_MAP = {
27
27
  };
28
28
 
29
29
  // 当前版本号 - 每次发布时同步更新
30
- const CURRENT_VERSION = '1.0.81';
30
+ const CURRENT_VERSION = '1.0.83';
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'];