@sokeai/cli 1.0.117 → 1.0.119
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 +2 -0
- package/docs/harmonyos.md +67 -0
- package/package.json +4 -1
- package/scripts/install.js +7 -21
- package/scripts/runtime-platform.js +32 -0
- package/skills/multi/demo-init-4.1.0.zip +0 -0
- package/skills/multi/demo-init-4.1.1.zip +0 -0
- package/skills/multi/demo-init-4.1.2.zip +0 -0
- package/skills/multi/demo-init-4.1.3.zip +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 鸿蒙电脑版原生 ARM64 CLI
|
|
2
|
+
|
|
3
|
+
从 `1.0.118` 起增加 `openharmony/arm64` 原生构建、npm 平台识别和可选发布链路。当前仅完成交叉编译与静态产物检查,尚未在鸿蒙电脑上验收,属于实验性支持。npm `1.0.117` 及更早版本不包含本次适配。
|
|
4
|
+
|
|
5
|
+
## 构建
|
|
6
|
+
|
|
7
|
+
标准 Go 没有 `openharmony` 目标,需要专用工具链及鸿蒙 Native SDK。本次实际使用:
|
|
8
|
+
|
|
9
|
+
- Go 工具链:[sysit/ohos-go](https://github.com/sysit/ohos-go),`release-branch.go1.26`,固定提交 `19667c7abfc332f848b5bd1f293e4aeb0e9991a9`,版本 `go1.26.5`。这是社区工具链;构建环境应固定提交,不自动拉取最新版本。
|
|
10
|
+
- DevEco Studio Native SDK `6.0.2.130`,API 22。
|
|
11
|
+
|
|
12
|
+
工具链可在独立目录从固定提交编译(宿主需要已有 Go 和 C 编译器):
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/sysit/ohos-go.git /path/to/ohos-go
|
|
16
|
+
git -C /path/to/ohos-go checkout 19667c7abfc332f848b5bd1f293e4aeb0e9991a9
|
|
17
|
+
cd /path/to/ohos-go/src
|
|
18
|
+
GOROOT_BOOTSTRAP=/path/to/host-go GOTOOLCHAIN=local bash make.bash
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
回到 soke-cli 仓库执行:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
HARMONY_GO=/path/to/ohos-go/bin/go \
|
|
25
|
+
OHOS_NATIVE_SDK=/path/to/sdk/openharmony/native \
|
|
26
|
+
npm run build:harmony
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
产物:`bin/soke-cli-openharmony-arm64` 和同名 `.sha256` 文件。构建固定注入 `app.pro.yaml` 与包版本,使用 `GOOS=openharmony`、`GOARCH=arm64`、SDK clang 及外部 PIE 链接。脚本检查鸿蒙加载器 `/system/lib/ld-musl-aarch64.so.1`,拒绝普通 Go 工具链和错误的 SDK。该二进制依赖鸿蒙系统的 `libc.so`,不能在 macOS 或普通 Linux 上直接验收。
|
|
30
|
+
|
|
31
|
+
macOS 上默认 SDK 路径是 `/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native`,可通过 `OHOS_NATIVE_SDK` 覆盖。
|
|
32
|
+
|
|
33
|
+
## 原生终端安装
|
|
34
|
+
|
|
35
|
+
无需 Node.js 时,下载 [1.0.118 鸿蒙 ARM64 二进制](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.118/soke-cli-openharmony-arm64),并用同目录的 [checksums.txt](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.118/checksums.txt) 验证 SHA-256。将产物复制到鸿蒙电脑上允许执行程序的目录,在该目录中运行:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
chmod +x ./soke-cli-openharmony-arm64
|
|
39
|
+
./soke-cli-openharmony-arm64 --version
|
|
40
|
+
./soke-cli-openharmony-arm64 --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
可将文件命名为 `soke-cli`,放入终端的用户 PATH 目录。不同终端的文件权限和沙箱规则可能不同;如果出现执行权限或代码签名错误,需要按该终端的规则安装,不能仅靠 `chmod` 保证可执行。
|
|
44
|
+
|
|
45
|
+
如果已安装支持鸿蒙的 Node.js/npm,可运行 `npm install -g @sokeai/cli@1.0.118`。安装器识别 `openharmony`、`ohos`、`harmonyos` 平台名;对报告为 `linux` 的 Node,仅在系统名或鸿蒙加载器存在时选择鸿蒙包。普通 Linux ARM64 不会被自动当作鸿蒙。
|
|
46
|
+
|
|
47
|
+
## 真机验收
|
|
48
|
+
|
|
49
|
+
1. 确认 `--version`、`--help` 能正常退出;运行 `doctor --offline`,检查输出(尚未配置或登录时可能报告检查失败)。
|
|
50
|
+
2. 运行 `auth login`,手动在**同一台鸿蒙电脑**的浏览器中打开终端显示的授权链接,确认本机回调可达,并验证 `auth status`。
|
|
51
|
+
3. 重新启动 CLI,确认登录凭证可读取;鸿蒙使用兼容 Linux 的加密文件存储,不依赖 macOS 钥匙串或桌面 D-Bus。
|
|
52
|
+
4. 调用一个有权限的只读业务接口,验证 DNS、HTTPS 证书和 JSON 输出;再验证登录退出及凭证清理。
|
|
53
|
+
|
|
54
|
+
浏览器自动唤起暂未适配,CLI 会提示手动访问授权链接。若系统证书目录没有被工具链识别,应将 `SSL_CERT_DIR` 指向系统可信 PEM 证书目录,或将 `SSL_CERT_FILE` 指向可信 CA bundle 后重试;保持 TLS 校验开启。
|
|
55
|
+
|
|
56
|
+
需要保留的验收信息:HarmonyOS 版本、电脑架构、终端名称、Node 的 `process.platform` / `process.arch`(使用 npm 时),以及上述检查结果。当前没有连接的鸿蒙设备,不能据交叉编译成功声明真机兼容。
|
|
57
|
+
|
|
58
|
+
## 纳入正式发布
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
BUILD_HARMONY=true \
|
|
62
|
+
HARMONY_GO=/path/to/ohos-go/bin/go \
|
|
63
|
+
OHOS_NATIVE_SDK=/path/to/sdk/openharmony/native \
|
|
64
|
+
npm run release
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`BUILD_HARMONY=true` 同时启用构建和发布清单,确保鸿蒙二进制进入统一 `checksums.txt`、OSS 上传和 CDN 预热。未设置时保持原有四平台发布。完成真机验收前,鸿蒙目标保持实验性支持标记。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sokeai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.119",
|
|
4
4
|
"description": "授客AI官方CLI工具 - 支持AI Agent Skills",
|
|
5
5
|
"bin": {
|
|
6
6
|
"soke-cli": "scripts/run.js"
|
|
@@ -8,11 +8,14 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"postinstall": "node scripts/install.js",
|
|
10
10
|
"build": "./scripts/build-binaries.sh",
|
|
11
|
+
"build:harmony": "bash ./scripts/build-harmony.sh",
|
|
11
12
|
"release": "./scripts/release.sh"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"scripts/install.js",
|
|
15
16
|
"scripts/run.js",
|
|
17
|
+
"scripts/runtime-platform.js",
|
|
18
|
+
"docs/harmonyos.md",
|
|
16
19
|
"skills/"
|
|
17
20
|
],
|
|
18
21
|
"homepage": "https://github.com/sokeai/soke-cli#readme",
|
package/scripts/install.js
CHANGED
|
@@ -5,9 +5,9 @@ const https = require('https');
|
|
|
5
5
|
const crypto = require('crypto');
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
7
|
const readline = require('readline');
|
|
8
|
+
const { resolveRuntimePlatform } = require('./runtime-platform');
|
|
8
9
|
|
|
9
10
|
const platform = os.platform();
|
|
10
|
-
const arch = os.arch();
|
|
11
11
|
const version = require('../package.json').version;
|
|
12
12
|
|
|
13
13
|
function copyDirRecursive(srcDir, destDir) {
|
|
@@ -448,29 +448,15 @@ async function maybeAssistGuiPath() {
|
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
const archMap = {
|
|
459
|
-
'x64': 'amd64',
|
|
460
|
-
'arm64': 'arm64'
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const mappedPlatform = platformMap[platform];
|
|
464
|
-
const mappedArch = archMap[arch];
|
|
465
|
-
|
|
466
|
-
if (!mappedPlatform || !mappedArch) {
|
|
467
|
-
console.error(`不支持的平台: ${platform}-${arch}`);
|
|
468
|
-
console.error('支持的平台: darwin-x64, darwin-arm64, linux-x64, windows-x64');
|
|
451
|
+
let runtimeTarget;
|
|
452
|
+
try {
|
|
453
|
+
runtimeTarget = resolveRuntimePlatform();
|
|
454
|
+
} catch (err) {
|
|
455
|
+
console.error(err.message);
|
|
469
456
|
process.exit(1);
|
|
470
457
|
}
|
|
471
458
|
|
|
472
|
-
const
|
|
473
|
-
const binaryFileName = `soke-cli-${mappedPlatform}-${mappedArch}${platform === 'win32' ? '.exe' : ''}`;
|
|
459
|
+
const { platform: mappedPlatform, arch: mappedArch, binaryName, binaryFileName } = runtimeTarget;
|
|
474
460
|
|
|
475
461
|
// 默认 CDN 二进制源。用户安装时会优先从这里下载,失败后回退 GitHub Releases。
|
|
476
462
|
const DEFAULT_BINARY_HOST = 'https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
|
|
4
|
+
// 鸿蒙版 Node 可能报告 openharmony、ohos,或兼容的 linux 平台名。
|
|
5
|
+
function resolveRuntimePlatform(platform = os.platform(), arch = os.arch(), system = os.type()) {
|
|
6
|
+
let target = platform;
|
|
7
|
+
if (['openharmony', 'ohos', 'harmonyos'].includes(platform) ||
|
|
8
|
+
(platform === 'linux' && (/^(openharmony|harmonyos)$/i.test(system) ||
|
|
9
|
+
fs.existsSync('/system/lib/ld-musl-aarch64.so.1')))) {
|
|
10
|
+
target = 'openharmony';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const targets = {
|
|
14
|
+
darwin: { x64: 'amd64', arm64: 'arm64' },
|
|
15
|
+
linux: { x64: 'amd64' },
|
|
16
|
+
win32: { x64: 'amd64' },
|
|
17
|
+
openharmony: { arm64: 'arm64' }
|
|
18
|
+
};
|
|
19
|
+
const mappedArch = targets[target] && targets[target][arch];
|
|
20
|
+
if (!mappedArch) {
|
|
21
|
+
throw new Error(`不支持的平台: ${platform}-${arch};支持 macOS x64/arm64、Linux x64、Windows x64、鸿蒙 ARM64`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
platform: target === 'win32' ? 'windows' : target,
|
|
26
|
+
arch: mappedArch,
|
|
27
|
+
binaryName: target === 'win32' ? 'soke-cli.exe' : 'soke-cli',
|
|
28
|
+
binaryFileName: `soke-cli-${target === 'win32' ? 'windows' : target}-${mappedArch}${target === 'win32' ? '.exe' : ''}`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { resolveRuntimePlatform };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|