@gaiaworks/gaia-cli 0.4.9 → 0.5.0

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
@@ -25,46 +25,46 @@ npx @gaiaworks/gaia-cli@latest install --mode external
25
25
  npx @gaiaworks/gaia-cli@latest install --mode internal
26
26
  ```
27
27
 
28
- 未指定 `--mode` 时默认写入 `external`。安装脚本会执行 `gaia setup --mode <external|internal>`,用于初始化本地 `install_mode`,并同步当前模式的 `gaia-shared` 与公共的 `gaia-skill-maker`。
29
-
30
- 安装时会根据 npm 包版本,从 OSS 的同版本目录下载当前平台对应的 `gaia-cli` 二进制。
31
-
32
- 升级到 npm `latest` 并保留当前安装模式:
33
-
34
- ```bash
35
- gaia update
36
- ```
37
-
38
- 仅检查或安装指定版本:
39
-
40
- ```bash
41
- gaia update --check
42
- gaia update --version 0.0.7
43
- ```
44
-
45
- 更新命令拒绝降级。首个包含该命令的版本仍需通过 `npx ... install` 手工升级一次。
46
-
47
- 查看脱敏后的当前有效配置,并诊断配置、端点、登录凭据及 Internal 远程授权服务:
48
-
49
- ```bash
50
- gaia config show
51
- gaia doctor
52
- gaia doctor --json
53
- ```
54
-
55
- `config show` 不输出 Token 或 Client Secret 明文。未登录属于警告;配置非法、必填端点缺失或远程授权服务健康检查失败时,`doctor` 返回非零退出码。
56
-
57
- 卸载全局命令和 Gaia 管理的 Agent Skills,默认保留本地配置、凭据和目标信息:
58
-
59
- ```bash
60
- gaia uninstall
61
- ```
62
-
63
- 需要同时删除全部本地 Gaia 数据时使用:
64
-
65
- ```bash
66
- gaia uninstall --purge
67
- gaia uninstall --purge --yes
68
- ```
69
-
70
- `--purge` 删除 `GAIA_CONFIG_DIR` 指向的目录;未设置该环境变量时删除 `~/.gaia`。默认会要求确认,自动化场景可显式添加 `--yes`。
28
+ 未指定 `--mode` 时默认写入 `external`。安装脚本会执行 `gaia setup --mode <external|internal>`,用于初始化本地 `install_mode`,并同步当前模式的 `gaia-shared` 与公共的 `gaia-skill-maker`。
29
+
30
+ 安装时会根据 npm 包版本,从 OSS 的同版本目录下载当前平台对应的 `gaia-cli` 二进制。
31
+
32
+ 升级到 npm `latest` 并保留当前安装模式:
33
+
34
+ ```bash
35
+ gaia update
36
+ ```
37
+
38
+ 仅检查或安装指定版本:
39
+
40
+ ```bash
41
+ gaia update --check
42
+ gaia update --version 0.0.7
43
+ ```
44
+
45
+ 更新命令拒绝降级。首个包含该命令的版本仍需通过 `npx ... install` 手工升级一次。
46
+
47
+ 查看脱敏后的当前有效配置,并诊断配置、端点、登录凭据及 Internal 远程授权服务:
48
+
49
+ ```bash
50
+ gaia config show
51
+ gaia doctor
52
+ gaia doctor --json
53
+ ```
54
+
55
+ `config show` 不输出 Token 或 Client Secret 明文。未登录属于警告;配置非法、必填端点缺失或远程授权服务健康检查失败时,`doctor` 返回非零退出码。
56
+
57
+ 卸载全局命令和 Gaia 管理的 Agent Skills,默认保留本地配置、凭据和目标信息:
58
+
59
+ ```bash
60
+ gaia uninstall
61
+ ```
62
+
63
+ 需要同时删除全部本地 Gaia 数据时使用:
64
+
65
+ ```bash
66
+ gaia uninstall --purge
67
+ gaia uninstall --purge --yes
68
+ ```
69
+
70
+ `--purge` 删除 `GAIA_CONFIG_DIR` 指向的目录;未设置该环境变量时删除 `~/.gaia`。默认会要求确认,自动化场景可显式添加 `--yes`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaiaworks/gaia-cli",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "description": "JavaScript launcher for gaia-cli.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -115,54 +115,54 @@ function shellProfilePath(env = process.env) {
115
115
  return path.join(home, '.profile');
116
116
  }
117
117
 
118
- function ensureWindowsPathConfigured(binDir, options = {}) {
119
- const platform = options.platform || process.platform;
120
- const spawn = options.spawnSync || spawnSync;
121
- if (!binDir || platform !== 'win32') return null;
122
- const command = [
123
- "$dir = $env:GAIA_CLI_PATH_DIR",
124
- "$current = [Environment]::GetEnvironmentVariable('Path', 'User')",
125
- "if (-not $current) { $current = '' }",
126
- "$parts = $current -split ';' | Where-Object { $_ }",
127
- "$normalize = { param($value) [Environment]::ExpandEnvironmentVariables($value.Trim().Trim([char]34).TrimEnd([char[]]'\\/')) }",
128
- "$target = & $normalize $dir",
129
- "$exists = @($parts | Where-Object { (& $normalize $_) -ieq $target }).Count -gt 0",
130
- "if (-not $exists) {",
131
- " $next = (@($dir) + $parts) -join ';'",
132
- " [Environment]::SetEnvironmentVariable('Path', $next, 'User')",
133
- " Write-Output '[gaia-cli:path-updated]'",
134
- "} else {",
135
- " Write-Output '[gaia-cli:path-unchanged]'",
136
- "}",
137
- ].join("; ");
138
- const result = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
139
- stdio: ["ignore", "pipe", "pipe"],
140
- encoding: "utf8",
141
- env: { ...process.env, GAIA_CLI_PATH_DIR: binDir },
142
- });
118
+ function ensureWindowsPathConfigured(binDir, options = {}) {
119
+ const platform = options.platform || process.platform;
120
+ const spawn = options.spawnSync || spawnSync;
121
+ if (!binDir || platform !== 'win32') return null;
122
+ const command = [
123
+ "$dir = $env:GAIA_CLI_PATH_DIR",
124
+ "$current = [Environment]::GetEnvironmentVariable('Path', 'User')",
125
+ "if (-not $current) { $current = '' }",
126
+ "$parts = $current -split ';' | Where-Object { $_ }",
127
+ "$normalize = { param($value) [Environment]::ExpandEnvironmentVariables($value.Trim().Trim([char]34).TrimEnd([char[]]'\\/')) }",
128
+ "$target = & $normalize $dir",
129
+ "$exists = @($parts | Where-Object { (& $normalize $_) -ieq $target }).Count -gt 0",
130
+ "if (-not $exists) {",
131
+ " $next = (@($dir) + $parts) -join ';'",
132
+ " [Environment]::SetEnvironmentVariable('Path', $next, 'User')",
133
+ " Write-Output '[gaia-cli:path-updated]'",
134
+ "} else {",
135
+ " Write-Output '[gaia-cli:path-unchanged]'",
136
+ "}",
137
+ ].join("; ");
138
+ const result = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], {
139
+ stdio: ["ignore", "pipe", "pipe"],
140
+ encoding: "utf8",
141
+ env: { ...process.env, GAIA_CLI_PATH_DIR: binDir },
142
+ });
143
143
  if (result.error || result.status !== 0) {
144
- const detail = result.error ? result.error.message : `${result.stdout || ""}${result.stderr || ""}`.trim();
145
- throw new Error(`Failed to update user PATH: ${detail}`);
146
- }
147
- return (result.stdout || '').includes('[gaia-cli:path-updated]') ? 'Windows user PATH' : null;
144
+ const detail = result.error ? result.error.message : `${result.stdout || ""}${result.stderr || ""}`.trim();
145
+ throw new Error(`Failed to update user PATH: ${detail}`);
146
+ }
147
+ return (result.stdout || '').includes('[gaia-cli:path-updated]') ? 'Windows user PATH' : null;
148
148
  }
149
149
 
150
150
  function pathExportBlock(binDir) {
151
151
  return `${shellPathMarker}\nexport PATH="${binDir}:$PATH"\n`;
152
152
  }
153
153
 
154
- function ensurePathConfigured(binDir, profilePath = shellProfilePath(), platform = process.platform) {
155
- if (!binDir) return null;
156
- if (platform === 'win32') {
157
- return ensureWindowsPathConfigured(binDir);
158
- }
159
- if (!profilePath) return null;
160
- const existing = fs.existsSync(profilePath) ? fs.readFileSync(profilePath, 'utf8') : '';
161
- if (existing.includes(binDir)) return null;
162
- const prefix = existing && !existing.endsWith('\n') ? '\n' : '';
163
- fs.appendFileSync(profilePath, `${prefix}${pathExportBlock(binDir)}`);
164
- return profilePath;
165
- }
154
+ function ensurePathConfigured(binDir, profilePath = shellProfilePath(), platform = process.platform) {
155
+ if (!binDir) return null;
156
+ if (platform === 'win32') {
157
+ return ensureWindowsPathConfigured(binDir);
158
+ }
159
+ if (!profilePath) return null;
160
+ const existing = fs.existsSync(profilePath) ? fs.readFileSync(profilePath, 'utf8') : '';
161
+ if (existing.includes(binDir)) return null;
162
+ const prefix = existing && !existing.endsWith('\n') ? '\n' : '';
163
+ fs.appendFileSync(profilePath, `${prefix}${pathExportBlock(binDir)}`);
164
+ return profilePath;
165
+ }
166
166
 
167
167
  function ensureLocalBinary() {
168
168
  if (fs.existsSync(binaryPath)) return;
@@ -180,17 +180,17 @@ function installWizard(args) {
180
180
  run(npm.command, npm.args);
181
181
  const globalBinDir = npmGlobalBinDir();
182
182
  const setupCommand = setupCommandPath(binaryPath);
183
- console.error('[gaia-cli] 正在安装 Gaia 内置 Skill: gaia-shared, gaia-skill-maker...');
183
+ console.error('[gaia-cli] 正在安装 Gaia 内置 Skill: gaia-shared, gaia-skill-maker...');
184
184
  try {
185
185
  run(setupCommand, ['setup', '--mode', mode], { stdio: 'ignore' });
186
186
  } catch (error) {
187
- console.error('[gaia-cli] Gaia 内置 Skill 安装失败。');
187
+ console.error('[gaia-cli] Gaia 内置 Skill 安装失败。');
188
188
  throw error;
189
189
  }
190
- console.error('[gaia-cli] ✓ Gaia 内置 Skill 安装完成。');
190
+ console.error('[gaia-cli] ✓ Gaia 内置 Skill 安装完成。');
191
191
  const profilePath = ensurePathConfigured(globalBinDir);
192
192
  const suffix = explicitMode ? `当前模式: ${mode}。` : '';
193
- if (profilePath && globalBinDir) {
193
+ if (profilePath && globalBinDir) {
194
194
  console.error(`[gaia-cli] 安装完成,${suffix}已更新 PATH 配置: ${profilePath}`);
195
195
  console.error(`[gaia-cli] 重新打开终端后可以执行: gaia version`);
196
196
  return;