@sciagent/cli 1.3.11 → 1.3.13

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
@@ -25,7 +25,7 @@ const https = require('https');
25
25
  const http = require('http');
26
26
 
27
27
  // 当前版本号 - 与 postinstall.js 和 package.json 保持同步
28
- const CURRENT_VERSION = '1.3.11';
28
+ const CURRENT_VERSION = '1.3.13';
29
29
 
30
30
  // Releases 下载源配置(优先级从高到低)
31
31
  // JihuLab 通用包仓库(国内 CDN,速度快)作为主源
@@ -411,6 +411,55 @@ function getInstallDir(platform) {
411
411
  : path.join(os.homedir(), '.sciagent', 'bin');
412
412
  }
413
413
 
414
+ /**
415
+ * 获取 SciAgent 数据目录(与 Python 侧 get_data_dir() 保持一致)
416
+ */
417
+ function getDataDir() {
418
+ if (process.platform === 'win32') {
419
+ return path.join(process.env.LOCALAPPDATA || os.homedir(), 'sciagent', 'data');
420
+ } else if (process.platform === 'darwin') {
421
+ return path.join(os.homedir(), 'Library', 'Application Support', 'sciagent', 'data');
422
+ }
423
+ return path.join(os.homedir(), '.sciagent', 'data');
424
+ }
425
+
426
+ /**
427
+ * 主日志文件路径
428
+ */
429
+ function getLogFilePath() {
430
+ return path.join(getDataDir(), 'logs', 'sciagent.log');
431
+ }
432
+
433
+ /**
434
+ * 日志跟随:把 sciagent.log 新增内容实时打印到当前控制台。
435
+ *
436
+ * 桌面端 exe 以 windowed 模式打包(console=False),自身 stdout 在 CMD 中不可见;
437
+ * 此函数让 npm 壳层持续读取主日志并打印,用户可在 CMD 中看到完整启动/运行日志。
438
+ */
439
+ function tailLogToConsole(child) {
440
+ const logPath = getLogFilePath();
441
+ let lastSize = 0;
442
+ const timer = setInterval(() => {
443
+ try {
444
+ if (!fs.existsSync(logPath)) return;
445
+ const stats = fs.statSync(logPath);
446
+ if (stats.size > lastSize) {
447
+ const fd = fs.openSync(logPath, 'r');
448
+ const buffer = Buffer.alloc(Math.min(stats.size - lastSize, 8 * 1024 * 1024));
449
+ fs.readSync(fd, buffer, 0, buffer.length, lastSize);
450
+ fs.closeSync(fd);
451
+ lastSize = stats.size;
452
+ process.stdout.write(buffer.toString('utf8'));
453
+ } else if (stats.size < lastSize) {
454
+ // 日志被轮转/清空,重新从头部读
455
+ lastSize = 0;
456
+ }
457
+ } catch (e) { /* 忽略瞬时错误(文件被占用等) */ }
458
+ }, 800);
459
+ child.on('exit', () => clearInterval(timer));
460
+ return timer;
461
+ }
462
+
414
463
  /**
415
464
  * 获取当前平台的二进制文件路径
416
465
  */
@@ -924,6 +973,9 @@ function main() {
924
973
  windowsHide: true
925
974
  });
926
975
 
976
+ // 把 sciagent.log 新增内容实时打印到 CMD(windowed exe 自身 stdout 不可见)
977
+ tailLogToConsole(child);
978
+
927
979
  // 处理子进程退出
928
980
  child.on('exit', (code, signal) => {
929
981
  if (signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sciagent/cli",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "SciAgent CLI - AI Research Assistant",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -27,7 +27,7 @@ const ARCH_MAP = {
27
27
  };
28
28
 
29
29
  // 当前版本号 - 每次发布时同步更新
30
- const CURRENT_VERSION = '1.3.11';
30
+ const CURRENT_VERSION = '1.3.13';
31
31
 
32
32
  // GitHub Releases 回退版本列表(当当前版本的 release 不存在时尝试)
33
33
  const GITHUB_FALLBACK_VERSIONS = ['1.1.3', '1.0.50', '1.0.48', '1.0.46', '1.0.40', '1.0.38', '1.0.36'];