@kg-ai/kugou-skill 0.1.2 → 0.1.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 +139 -139
- package/SKILL.md +2 -0
- package/bin/darwin-arm64/kugou-cli +0 -0
- package/bin/darwin-x64/kugou-cli +0 -0
- package/bin/kugou-cli.exe +0 -0
- package/bin/linux-arm64/kugou-cli +0 -0
- package/bin/linux-x64/kugou-cli +0 -0
- package/bin/win32-x64/kugou-cli.exe +0 -0
- package/package.json +1 -1
- package/references/auth.md +30 -1
- package/references/error-handling.md +2 -1
- package/references/install.md +54 -54
- package/references/music.md +323 -323
- package/references/output-format.md +42 -42
- package/references/update.md +128 -128
- package/scripts/build-all.js +52 -52
- package/scripts/pack.js +67 -67
- package/scripts/run.js +21 -21
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# 输出格式与展示规范
|
|
2
|
-
|
|
3
|
-
## 通用响应结构
|
|
4
|
-
|
|
5
|
-
所有 API 命令输出标准 JSON 结构:
|
|
6
|
-
|
|
7
|
-
```json
|
|
8
|
-
{
|
|
9
|
-
"errcode": 0,
|
|
10
|
-
"errmsg": "",
|
|
11
|
-
"data": { ... },
|
|
12
|
-
"status": 1
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
**响应状态**:
|
|
17
|
-
- `errcode: 0` 表示成功
|
|
18
|
-
- `data` 包含实际业务数据
|
|
19
|
-
- `status: 1` 表示接口调用成功
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 展示规范
|
|
24
|
-
|
|
25
|
-
向用户展示结果时,**必须遵循以下规范**:
|
|
26
|
-
|
|
27
|
-
### 1. 歌曲列表展示(强制要求)
|
|
28
|
-
|
|
29
|
-
- **禁止**只返回歌曲名、歌手名
|
|
30
|
-
- **必须**以 Markdown 链接格式展示播放链接
|
|
31
|
-
- 正确格式:`[歌曲名 - 歌手名](https://www.kugou.com/...)`
|
|
32
|
-
- 禁止格式:`晴天 - 周杰伦`(无链接)、`歌曲名: 晴天, 歌手: 周杰伦`(无链接)
|
|
33
|
-
|
|
34
|
-
### 2. 统计数据
|
|
35
|
-
|
|
36
|
-
提取关键字段并以结构化方式呈现(如"累计听歌 342 首,时长 22.4 小时")
|
|
37
|
-
|
|
38
|
-
### 3. 二维码
|
|
39
|
-
|
|
40
|
-
使用 `qrcode_img_path` 对应的图片文件发送给用户
|
|
41
|
-
|
|
42
|
-
---
|
|
1
|
+
# 输出格式与展示规范
|
|
2
|
+
|
|
3
|
+
## 通用响应结构
|
|
4
|
+
|
|
5
|
+
所有 API 命令输出标准 JSON 结构:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"errcode": 0,
|
|
10
|
+
"errmsg": "",
|
|
11
|
+
"data": { ... },
|
|
12
|
+
"status": 1
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**响应状态**:
|
|
17
|
+
- `errcode: 0` 表示成功
|
|
18
|
+
- `data` 包含实际业务数据
|
|
19
|
+
- `status: 1` 表示接口调用成功
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 展示规范
|
|
24
|
+
|
|
25
|
+
向用户展示结果时,**必须遵循以下规范**:
|
|
26
|
+
|
|
27
|
+
### 1. 歌曲列表展示(强制要求)
|
|
28
|
+
|
|
29
|
+
- **禁止**只返回歌曲名、歌手名
|
|
30
|
+
- **必须**以 Markdown 链接格式展示播放链接
|
|
31
|
+
- 正确格式:`[歌曲名 - 歌手名](https://www.kugou.com/...)`
|
|
32
|
+
- 禁止格式:`晴天 - 周杰伦`(无链接)、`歌曲名: 晴天, 歌手: 周杰伦`(无链接)
|
|
33
|
+
|
|
34
|
+
### 2. 统计数据
|
|
35
|
+
|
|
36
|
+
提取关键字段并以结构化方式呈现(如"累计听歌 342 首,时长 22.4 小时")
|
|
37
|
+
|
|
38
|
+
### 3. 二维码
|
|
39
|
+
|
|
40
|
+
使用 `qrcode_img_path` 对应的图片文件发送给用户
|
|
41
|
+
|
|
42
|
+
---
|
package/references/update.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# 更新命令 (update)
|
|
2
|
-
|
|
3
|
-
> 自动检查并更新 kugou-cli
|
|
4
|
-
|
|
5
|
-
## 命令
|
|
6
|
-
|
|
7
|
-
| 命令 | 说明 |
|
|
8
|
-
|------|------|
|
|
9
|
-
| `kugou-cli update --check` | 仅检查更新,不执行 |
|
|
10
|
-
| `kugou-cli update` | 检查并提示(不自动执行) |
|
|
11
|
-
| `kugou-cli update --force` | 直接执行更新(仅 npm 安装) |
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 工作机制
|
|
16
|
-
|
|
17
|
-
### 1. 启动时检查
|
|
18
|
-
|
|
19
|
-
每次执行任意 `kugou-cli` 命令时,**后台异步**检查 npm registry 上的最新版本。
|
|
20
|
-
|
|
21
|
-
- **不阻塞** 主命令
|
|
22
|
-
- 有更新时输出到 **stderr**(避免污染 stdout JSON 输出)
|
|
23
|
-
- 提示格式:
|
|
24
|
-
```
|
|
25
|
-
[kugou-cli] update available: 0.0.22 → 0.0.23 (run `kugou-cli update` to upgrade)
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### 2. 检查频率限制
|
|
29
|
-
|
|
30
|
-
- 缓存文件:`~/.config/kugou-cli/update_check.json`
|
|
31
|
-
- 缓存有效期:**24 小时**
|
|
32
|
-
- 24 小时内不会重复访问 npm registry
|
|
33
|
-
|
|
34
|
-
### 3. 跳过检查
|
|
35
|
-
|
|
36
|
-
在以下情况跳过启动检查:
|
|
37
|
-
- `CI=true` 环境变量
|
|
38
|
-
- `KUGOU_CLI_NO_UPDATE_CHECK=1` 环境变量
|
|
39
|
-
- 命令行指定 `--no-update-check` flag
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 显式检查更新
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
kugou-cli update --check
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**输出示例**:
|
|
50
|
-
|
|
51
|
-
有更新时:
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"current_version": "0.0.22",
|
|
55
|
-
"latest_version": "0.0.23",
|
|
56
|
-
"update_available": true,
|
|
57
|
-
"install_method": "npm",
|
|
58
|
-
"update_command": "npm install -g @kg-ai/kugou-skill@latest"
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
无更新时:
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"current_version": "0.0.22",
|
|
66
|
-
"latest_version": "0.0.22",
|
|
67
|
-
"update_available": false,
|
|
68
|
-
"install_method": "npm"
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## 执行更新
|
|
75
|
-
|
|
76
|
-
### 方式 1:Agent / 脚本(推荐)
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# 步骤 1: 检查
|
|
80
|
-
info=$(kugou-cli update --check)
|
|
81
|
-
update_available=$(echo "$info" | jq -r '.update_available')
|
|
82
|
-
|
|
83
|
-
# 步骤 2: 如果有更新,提示用户确认后执行
|
|
84
|
-
if [ "$update_available" = "true" ]; then
|
|
85
|
-
echo "有可用更新,正在升级..."
|
|
86
|
-
kugou-cli update --force
|
|
87
|
-
fi
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 方式 2:手动
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
# 提示但不执行
|
|
94
|
-
kugou-cli update
|
|
95
|
-
# 显示: About to run: npm install -g @kg-ai/kugou-skill@latest
|
|
96
|
-
|
|
97
|
-
# 强制执行
|
|
98
|
-
kugou-cli update --force
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### 方式 3:标准 npm 命令
|
|
102
|
-
|
|
103
|
-
无需 `update` 子命令,直接:
|
|
104
|
-
```bash
|
|
105
|
-
npm install -g @kg-ai/kugou-skill@latest
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## 安装方式检测
|
|
111
|
-
|
|
112
|
-
CLI 自动检测安装方式:
|
|
113
|
-
|
|
114
|
-
| 安装方式 | 检测方法 | 是否支持自动更新 |
|
|
115
|
-
|---------|---------|------------------|
|
|
116
|
-
| **npm** | 二进制路径包含 `node_modules/@kg-ai/kugou-skill` | ✅ 支持 |
|
|
117
|
-
| **其他**(源码编译 / 手动下载) | 其他路径 | ❌ 仅提示 |
|
|
118
|
-
|
|
119
|
-
非 npm 安装时,CLI 只会提示,不会自动更新。请使用对应方式更新。
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## 注意事项
|
|
124
|
-
|
|
125
|
-
1. **网络要求**:检查更新需要访问 `https://registry.npmjs.org`,在受限网络下可能失败
|
|
126
|
-
2. **离线友好**:网络失败时静默忽略,不影响主命令
|
|
127
|
-
3. **CI 友好**:CI 环境默认跳过检查,避免污染日志
|
|
128
|
-
4. **不强制**:默认仅提示,更新需用户/Agent 显式确认
|
|
1
|
+
# 更新命令 (update)
|
|
2
|
+
|
|
3
|
+
> 自动检查并更新 kugou-cli
|
|
4
|
+
|
|
5
|
+
## 命令
|
|
6
|
+
|
|
7
|
+
| 命令 | 说明 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| `kugou-cli update --check` | 仅检查更新,不执行 |
|
|
10
|
+
| `kugou-cli update` | 检查并提示(不自动执行) |
|
|
11
|
+
| `kugou-cli update --force` | 直接执行更新(仅 npm 安装) |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 工作机制
|
|
16
|
+
|
|
17
|
+
### 1. 启动时检查
|
|
18
|
+
|
|
19
|
+
每次执行任意 `kugou-cli` 命令时,**后台异步**检查 npm registry 上的最新版本。
|
|
20
|
+
|
|
21
|
+
- **不阻塞** 主命令
|
|
22
|
+
- 有更新时输出到 **stderr**(避免污染 stdout JSON 输出)
|
|
23
|
+
- 提示格式:
|
|
24
|
+
```
|
|
25
|
+
[kugou-cli] update available: 0.0.22 → 0.0.23 (run `kugou-cli update` to upgrade)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. 检查频率限制
|
|
29
|
+
|
|
30
|
+
- 缓存文件:`~/.config/kugou-cli/update_check.json`
|
|
31
|
+
- 缓存有效期:**24 小时**
|
|
32
|
+
- 24 小时内不会重复访问 npm registry
|
|
33
|
+
|
|
34
|
+
### 3. 跳过检查
|
|
35
|
+
|
|
36
|
+
在以下情况跳过启动检查:
|
|
37
|
+
- `CI=true` 环境变量
|
|
38
|
+
- `KUGOU_CLI_NO_UPDATE_CHECK=1` 环境变量
|
|
39
|
+
- 命令行指定 `--no-update-check` flag
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 显式检查更新
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
kugou-cli update --check
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**输出示例**:
|
|
50
|
+
|
|
51
|
+
有更新时:
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"current_version": "0.0.22",
|
|
55
|
+
"latest_version": "0.0.23",
|
|
56
|
+
"update_available": true,
|
|
57
|
+
"install_method": "npm",
|
|
58
|
+
"update_command": "npm install -g @kg-ai/kugou-skill@latest"
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
无更新时:
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"current_version": "0.0.22",
|
|
66
|
+
"latest_version": "0.0.22",
|
|
67
|
+
"update_available": false,
|
|
68
|
+
"install_method": "npm"
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 执行更新
|
|
75
|
+
|
|
76
|
+
### 方式 1:Agent / 脚本(推荐)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 步骤 1: 检查
|
|
80
|
+
info=$(kugou-cli update --check)
|
|
81
|
+
update_available=$(echo "$info" | jq -r '.update_available')
|
|
82
|
+
|
|
83
|
+
# 步骤 2: 如果有更新,提示用户确认后执行
|
|
84
|
+
if [ "$update_available" = "true" ]; then
|
|
85
|
+
echo "有可用更新,正在升级..."
|
|
86
|
+
kugou-cli update --force
|
|
87
|
+
fi
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 方式 2:手动
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 提示但不执行
|
|
94
|
+
kugou-cli update
|
|
95
|
+
# 显示: About to run: npm install -g @kg-ai/kugou-skill@latest
|
|
96
|
+
|
|
97
|
+
# 强制执行
|
|
98
|
+
kugou-cli update --force
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 方式 3:标准 npm 命令
|
|
102
|
+
|
|
103
|
+
无需 `update` 子命令,直接:
|
|
104
|
+
```bash
|
|
105
|
+
npm install -g @kg-ai/kugou-skill@latest
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 安装方式检测
|
|
111
|
+
|
|
112
|
+
CLI 自动检测安装方式:
|
|
113
|
+
|
|
114
|
+
| 安装方式 | 检测方法 | 是否支持自动更新 |
|
|
115
|
+
|---------|---------|------------------|
|
|
116
|
+
| **npm** | 二进制路径包含 `node_modules/@kg-ai/kugou-skill` | ✅ 支持 |
|
|
117
|
+
| **其他**(源码编译 / 手动下载) | 其他路径 | ❌ 仅提示 |
|
|
118
|
+
|
|
119
|
+
非 npm 安装时,CLI 只会提示,不会自动更新。请使用对应方式更新。
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 注意事项
|
|
124
|
+
|
|
125
|
+
1. **网络要求**:检查更新需要访问 `https://registry.npmjs.org`,在受限网络下可能失败
|
|
126
|
+
2. **离线友好**:网络失败时静默忽略,不影响主命令
|
|
127
|
+
3. **CI 友好**:CI 环境默认跳过检查,避免污染日志
|
|
128
|
+
4. **不强制**:默认仅提示,更新需用户/Agent 显式确认
|
package/scripts/build-all.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 构建所有平台二进制
|
|
4
|
-
* 使用方式: node scripts/build-all.js
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { execSync } = require('child_process');
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
const platforms = [
|
|
12
|
-
{ os: 'darwin', arch: 'arm64', name: 'darwin-arm64', exe: 'kugou-cli' },
|
|
13
|
-
{ os: 'darwin', arch: 'amd64', name: 'darwin-x64', exe: 'kugou-cli' },
|
|
14
|
-
{ os: 'linux', arch: 'arm64', name: 'linux-arm64', exe: 'kugou-cli' },
|
|
15
|
-
{ os: 'linux', arch: 'amd64', name: 'linux-x64', exe: 'kugou-cli' },
|
|
16
|
-
{ os: 'windows', arch: 'amd64', name: 'win32-x64', exe: 'kugou-cli.exe' },
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const binDir = path.join(__dirname, '..', 'bin');
|
|
20
|
-
|
|
21
|
-
console.log('=== Building all platforms ===\n');
|
|
22
|
-
|
|
23
|
-
// 清理平台目录
|
|
24
|
-
for (const p of platforms) {
|
|
25
|
-
const dir = path.join(binDir, p.name);
|
|
26
|
-
if (fs.existsSync(dir)) {
|
|
27
|
-
fs.rmSync(dir, { recursive: true });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 构建每个平台
|
|
32
|
-
for (const p of platforms) {
|
|
33
|
-
const outDir = path.join(binDir, p.name);
|
|
34
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
35
|
-
|
|
36
|
-
const outFile = path.join(outDir, p.exe);
|
|
37
|
-
console.log(`Building ${p.name}...`);
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
execSync(`go build -ldflags="-s -w" -o "${outFile}" .`, {
|
|
41
|
-
env: { ...process.env, GOOS: p.os, GOARCH: p.arch, CGO_ENABLED: '0' },
|
|
42
|
-
stdio: 'inherit',
|
|
43
|
-
});
|
|
44
|
-
console.log(`✅ Built: ${p.name}\n`);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error(`❌ Failed: ${p.name}\n`);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log('=== All platforms built successfully! ===');
|
|
52
|
-
console.log('\nRun: node scripts/pack.js');
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 构建所有平台二进制
|
|
4
|
+
* 使用方式: node scripts/build-all.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const platforms = [
|
|
12
|
+
{ os: 'darwin', arch: 'arm64', name: 'darwin-arm64', exe: 'kugou-cli' },
|
|
13
|
+
{ os: 'darwin', arch: 'amd64', name: 'darwin-x64', exe: 'kugou-cli' },
|
|
14
|
+
{ os: 'linux', arch: 'arm64', name: 'linux-arm64', exe: 'kugou-cli' },
|
|
15
|
+
{ os: 'linux', arch: 'amd64', name: 'linux-x64', exe: 'kugou-cli' },
|
|
16
|
+
{ os: 'windows', arch: 'amd64', name: 'win32-x64', exe: 'kugou-cli.exe' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
20
|
+
|
|
21
|
+
console.log('=== Building all platforms ===\n');
|
|
22
|
+
|
|
23
|
+
// 清理平台目录
|
|
24
|
+
for (const p of platforms) {
|
|
25
|
+
const dir = path.join(binDir, p.name);
|
|
26
|
+
if (fs.existsSync(dir)) {
|
|
27
|
+
fs.rmSync(dir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 构建每个平台
|
|
32
|
+
for (const p of platforms) {
|
|
33
|
+
const outDir = path.join(binDir, p.name);
|
|
34
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
35
|
+
|
|
36
|
+
const outFile = path.join(outDir, p.exe);
|
|
37
|
+
console.log(`Building ${p.name}...`);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
execSync(`go build -ldflags="-s -w" -o "${outFile}" .`, {
|
|
41
|
+
env: { ...process.env, GOOS: p.os, GOARCH: p.arch, CGO_ENABLED: '0' },
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
});
|
|
44
|
+
console.log(`✅ Built: ${p.name}\n`);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error(`❌ Failed: ${p.name}\n`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log('=== All platforms built successfully! ===');
|
|
52
|
+
console.log('\nRun: node scripts/pack.js');
|
package/scripts/pack.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 本地打包脚本
|
|
4
|
-
* 使用方式: node scripts/pack.js
|
|
5
|
-
*
|
|
6
|
-
* 发布流程:
|
|
7
|
-
* 1. 构建所有平台二进制到 bin/{platform}/
|
|
8
|
-
* 2. 运行 node scripts/pack.js
|
|
9
|
-
* 3. 运行 npm publish
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const fs = require('fs');
|
|
13
|
-
const path = require('path');
|
|
14
|
-
const pkgRoot = path.join(__dirname, '..');
|
|
15
|
-
|
|
16
|
-
// 检查必要文件
|
|
17
|
-
const requiredFiles = [
|
|
18
|
-
'package.json',
|
|
19
|
-
'SKILL.md',
|
|
20
|
-
'scripts/install.js',
|
|
21
|
-
'scripts/run.js'
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
// 检查平台二进制
|
|
25
|
-
const platforms = [
|
|
26
|
-
'darwin-arm64',
|
|
27
|
-
'darwin-x64',
|
|
28
|
-
'linux-arm64',
|
|
29
|
-
'linux-x64',
|
|
30
|
-
'win32-x64'
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
console.log('=== 检查必要文件 ===');
|
|
34
|
-
let hasError = false;
|
|
35
|
-
|
|
36
|
-
for (const file of requiredFiles) {
|
|
37
|
-
const filePath = path.join(pkgRoot, file);
|
|
38
|
-
if (fs.existsSync(filePath)) {
|
|
39
|
-
console.log(`✅ ${file}`);
|
|
40
|
-
} else {
|
|
41
|
-
console.log(`❌ ${file} - 缺失`);
|
|
42
|
-
hasError = true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log('\n=== 检查平台二进制 ===');
|
|
47
|
-
for (const platform of platforms) {
|
|
48
|
-
const exeName = platform.startsWith('win32') ? 'kugou-cli.exe' : 'kugou-cli';
|
|
49
|
-
const binPath = path.join(pkgRoot, 'bin', platform, exeName);
|
|
50
|
-
if (fs.existsSync(binPath)) {
|
|
51
|
-
const size = fs.statSync(binPath).size;
|
|
52
|
-
console.log(`✅ ${platform}: ${exeName} (${(size / 1024 / 1024).toFixed(2)} MB)`);
|
|
53
|
-
} else {
|
|
54
|
-
console.log(`❌ ${platform}: ${exeName} - 缺失`);
|
|
55
|
-
hasError = true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (hasError) {
|
|
60
|
-
console.log('\n❌ 打包检查失败,请确保所有文件都已构建');
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log('\n=== 构建完成 ===');
|
|
65
|
-
console.log('运行以下命令发布:');
|
|
66
|
-
console.log(' npm pack');
|
|
67
|
-
console.log(' npm publish --access public --scope=@kugouai');
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 本地打包脚本
|
|
4
|
+
* 使用方式: node scripts/pack.js
|
|
5
|
+
*
|
|
6
|
+
* 发布流程:
|
|
7
|
+
* 1. 构建所有平台二进制到 bin/{platform}/
|
|
8
|
+
* 2. 运行 node scripts/pack.js
|
|
9
|
+
* 3. 运行 npm publish
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const pkgRoot = path.join(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// 检查必要文件
|
|
17
|
+
const requiredFiles = [
|
|
18
|
+
'package.json',
|
|
19
|
+
'SKILL.md',
|
|
20
|
+
'scripts/install.js',
|
|
21
|
+
'scripts/run.js'
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// 检查平台二进制
|
|
25
|
+
const platforms = [
|
|
26
|
+
'darwin-arm64',
|
|
27
|
+
'darwin-x64',
|
|
28
|
+
'linux-arm64',
|
|
29
|
+
'linux-x64',
|
|
30
|
+
'win32-x64'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
console.log('=== 检查必要文件 ===');
|
|
34
|
+
let hasError = false;
|
|
35
|
+
|
|
36
|
+
for (const file of requiredFiles) {
|
|
37
|
+
const filePath = path.join(pkgRoot, file);
|
|
38
|
+
if (fs.existsSync(filePath)) {
|
|
39
|
+
console.log(`✅ ${file}`);
|
|
40
|
+
} else {
|
|
41
|
+
console.log(`❌ ${file} - 缺失`);
|
|
42
|
+
hasError = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log('\n=== 检查平台二进制 ===');
|
|
47
|
+
for (const platform of platforms) {
|
|
48
|
+
const exeName = platform.startsWith('win32') ? 'kugou-cli.exe' : 'kugou-cli';
|
|
49
|
+
const binPath = path.join(pkgRoot, 'bin', platform, exeName);
|
|
50
|
+
if (fs.existsSync(binPath)) {
|
|
51
|
+
const size = fs.statSync(binPath).size;
|
|
52
|
+
console.log(`✅ ${platform}: ${exeName} (${(size / 1024 / 1024).toFixed(2)} MB)`);
|
|
53
|
+
} else {
|
|
54
|
+
console.log(`❌ ${platform}: ${exeName} - 缺失`);
|
|
55
|
+
hasError = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (hasError) {
|
|
60
|
+
console.log('\n❌ 打包检查失败,请确保所有文件都已构建');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('\n=== 构建完成 ===');
|
|
65
|
+
console.log('运行以下命令发布:');
|
|
66
|
+
console.log(' npm pack');
|
|
67
|
+
console.log(' npm publish --access public --scope=@kugouai');
|
package/scripts/run.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require('child_process');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
// 获取当前平台对应的二进制路径
|
|
6
|
-
const platform = process.platform; // darwin, linux, win32
|
|
7
|
-
|
|
8
|
-
const binName = platform === 'win32' ? 'kugou-cli.exe' : 'kugou-cli';
|
|
9
|
-
// scripts/ 的父目录就是项目根目录,bin/ 在根目录下
|
|
10
|
-
// 使用简单名称,install.js 会复制对应平台的二进制到这里
|
|
11
|
-
const rootDir = path.join(__dirname, '..');
|
|
12
|
-
const binPath = path.join(rootDir, 'bin', binName);
|
|
13
|
-
|
|
14
|
-
const child = spawn(binPath, process.argv.slice(2), {
|
|
15
|
-
stdio: 'inherit',
|
|
16
|
-
shell: platform === 'win32'
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
child.on('exit', (code) => {
|
|
20
|
-
process.exit(code);
|
|
21
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// 获取当前平台对应的二进制路径
|
|
6
|
+
const platform = process.platform; // darwin, linux, win32
|
|
7
|
+
|
|
8
|
+
const binName = platform === 'win32' ? 'kugou-cli.exe' : 'kugou-cli';
|
|
9
|
+
// scripts/ 的父目录就是项目根目录,bin/ 在根目录下
|
|
10
|
+
// 使用简单名称,install.js 会复制对应平台的二进制到这里
|
|
11
|
+
const rootDir = path.join(__dirname, '..');
|
|
12
|
+
const binPath = path.join(rootDir, 'bin', binName);
|
|
13
|
+
|
|
14
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: platform === 'win32'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
child.on('exit', (code) => {
|
|
20
|
+
process.exit(code);
|
|
21
|
+
});
|