@kg-ai/kugou-skill 0.0.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 ADDED
@@ -0,0 +1,130 @@
1
+ # Kugou CLI
2
+
3
+ 酷狗音乐 API CLI 工具,用于搜索、推荐、收藏、统计、榜单等功能。
4
+
5
+ ## 安装
6
+
7
+ ### npm 安装(推荐)
8
+
9
+ ```bash
10
+ npm install -g @kg-ai/kugou-skill
11
+ ```
12
+
13
+ 安装后使用 `kugou-cli` 命令。npm 安装时会自动安装 SKILL.md 到各平台的 skills 目录。
14
+
15
+ ## 前置条件
16
+
17
+ 使用前需要扫码登录:
18
+
19
+ ```bash
20
+ kugou-cli auth login
21
+ ```
22
+
23
+ 登录后 token 会自动持久化存储。
24
+
25
+ ## 命令
26
+
27
+ ### 认证
28
+
29
+ ```bash
30
+ # 扫码登录(默认保存二维码图片到临时目录)
31
+ kugou-cli auth login
32
+
33
+ # 输出 base64 编码的二维码图片
34
+ kugou-cli auth login --output base64
35
+
36
+ # 打开系统图片查看器扫码
37
+ kugou-cli auth login --output terminal
38
+
39
+ # 查看登录状态
40
+ kugou-cli auth status
41
+
42
+ # 登出
43
+ kugou-cli auth logout
44
+ ```
45
+
46
+ ### 音乐
47
+
48
+ ```bash
49
+ # 搜索歌曲
50
+ kugou-cli music search "周杰伦"
51
+ kugou-cli music search "周杰伦" --page 1 --size 20
52
+
53
+ # 每日推荐
54
+ kugou-cli music recommend daily
55
+ kugou-cli music recommend daily --num 10
56
+
57
+ # 相似推荐(需要指定歌曲)
58
+ kugou-cli music recommend similar --song "晴天"
59
+ kugou-cli music recommend similar -s "晴天" -n 5
60
+
61
+ # 我的收藏
62
+ kugou-cli music favorites
63
+ kugou-cli music favorites --page 1 --size 20
64
+
65
+ # 最近播放
66
+ kugou-cli music recent
67
+ kugou-cli music recent --page 1 --size 20
68
+
69
+ # 听歌统计
70
+ kugou-cli music stats
71
+
72
+ # 酷狗榜单
73
+ kugou-cli music charts 6666 # 飙升榜
74
+ kugou-cli music charts 8888 # TOP500榜
75
+ kugou-cli music charts 52144 # 抖音热歌酷狗榜
76
+ kugou-cli music charts 90379 # 星耀星光榜
77
+ kugou-cli music charts 85432 # 百万收藏榜
78
+ kugou-cli music charts 74534 # 新歌榜
79
+ ```
80
+
81
+ ### 安装 SKILL.md
82
+
83
+ ```bash
84
+ # 安装到所有平台
85
+ kugou-cli install --all
86
+
87
+ # 安装到指定平台
88
+ kugou-cli install --claude
89
+ kugou-cli install --hermes --openclaw --codex
90
+ ```
91
+
92
+ ### 全局
93
+
94
+ ```bash
95
+ kugou-cli --version
96
+ kugou-cli --help
97
+ ```
98
+
99
+ ## 输出格式
100
+
101
+ 所有命令输出 JSON 格式,方便其他程序调用:
102
+
103
+ ```json
104
+ {
105
+ "errcode": 0,
106
+ "data": {
107
+ "list": [
108
+ {
109
+ "song_name": "晴天",
110
+ "mix_song_id": "32100650",
111
+ "artist_name": "周杰伦",
112
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/xxx.html"
113
+ }
114
+ ],
115
+ "total": 480,
116
+ "page": 1,
117
+ "size": 20
118
+ },
119
+ "status": 1
120
+ }
121
+ ```
122
+
123
+ ## 错误处理
124
+
125
+ 错误信息输出到 stderr,程序 exit code 为 1:
126
+
127
+ ```bash
128
+ kugou-cli music search "xxx" 2>&1
129
+ echo $? # 非 0 表示出错
130
+ ```
package/SKILL.md ADDED
@@ -0,0 +1,369 @@
1
+ ---
2
+ name: kugou-skill
3
+ description: |
4
+ kugou-skill 是酷狗音乐 API CLI 工具,用于搜索、推荐、收藏、统计、榜单等功能。
5
+ 触发场景:用户要求搜索歌曲、获取推荐、管理收藏、查看听歌统计、查看榜单等酷狗音乐相关操作。
6
+ 安装方式:npm install -g @kg-ai/kugou-skill
7
+ ---
8
+
9
+ # kugou-skill
10
+
11
+ ## 基础信息
12
+
13
+ - **npm 包**: @kg-ai/kugou-skill
14
+ - **二进制命令**: kugou-cli
15
+ - **API 域名**: https://agentgateway.kugou.com(固定,无需配置)
16
+ - **安装方式**: `npm install -g @kg-ai/kugou-skill`
17
+
18
+ ## 前置条件
19
+
20
+ 使用前需要扫码登录:
21
+ ```bash
22
+ kugou-cli auth login
23
+ ```
24
+ 登录后 token 会自动持久化存储。
25
+
26
+ ## 命令列表
27
+
28
+ ### 认证命令 (auth)
29
+
30
+ | 命令 | 说明 |
31
+ |------|------|
32
+ | `kugou-cli auth login` | 扫码登录(返回二维码信息) |
33
+ | `kugou-cli auth status` | 查看登录状态 |
34
+ | `kugou-cli auth logout` | 登出 |
35
+
36
+ ### 音乐命令 (music)
37
+
38
+ | 命令 | 说明 |
39
+ |------|------|
40
+ | `kugou-cli music search <keyword>` | 搜索歌曲 |
41
+ | `kugou-cli music recommend daily` | 每日推荐 |
42
+ | `kugou-cli music recommend similar -s <song>` | 相似歌曲推荐 |
43
+ | `kugou-cli music favorites` | 我的收藏 |
44
+ | `kugou-cli music recent` | 最近播放 |
45
+ | `kugou-cli music stats` | 听歌统计 |
46
+ | `kugou-cli music charts <rank_id>` | 榜单 |
47
+
48
+ ### 安装命令 (install)
49
+
50
+ | 命令 | 说明 |
51
+ |------|------|
52
+ | `kugou-cli install` | 显示帮助信息 |
53
+ | `kugou-cli install --all` | 安装 SKILL.md 到所有平台 |
54
+ | `kugou-cli install --claude` | 安装到 Claude skills 目录 |
55
+ | `kugou-cli install --hermes` | 安装到 Hermes skills 目录 |
56
+ | `kugou-cli install --openclaw` | 安装到 Openclaw skills 目录 |
57
+ | `kugou-cli install --codex` | 安装到 Codex skills 目录 |
58
+
59
+ ---
60
+
61
+ ## 详细用法
62
+
63
+ ### 1. 扫码登录
64
+
65
+ ```bash
66
+ kugou-cli auth login
67
+ kugou-cli auth login --output image # 默认,保存二维码图片到临时目录
68
+ kugou-cli auth login --output base64 # 输出 base64 编码的图片数据(含 data:image/png;base64, 前缀)
69
+ kugou-cli auth login --output terminal # 打开图片查看器扫码(Windows/macOS/Linux)
70
+ ```
71
+
72
+ **参数**:
73
+ - `-o, --output`: 输出模式
74
+ - `image` (默认): 保存二维码图片到临时目录,输出图片路径
75
+ - `base64`: 输出 base64 编码的图片数据(含 `data:image/png;base64,` 前缀)
76
+ - `terminal`: 打开系统图片查看器扫码(非 ASCII 渲染)
77
+
78
+ **输出示例** (image 模式):
79
+ ```json
80
+ {"qrcode": "xxx", "qrcode_img_path": "/tmp/kugou-qrcode.png", "status": "waiting"}
81
+ ```
82
+
83
+ **输出示例** (base64 模式):
84
+ ```json
85
+ {"qrcode": "xxx", "qrcode_base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "status": "waiting"}
86
+ ```
87
+
88
+ **输出示例** (terminal 模式):
89
+ ```json
90
+ {"qrcode": "xxx", "qrcode_img_path": "C:\Users\xxx\AppData\Local\Temp\kugou-qrcode.png", "status": "waiting"}
91
+ ```
92
+
93
+ **轮询状态**:
94
+ - `status: scanned` - 已扫码,等待确认
95
+ - `status: success` - 登录成功
96
+ - `status: failed` - 登录失败(二维码过期)
97
+
98
+ ---
99
+
100
+ ### 2. 查看登录状态
101
+
102
+ ```bash
103
+ kugou-cli auth status
104
+ ```
105
+
106
+ **输出示例**:
107
+ ```json
108
+ {"logged_in": true, "nickname": "沙墨", "login_time": "2024-01-01 12:00:00"}
109
+ ```
110
+
111
+ ---
112
+
113
+ ### 3. 搜索歌曲
114
+
115
+ ```bash
116
+ kugou-cli music search "周杰伦"
117
+ kugou-cli music search "周杰伦" --page 1 --size 20
118
+ ```
119
+
120
+ **参数**:
121
+ - `<keyword>`: 搜索关键词(必填)
122
+ - `--page`: 页码,默认 1
123
+ - `--size`: 每页数量,默认 20
124
+
125
+ **输出示例**:
126
+ ```json
127
+ {
128
+ "errcode": 0,
129
+ "data": {
130
+ "list": [
131
+ {
132
+ "song_name": "晴天",
133
+ "mix_song_id": "32100650",
134
+ "artist_name": "周杰伦",
135
+ "play_link": "https://www.kugou.com/mixsong/agent_gateway/j410q78a01f.html"
136
+ }
137
+ ],
138
+ "total": 480,
139
+ "page": 1,
140
+ "size": 20
141
+ },
142
+ "status": 1
143
+ }
144
+ ```
145
+
146
+ ---
147
+
148
+ ### 4. 每日推荐
149
+
150
+ ```bash
151
+ kugou-cli music recommend daily
152
+ kugou-cli music recommend daily --num 10
153
+ ```
154
+
155
+ **参数**:
156
+ - `--num`: 推荐数量,默认 10
157
+ - `--text`: 描述文本(可选)
158
+
159
+ ---
160
+
161
+ ### 5. 相似推荐
162
+
163
+ ```bash
164
+ kugou-cli music recommend similar -s "晴天"
165
+ kugou-cli music recommend similar --song "晴天" -n 5
166
+ ```
167
+
168
+ **参数**:
169
+ - `-s, --song`: 歌曲名称(必填)
170
+ - `-n, --num`: 推荐数量,默认 10
171
+ - `-t, --text`: 描述文本(可选)
172
+
173
+ ---
174
+
175
+ ### 6. 我的收藏
176
+
177
+ ```bash
178
+ kugou-cli music favorites
179
+ kugou-cli music favorites --page 1 --size 20
180
+ ```
181
+
182
+ **参数**:
183
+ - `--page`: 页码,默认 1
184
+ - `--size`: 每页数量,默认 20
185
+
186
+ ---
187
+
188
+ ### 7. 最近播放
189
+
190
+ ```bash
191
+ kugou-cli music recent
192
+ kugou-cli music recent --page 1 --size 20
193
+ ```
194
+
195
+ **参数**:
196
+ - `--page`: 页码,默认 1
197
+ - `--size`: 每页数量,默认 20
198
+
199
+ ---
200
+
201
+ ### 8. 听歌统计
202
+
203
+ ```bash
204
+ kugou-cli music stats
205
+ ```
206
+
207
+ **输出示例**:
208
+ ```json
209
+ {
210
+ "errcode": 0,
211
+ "data": {
212
+ "server_time": 1779977674,
213
+ "listen_duration": 80776,
214
+ "accumulate_listen_days": 1,
215
+ "continue_listen_days": 1,
216
+ "listen_total": 342,
217
+ "last_listen_total": 387,
218
+ "rank_song": [...],
219
+ "rank_singer": [...],
220
+ "rank_style": [...],
221
+ "rank_language": [...]
222
+ },
223
+ "status": 1
224
+ }
225
+ ```
226
+
227
+ **关键字段**:
228
+ - `listen_duration`: 累计听歌时长(秒)
229
+ - `listen_total`: 累计听歌数量
230
+ - `rank_song`: 播放最多的歌曲排行
231
+ - `rank_singer`: 播放最多的歌手排行
232
+
233
+ ---
234
+
235
+ ### 9. 榜单
236
+
237
+ ```bash
238
+ kugou-cli music charts 6666
239
+ kugou-cli music charts 52144 --page 1 --size 20
240
+ ```
241
+
242
+ **可用榜单 ID**:
243
+
244
+ | rank_id | 榜单名称 |
245
+ |---------|----------|
246
+ | 8888 | TOP500榜 |
247
+ | 90379 | 星耀星光榜 |
248
+ | 6666 | 飙升榜 |
249
+ | 85432 | 百万收藏榜 |
250
+ | 74534 | 新歌榜 |
251
+ | 52144 | 抖音热歌酷狗榜 |
252
+
253
+ **参数**:
254
+ - `<rank_id>`: 榜单 ID(必填)
255
+ - `--page`: 页码,默认 1
256
+ - `--size`: 每页数量,默认 20
257
+
258
+ ---
259
+
260
+ ### 10. 安装 SKILL.md
261
+
262
+ ```bash
263
+ kugou-cli install --all # 安装到所有平台
264
+ kugou-cli install --claude # 仅安装到 Claude
265
+ kugou-cli install --hermes --claude # 安装到 Hermes 和 Claude
266
+ ```
267
+
268
+ **参数**:
269
+ - `--claude`: 安装到 `~/.claude/skills/kugou-skill/`
270
+ - `--hermes`: 安装到 `~/.hermes/skills/kugou-skill/`
271
+ - `--openclaw`: 安装到 `~/.openclaw/skills/kugou-skill/`
272
+ - `--codex`: 安装到 `~/.codex/skills/kugou-skill/`
273
+ - `--all`: 安装到以上所有平台
274
+
275
+ **说明**:
276
+ - npm 安装时会自动调用 install.js 安装 SKILL.md
277
+ - `kugou-cli install` 命令用于手动重新安装或更新 SKILL.md
278
+ - 只在目标平台目录存在时才安装,不自动创建目录
279
+
280
+ ---
281
+
282
+ ## 全局参数
283
+
284
+ 所有命令支持以下隐藏参数:
285
+
286
+ - `--proxy`: HTTP 代理地址,用于网络受限环境
287
+ ```bash
288
+ kugou-cli music search "周杰伦" --proxy "http://127.0.0.1:7890"
289
+ ```
290
+
291
+ ## 输出格式
292
+
293
+ 所有命令输出原始 JSON 响应,方便程序解析。
294
+
295
+ **通用响应结构**:
296
+ ```json
297
+ {
298
+ "errcode": 0,
299
+ "errmsg": "",
300
+ "data": { ... },
301
+ "status": 1
302
+ }
303
+ ```
304
+
305
+ **响应状态**:
306
+ - `errcode: 0` 表示成功
307
+ - `data` 包含实际业务数据
308
+ - `status: 1` 表示接口调用成功
309
+
310
+ ---
311
+
312
+ ## 错误处理
313
+
314
+ 错误信息输出到 stderr,程序 exit code 为 1:
315
+
316
+ ```bash
317
+ kugou-cli music search "xxx" 2>&1
318
+ echo $? # 非 0 表示出错
319
+ ```
320
+
321
+ **常见错误**:
322
+ - `not logged in`: 需要先登录
323
+ - `HTTP error: 400/500`: 服务端错误
324
+ - `network error`: 网络连接问题
325
+
326
+ ---
327
+
328
+ ## 使用示例
329
+
330
+ ### 完整使用流程
331
+
332
+ ```bash
333
+ # 1. 登录
334
+ kugou-cli auth login
335
+
336
+ # 2. 查看登录状态
337
+ kugou-cli auth status
338
+
339
+ # 3. 搜索歌曲
340
+ kugou-cli music search "周杰伦"
341
+
342
+ # 4. 获取每日推荐
343
+ kugou-cli music recommend daily --num 5
344
+
345
+ # 5. 查看我的收藏
346
+ kugou-cli music favorites --page 1
347
+
348
+ # 6. 查看最近播放
349
+ kugou-cli music recent --size 10
350
+
351
+ # 7. 查看听歌统计
352
+ kugou-cli music stats
353
+
354
+ # 8. 查看抖音热歌榜
355
+ kugou-cli music charts 52144
356
+ ```
357
+
358
+ ### 在脚本中使用
359
+
360
+ ```bash
361
+ #!/bin/bash
362
+
363
+ # 搜索并提取歌曲名
364
+ result=$(kugou-cli music search "周杰伦" --size 1)
365
+ echo "$result" | jq -r '.data.list[0].song_name'
366
+
367
+ # 获取榜单第一首
368
+ kugou-cli music charts 6666 --size 1 | jq -r '.data.list[0].song_name'
369
+ ```
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@kg-ai/kugou-skill",
3
+ "version": "0.0.1",
4
+ "description": "Kugou Skill CLI",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "kugou-cli": "./scripts/run.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node ./scripts/install.js"
11
+ },
12
+ "keywords": [
13
+ "cli",
14
+ "kugou"
15
+ ],
16
+ "files": [
17
+ "bin",
18
+ "scripts",
19
+ "SKILL.md"
20
+ ],
21
+ "author": "",
22
+ "license": "MIT",
23
+ "engines": {
24
+ "node": ">=16"
25
+ }
26
+ }
@@ -0,0 +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');
@@ -0,0 +1,62 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+ const binDir = path.join(__dirname, '..', 'bin');
8
+ const pkgRoot = path.join(__dirname, '..');
9
+
10
+ // 平台映射
11
+ const platformMap = {
12
+ 'darwin': { dir: `darwin-${arch}`, exe: 'kugou-cli' },
13
+ 'linux': { dir: `linux-${arch}`, exe: 'kugou-cli' },
14
+ 'win32': { dir: `win32-x64`, exe: 'kugou-cli.exe' }
15
+ };
16
+
17
+ const config = platformMap[platform];
18
+ if (!config) {
19
+ console.error(`Unsupported platform: ${platform}`);
20
+ process.exit(1);
21
+ }
22
+
23
+ // 安装二进制
24
+ const srcBin = path.join(binDir, config.dir, config.exe);
25
+ const destBin = path.join(binDir, config.exe);
26
+
27
+ if (!fs.existsSync(srcBin)) {
28
+ console.error(`Binary not found for ${platform}-${arch}: ${srcBin}`);
29
+ console.error('Please report this issue: https://github.com/kg-ai/kugou-cli/issues');
30
+ process.exit(1);
31
+ }
32
+
33
+ fs.copyFileSync(srcBin, destBin);
34
+ fs.chmodSync(destBin, 0o755);
35
+ console.log(`Installed ${config.exe} for ${platform}-${arch}`);
36
+
37
+ // 安装 SKILL.md 到各平台的 skills 目录
38
+ const skillSrc = path.join(pkgRoot, 'SKILL.md');
39
+ const skillDirs = [
40
+ path.join(os.homedir(), '.claude', 'skills', 'kugou-skill'),
41
+ path.join(os.homedir(), '.hermes', 'skills', 'kugou-skill'),
42
+ path.join(os.homedir(), '.openclaw', 'skills', 'kugou-skill'),
43
+ path.join(os.homedir(), '.codex', 'skills', 'kugou-skill'),
44
+ ];
45
+
46
+ if (fs.existsSync(skillSrc)) {
47
+ for (const skillDir of skillDirs) {
48
+ // 只在 skills 目录存在时才复制,不创建目录
49
+ const parentDir = path.dirname(skillDir);
50
+ if (fs.existsSync(parentDir)) {
51
+ try {
52
+ if (!fs.existsSync(skillDir)) {
53
+ fs.mkdirSync(skillDir, { recursive: true });
54
+ }
55
+ fs.copyFileSync(skillSrc, path.join(skillDir, 'SKILL.md'));
56
+ console.log(`Installed SKILL.md to ${skillDir}`);
57
+ } catch (err) {
58
+ console.warn(`Warning: Failed to install SKILL.md to ${skillDir}: ${err.message}`);
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +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');
package/scripts/run.js ADDED
@@ -0,0 +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
+ });