@rienn/guanyuan-cli 0.4.0 → 0.5.1

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/README.md CHANGED
@@ -8,7 +8,12 @@
8
8
  npm install -g @rienn/guanyuan-cli
9
9
  ```
10
10
 
11
- 安装后终端可用 `guanyuan` 命令。
11
+ 安装后终端可用 `guanyuan` 命令。包自带 Windows + macOS(Intel/Apple Silicon) 二进制,按系统自动选。
12
+
13
+ 更新到最新(完全覆盖旧版):
14
+ ```bash
15
+ npm install -g @rienn/guanyuan-cli@latest
16
+ ```
12
17
 
13
18
  ## 登录
14
19
 
package/bin/guanyuan.js CHANGED
@@ -1,11 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  // 启动器:按当前系统/架构选 vendor 里对应的 Go 二进制并转发参数与退出码。
4
+ // update/upgrade 在 JS 层拦截执行 npm,不启动 Go 二进制——避免 Windows 下替换正在运行的 exe 引发文件占用。
4
5
  const { spawnSync } = require("child_process");
5
6
  const fs = require("fs");
6
7
  const path = require("path");
7
8
  const os = require("os");
8
9
 
10
+ const PKG = "@rienn/guanyuan-cli";
11
+
12
+ if (process.argv[2] === "update" || process.argv[2] === "upgrade") {
13
+ const npmCmd = os.platform() === "win32" ? "npm.cmd" : "npm";
14
+ console.error(`更新 ${PKG} 到最新版...`);
15
+ const res = spawnSync(npmCmd, ["install", "-g", `${PKG}@latest`], { stdio: "inherit" });
16
+ if (res.error) {
17
+ console.error(`更新失败: ${res.error.message}`);
18
+ console.error(`请手动执行: npm install -g ${PKG}@latest(检查 npm registry / 代理 / 权限)`);
19
+ process.exit(1);
20
+ }
21
+ if (res.status === 0) {
22
+ console.error("\n更新完成。下一步建议:");
23
+ console.error(" 1. guanyuan version");
24
+ console.error(" 2. guanyuan skill install # 更新 Agent Skill");
25
+ console.error(" 3. guanyuan refresh # 重建深度索引");
26
+ }
27
+ process.exit(res.status === null ? 1 : res.status);
28
+ }
29
+
9
30
  function binaryName() {
10
31
  const platform = os.platform();
11
32
  const arch = os.arch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rienn/guanyuan-cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "观远 Agent CLI — 给 AI Agent 用的观远 BI 取数遥控器(零依赖 Go 单二进制)",
5
5
  "bin": {
6
6
  "guanyuan": "bin/guanyuan.js"
Binary file
Binary file
Binary file