@sciagent/cli 1.0.40 → 1.0.41
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 -2
- package/scripts/postinstall.js +33 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sciagent/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "SciAgent CLI - AI Research Assistant",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
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.41",
|
|
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.41';
|
|
31
31
|
|
|
32
32
|
// PyPI 镜像源列表(国内优先)
|
|
33
33
|
const PYPI_MIRRORS = [
|
|
@@ -179,18 +179,18 @@ function downloadFile(url, destPath, timeout = 120000) {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
async function
|
|
183
|
-
//
|
|
182
|
+
async function getSdkDownloadInfo(platformTag) {
|
|
183
|
+
// 尝试从多个镜像获取版本信息和下载URL
|
|
184
184
|
const mirrors = [
|
|
185
185
|
'https://mirrors.cloud.tencent.com/pypi/pypi/codebuddy-agent-sdk/json',
|
|
186
186
|
'https://mirrors.aliyun.com/pypi/pypi/codebuddy-agent-sdk/json',
|
|
187
|
-
'https://pypi.tuna.tsinghua.edu.cn/pypi/codebuddy-agent-sdk/json',
|
|
187
|
+
'https://pypi.tuna.tsinghua.edu.cn/pypi/pypi/codebuddy-agent-sdk/json',
|
|
188
188
|
'https://pypi.org/pypi/codebuddy-agent-sdk/json'
|
|
189
189
|
];
|
|
190
190
|
|
|
191
191
|
for (const url of mirrors) {
|
|
192
192
|
try {
|
|
193
|
-
const
|
|
193
|
+
const result = await new Promise((resolve, reject) => {
|
|
194
194
|
const protocol = url.startsWith('https') ? https : http;
|
|
195
195
|
protocol.get(url, {
|
|
196
196
|
headers: { 'User-Agent': 'sciagent-cli/1.0' },
|
|
@@ -207,7 +207,7 @@ async function getLatestSdkVersion() {
|
|
|
207
207
|
res2.on('end', () => {
|
|
208
208
|
try {
|
|
209
209
|
const json = JSON.parse(data);
|
|
210
|
-
resolve(json
|
|
210
|
+
resolve(json);
|
|
211
211
|
} catch (e) {
|
|
212
212
|
reject(new Error('Parse error'));
|
|
213
213
|
}
|
|
@@ -221,7 +221,7 @@ async function getLatestSdkVersion() {
|
|
|
221
221
|
response.on('end', () => {
|
|
222
222
|
try {
|
|
223
223
|
const json = JSON.parse(data);
|
|
224
|
-
resolve(json
|
|
224
|
+
resolve(json);
|
|
225
225
|
} catch (e) {
|
|
226
226
|
reject(new Error('Parse error'));
|
|
227
227
|
}
|
|
@@ -229,13 +229,27 @@ async function getLatestSdkVersion() {
|
|
|
229
229
|
}).on('error', reject);
|
|
230
230
|
});
|
|
231
231
|
|
|
232
|
-
if (
|
|
232
|
+
if (result && result.info && result.urls) {
|
|
233
|
+
const version = result.info.version;
|
|
234
|
+
// 查找匹配平台的wheel文件
|
|
235
|
+
const wheelUrl = result.urls.find(u =>
|
|
236
|
+
u.filename && u.filename.includes(platformTag) && u.filename.endsWith('.whl')
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
if (wheelUrl) {
|
|
240
|
+
console.log(` 从 ${url.split('/')[2]} 获取到版本信息`);
|
|
241
|
+
return { version, url: wheelUrl.url, size: wheelUrl.size };
|
|
242
|
+
} else {
|
|
243
|
+
console.log(` ${url.split('/')[2]}: 未找到 ${platformTag} 平台的wheel文件`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
233
246
|
} catch (e) {
|
|
247
|
+
console.log(` ${url.split('/')[2]}: ${e.message}`);
|
|
234
248
|
// 继续尝试下一个镜像
|
|
235
249
|
}
|
|
236
250
|
}
|
|
237
251
|
|
|
238
|
-
throw new Error('无法获取SDK
|
|
252
|
+
throw new Error('无法获取SDK下载信息,请检查网络连接');
|
|
239
253
|
}
|
|
240
254
|
|
|
241
255
|
async function installCodebuddySdk() {
|
|
@@ -259,45 +273,26 @@ async function installCodebuddySdk() {
|
|
|
259
273
|
console.log('📦 正在安装 CodeBuddy SDK...');
|
|
260
274
|
|
|
261
275
|
try {
|
|
262
|
-
//
|
|
276
|
+
// 获取版本信息和下载URL
|
|
263
277
|
console.log(' 正在获取版本信息...');
|
|
264
|
-
const
|
|
265
|
-
console.log(` 版本: ${version}`);
|
|
278
|
+
const sdkInfo = await getSdkDownloadInfo(platformTag);
|
|
279
|
+
console.log(` 版本: ${sdkInfo.version}`);
|
|
266
280
|
console.log(` 平台: ${platformTag}`);
|
|
267
|
-
|
|
268
|
-
// 构建 wheel 文件名
|
|
269
|
-
const wheelFilename = `codebuddy_agent_sdk-${version}-py3-none-${platformTag}.whl`;
|
|
281
|
+
console.log(` 文件大小: ${(sdkInfo.size / (1024 * 1024)).toFixed(1)} MB`);
|
|
270
282
|
|
|
271
283
|
// 创建临时目录
|
|
272
284
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sciagent-sdk-'));
|
|
285
|
+
const wheelFilename = `codebuddy_agent_sdk-${sdkInfo.version}-py3-none-${platformTag}.whl`;
|
|
273
286
|
const wheelPath = path.join(tmpDir, wheelFilename);
|
|
274
287
|
|
|
275
|
-
//
|
|
276
|
-
let downloaded = false;
|
|
288
|
+
// 使用从JSON API获取的正确URL下载
|
|
277
289
|
const binaryName = BINARY_NAMES[platform] || 'codebuddy-headless';
|
|
278
290
|
const binDir = getCodebuddyBinDir();
|
|
279
291
|
const targetPath = path.join(binDir, binaryName);
|
|
280
292
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
console.log(` 尝试下载: ${mirror.split('/')[2]}...`);
|
|
286
|
-
await downloadFile(downloadUrl, wheelPath);
|
|
287
|
-
downloaded = true;
|
|
288
|
-
console.log(' ✅ 下载成功');
|
|
289
|
-
break;
|
|
290
|
-
} catch (e) {
|
|
291
|
-
console.log(` ❌ ${mirror.split('/')[2]}: ${e.message}`);
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (!downloaded) {
|
|
297
|
-
console.error('❌ 所有镜像源下载失败');
|
|
298
|
-
console.error(' 请检查网络连接,或稍后运行 "sciagent install-sdk" 手动安装');
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
293
|
+
console.log(' 正在下载...');
|
|
294
|
+
await downloadFile(sdkInfo.url, wheelPath);
|
|
295
|
+
console.log(' ✅ 下载成功');
|
|
301
296
|
|
|
302
297
|
// 提取二进制文件
|
|
303
298
|
console.log(' 正在提取二进制文件...');
|
|
@@ -371,7 +366,7 @@ sys.exit(1)
|
|
|
371
366
|
|
|
372
367
|
function installBinaryPackage(platform, arch) {
|
|
373
368
|
// 版本回退列表:先尝试当前版本,再尝试已知存在的版本
|
|
374
|
-
const FALLBACK_VERSIONS = [CURRENT_VERSION, '1.0.38', '1.0.36', '1.0.33'];
|
|
369
|
+
const FALLBACK_VERSIONS = [CURRENT_VERSION, '1.0.40', '1.0.38', '1.0.36', '1.0.33'];
|
|
375
370
|
|
|
376
371
|
let npmCmd = 'npm';
|
|
377
372
|
const isGlobal = process.env.npm_config_global === 'true' ||
|