@gaiaworks/gaia-cli 0.0.2 → 0.0.4
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 +3 -3
- package/package.json +2 -2
- package/scripts/install-wizard.js +16 -9
- package/scripts/install.js +4 -5
- package/scripts/run.js +0 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npx @gaiaworks/gaia-cli version
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npx @gaiaworks/gaia-cli@latest install
|
|
17
|
-
gaia
|
|
17
|
+
gaia version
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
安装模式:
|
|
@@ -25,6 +25,6 @@ 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
|
|
28
|
+
未指定 `--mode` 时默认写入 `external`。安装脚本会执行 `gaia setup --mode <external|internal>`,用于初始化本地 `install_mode` 和 Agent Skills。
|
|
29
29
|
|
|
30
|
-
安装时会根据 npm 包版本,从
|
|
30
|
+
安装时会根据 npm 包版本,从 OSS 的同版本目录下载当前平台对应的 `gaia-cli` 二进制。
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaiaworks/gaia-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "JavaScript launcher for gaia-cli.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"bin": {
|
|
8
|
-
"gaia
|
|
8
|
+
"gaia": "scripts/run.js"
|
|
9
9
|
},
|
|
10
10
|
"os": [
|
|
11
11
|
"darwin",
|
|
@@ -12,6 +12,7 @@ const binaryPath = path.join(__dirname, '..', 'bin', binaryName());
|
|
|
12
12
|
|
|
13
13
|
function parseInstallArgs(args) {
|
|
14
14
|
let mode = 'external';
|
|
15
|
+
let explicitMode = false;
|
|
15
16
|
const npmArgs = [];
|
|
16
17
|
|
|
17
18
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -19,29 +20,31 @@ function parseInstallArgs(args) {
|
|
|
19
20
|
if (arg === '--mode') {
|
|
20
21
|
const value = args[i + 1];
|
|
21
22
|
if (!value) {
|
|
22
|
-
throw new Error('--mode requires a value:
|
|
23
|
+
throw new Error('--mode requires a value: external or internal');
|
|
23
24
|
}
|
|
24
25
|
mode = value;
|
|
26
|
+
explicitMode = true;
|
|
25
27
|
i += 1;
|
|
26
28
|
continue;
|
|
27
29
|
}
|
|
28
30
|
if (arg.startsWith('--mode=')) {
|
|
29
31
|
mode = arg.slice('--mode='.length);
|
|
32
|
+
explicitMode = true;
|
|
30
33
|
continue;
|
|
31
34
|
}
|
|
32
35
|
npmArgs.push(arg);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
if (mode !== '
|
|
36
|
-
throw new Error(`Unsupported mode: ${mode}. Expected
|
|
38
|
+
if (mode !== 'external' && mode !== 'internal') {
|
|
39
|
+
throw new Error(`Unsupported mode: ${mode}. Expected external or internal.`);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
return { mode, npmArgs };
|
|
42
|
+
return { explicitMode, mode, npmArgs };
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
function run(command, args) {
|
|
45
|
+
function run(command, args, options = {}) {
|
|
43
46
|
const result = spawnSync(command, args, {
|
|
44
|
-
stdio: 'inherit',
|
|
47
|
+
stdio: options.stdio || 'inherit',
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
if (result.error) {
|
|
@@ -60,15 +63,19 @@ function ensureLocalBinary() {
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
function installWizard(args) {
|
|
63
|
-
const { mode, npmArgs } = parseInstallArgs(args);
|
|
66
|
+
const { explicitMode, mode, npmArgs } = parseInstallArgs(args);
|
|
64
67
|
if (npmArgs.length > 0) {
|
|
65
68
|
throw new Error(`Unsupported install arguments: ${npmArgs.join(' ')}`);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
ensureLocalBinary();
|
|
69
72
|
run('npm', ['install', '-g', packageSpec]);
|
|
70
|
-
run(binaryPath, ['
|
|
71
|
-
|
|
73
|
+
run(binaryPath, ['setup', '--mode', mode], { stdio: 'ignore' });
|
|
74
|
+
if (explicitMode) {
|
|
75
|
+
console.error(`[gaia-cli] 安装完成,当前模式: ${mode}。可以执行: gaia version`);
|
|
76
|
+
} else {
|
|
77
|
+
console.error('[gaia-cli] 安装完成。可以执行: gaia version');
|
|
78
|
+
}
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
if (require.main === module) {
|
package/scripts/install.js
CHANGED
|
@@ -9,11 +9,10 @@ const { spawnSync } = require('child_process');
|
|
|
9
9
|
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
10
10
|
const PACKAGE_JSON = path.join(PACKAGE_ROOT, 'package.json');
|
|
11
11
|
const BIN_DIR = path.join(PACKAGE_ROOT, 'bin');
|
|
12
|
-
const
|
|
13
|
-
const DOWNLOAD_BASE = process.env.GAIA_CLI_DOWNLOAD_BASE || `https://github.com/${RELEASE_REPO}/releases/download`;
|
|
12
|
+
const DOWNLOAD_BASE = process.env.GAIA_CLI_DOWNLOAD_BASE || 'https://assets.gaiaworkforce.com/gaia-cli/releases';
|
|
14
13
|
const ALLOWED_DOWNLOAD_HOSTS = new Set([
|
|
15
|
-
'
|
|
16
|
-
'
|
|
14
|
+
'assets.gaiaworkforce.com',
|
|
15
|
+
'gaiafe.oss-cn-shanghai.aliyuncs.com',
|
|
17
16
|
]);
|
|
18
17
|
|
|
19
18
|
function readPackageVersion() {
|
|
@@ -158,7 +157,7 @@ if (require.main === module) {
|
|
|
158
157
|
install();
|
|
159
158
|
} catch (error) {
|
|
160
159
|
console.error(`[gaia-cli] Failed to install binary: ${error.message}`);
|
|
161
|
-
console.error('[gaia-cli] Please check network access to
|
|
160
|
+
console.error('[gaia-cli] Please check network access to OSS assets or contact the administrator.');
|
|
162
161
|
process.exit(1);
|
|
163
162
|
}
|
|
164
163
|
}
|
package/scripts/run.js
CHANGED
|
File without changes
|