dsh-music-player 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +39 -5
  2. package/lib/index.js +4 -0
  3. package/package.json +12 -1
package/README.md CHANGED
@@ -16,17 +16,24 @@ DeepSeek Harness 本地音乐库播放器插件(bundle)。
16
16
 
17
17
  需要已安装 `dsh` CLI。
18
18
 
19
- 直接从一个 git 托管安装(推荐,无构建步骤):
19
+ ### 从 npm 安装(推荐,已发布到 registry)
20
20
 
21
21
  ```sh
22
- # 安装到你的 profile(把 <profile> 换成实际 profile 名,如 web)
22
+ # 把 <profile> 换成实际 profile 名,如 web
23
+ dsh plugin --profile <profile> add dsh-music-player
24
+ ```
25
+
26
+ ### 从 GitHub 安装(备用来源)
27
+
28
+ ```sh
29
+ # 把 <profile> 换成实际 profile 名,如 web
23
30
  dsh plugin --profile <profile> add github:kendu76/dsh-music-player
24
31
  ```
25
32
 
26
- > 项目是手写的纯 JS(`lib/` 直接是发布产物),**没有**需要从源码构建的步骤,因此从 GitHub 直装即可使用,无需像 TypeScript 包那样为构建脚本授权。
33
+ > 项目是手写的纯 JS(`lib/` 直接是发布产物),**没有**需要从源码构建的步骤,因此从 GitHub/npm 直装即可使用,无需像 TypeScript 包那样为构建脚本授权。
27
34
 
28
35
  安装后重启 DSH,打开 Web GUI:
29
- - 聊天输入区下方会出现「本地音乐播放器」播放条
36
+ - 聊天输入区上方会出现「本地音乐播放器」播放条
30
37
  - 点击右侧「列表」按钮打开播放面板
31
38
  - 在面板顶部点击「选择音乐目录」并选定音乐目录(默认 `~/Music`),自动递归扫描
32
39
  - 之后可直接在对话框里让 agent 播放,例如「播放周杰伦的歌」
@@ -61,11 +68,38 @@ dsh plugin --profile <profile> add ./dsh-music-player-0.1.0.tgz
61
68
 
62
69
  ## 开发
63
70
 
71
+ 需要 Node.js ≥ 20(vitest 建议 20.19+)与 npm。开发依赖仅 `vitest`:
72
+
73
+ ```sh
74
+ npm install
75
+ npm test # 跑 vitest 测试套件
76
+ ```
77
+
78
+ 修改 `lib/` 后,在本机 profile 里用 link 方式本地调试并验证:
79
+
64
80
  ```sh
65
- # 修改 lib/ 后,在本机 profile 里用 link 方式本地调试
66
81
  dsh plugin --profile <profile> add ./ # 或直接改 profile 里的 link 目标
67
82
  ```
68
83
 
84
+ 项目结构、测试策略与发布流程详见 [CONTRIBUTING.md](CONTRIBUTING.md)。
85
+
86
+ ## 常见问题
87
+
88
+ **播放没有声音 / 显示"浏览器拦截了自动播放"?**
89
+ 浏览器安全策略禁止未经交互的音频播放。首次自动播放被拦截是正常的——在播放条上点一次 ▶ 即可解锁,之后恢复播放。
90
+
91
+ **音乐面板显示"暂无音乐"或"不是有效的音乐目录"?**
92
+ 点面板顶部「选择音乐目录」,选一个包含音频文件的实际目录(默认 `~/Music`)。目录路径不可读或不存在时会回退到默认目录而不是报错。
93
+
94
+ **改了音乐目录/新增了歌曲,但列表没更新?**
95
+ 播放器在启动时扫描,并在每次“选择音乐目录”时重扫。想强制刷新当前目录,重新打开一次面板或点一次目录设置即可(扫描上限 500 首、递归子目录深度上限 4 层)。
96
+
97
+ **`music_play` 工具说"音乐库为空"?**
98
+ 说明还没有可用的音乐目录。请先打开播放面板,点「选择音乐目录」配置一次。
99
+
100
+ **想支持更多音频格式?**
101
+ 格式支持由 Host 端 `AUDIO_TYPES` 表驱动,在 `lib/index.js` 里加扩展名与 MIME 即可(播放器本身用浏览器原生 `<audio>` 解码,最终能否播放还取决于浏览器对该编码的支持)。
102
+
69
103
  ## License
70
104
 
71
105
  [MIT](LICENSE) © kendu76
package/lib/index.js CHANGED
@@ -232,6 +232,10 @@ export function apply(ctx) {
232
232
  }
233
233
  // audio streaming
234
234
  if (req.method !== 'GET' && req.method !== 'HEAD') { res.writeHead(405); res.end(); return }
235
+ // Ensure the library scan completes before resolving a track, so a
236
+ // streaming/HEAD request that arrives before any manifest call (or at
237
+ // startup) still finds its track instead of spuriously 404ing.
238
+ await ensureStarted()
235
239
  const id = pathname.slice('/dsh-music/'.length)
236
240
  const track = tracks.find((t) => t.id === id)
237
241
  if (track === undefined) { res.writeHead(404); res.end(); return }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-music-player",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DeepSeek Harness 本地音乐库播放器:Host 扫描音乐目录并以 HTTP 流式提供音频,浏览器侧提供播放条/播放面板/设置页与实时频谱,并注册 music_play 模型工具",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -28,6 +28,14 @@
28
28
  "url": "git+https://github.com/kendu76/dsh-music-player.git"
29
29
  },
30
30
  "license": "MIT",
31
+ "engines": {
32
+ "node": ">=20"
33
+ },
34
+ "scripts": {
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "ci": "vitest run"
38
+ },
31
39
  "dsh": {
32
40
  "bundle": {
33
41
  "patch": "./cordis.patch.yml"
@@ -39,5 +47,8 @@
39
47
  },
40
48
  "peerDependencies": {
41
49
  "react": "^18.2.0"
50
+ },
51
+ "devDependencies": {
52
+ "vitest": "^4.1.10"
42
53
  }
43
54
  }