@chenhao6682108/dsh-skill-netease-playlist 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 chenhao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,96 @@
1
- # Temporary Holding Version
1
+ # dsh-skill-netease-playlist
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English | [中文](README.zh.md)
4
+
5
+ A [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`) plugin that ships the
6
+ `netease-playlist` skill: drive NetEase Cloud Music (网易云音乐) playlists through the **local desktop
7
+ client's own login state** — no QR scan, no password, no browser automation, and no cookie written to
8
+ disk.
9
+
10
+ It is a **skill plugin**: installing it registers one agent skill (plus its scripts) into the harness,
11
+ so the agent can search tracks, build playlists, and move MusicBee `.mbp` playlists to the cloud.
12
+
13
+ ## How the login state is obtained
14
+
15
+ The NetEase desktop client embeds Chromium (CEF). Its cookies live in an encrypted SQLite store, and the
16
+ AES key is wrapped by Windows DPAPI under the current user. The skill:
17
+
18
+ 1. DPAPI-unwraps `os_crypt.encrypted_key` → an AES-256-GCM key;
19
+ 2. decrypts each `v10` cookie with it, extracting `MUSIC_U` (the login credential) and `__csrf`;
20
+ 3. encrypts every `weapi/*` request body the way the client does and calls `music.163.com`.
21
+
22
+ The key and cookie copies are written only to a system temp directory and deleted immediately after
23
+ reading; cookies live in process memory only. Every command re-derives them (~1 s) by design.
24
+
25
+ ## What the skill does
26
+
27
+ | Command | Purpose |
28
+ |---|---|
29
+ | `ne login` | Verify the login state, print nickname and uid |
30
+ | `ne search <keywords>` | Search tracks |
31
+ | `ne create / rename / desc / privacy` | Create a playlist and edit its name, description, privacy (public or private) |
32
+ | `ne add / remove / list / delete` | Add tracks (`--order` preserves the given order), remove tracks, list, delete a playlist |
33
+ | `ne download <id>` | Download every track as local mp3 (320k, resumable) |
34
+ | `ne import-mbp [target] --groups a,b` | Bulk-import MusicBee `.mbp` playlists: parse → read tags → fuzzy-match → create → add in order → verify; `--sync` re-aligns the cloud playlist after the local one changed |
35
+
36
+ ## Requirements
37
+
38
+ - **Windows** — DPAPI and the desktop client's CEF store are Windows-only, and the scripts are `.cmd`.
39
+ - **NetEase Cloud Music desktop client installed and logged in** as the same Windows user that runs
40
+ `dsh` (DPAPI cannot decrypt another user's key).
41
+ - **Node ≥ 22.5** (the CLI uses the built-in `node:sqlite` to read the cookie store). The bundled DSH
42
+ host already satisfies this.
43
+
44
+ ## Install
45
+
46
+ ```sh
47
+ dsh plugin --profile web add @chenhao6682108/dsh-skill-netease-playlist # npm (once published)
48
+ dsh plugin --profile web add github:chenhao6682108/dsh-skill-netease-playlist # straight from the repo
49
+ dsh plugin --profile web add . # from a local checkout
50
+ ```
51
+
52
+ Restart `dsh web`; the skill catalog lists `netease-playlist`.
53
+
54
+ Uninstall with `dsh plugin --profile web remove @chenhao6682108/dsh-skill-netease-playlist`.
55
+
56
+ ## Known traps the skill documents
57
+
58
+ - Adding tracks inserts them **in reverse** (and batches of 25 internally too) — `--order` submits the
59
+ reversed array so display order matches; preserving order after an edit means "clear and rebuild".
60
+ - Write endpoints intermittently return `404 playlist not found`; the CLI retries 3× at 1.5 s.
61
+ - Rename/privacy only work through the plaintext `/api/playlist/update/*` endpoints.
62
+ - Search results are polluted by covers/remixes/live takes; the importer scores title/artist/duration
63
+ and refuses to substitute a different recording for the original.
64
+ - Downloading needs `weapi/song/enhance/download/url/v1`; streaming CDN URLs return 403.
65
+ - The `.mbp` prefix length varies per library, so the parser probes offsets 40–120 and requires an
66
+ exact end-of-file match.
67
+
68
+ ## Layout
69
+
70
+ ```text
71
+ package.json dsh.bundle.patch + engines.dsh
72
+ cordis.patch.yml inserts the plugin into the profile layer stack
73
+ lib/index.js registers the bundled skill (no dependencies, no build)
74
+ skills/netease-playlist/
75
+ SKILL.md the skill body the agent loads
76
+ scripts/ ne.cmd / ne.mjs (CLI), mbp-import.mjs, mbp.mjs, tagread.mjs,
77
+ extract-key.ps1 + Dpapi.cs (credential extraction)
78
+ ```
79
+
80
+ ## Canonical repository
81
+
82
+ This repository is the **canonical source** for `@chenhao6682108/dsh-skill-netease-playlist`. Forks
83
+ and redistributions are not affiliated with or endorsed by the author, and the npm package is
84
+ published only from this repository. This skill reads the desktop client's login state — read
85
+ [SECURITY.md](SECURITY.md) before running any copy that did not come from here.
86
+
87
+ ## Notes
88
+
89
+ - Pairs with [`@chenhao6682108/dsh-skill-musicbee`](../dsh-skill-musicbee): download from NetEase, tag the
90
+ files, publish the playlist into MusicBee.
91
+ - `extract-key.ps1` and `Dpapi.cs` are deliberately ASCII-only — Windows PowerShell 5.1 decodes
92
+ BOM-less UTF-8 as ANSI and would mangle non-ASCII source.
93
+
94
+ ## License
95
+
96
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,84 @@
1
+ # dsh-skill-netease-playlist
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 把 `netease-playlist` 技能打包成 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)插件的仓库。
6
+ 它直接复用**本机网易云音乐桌面客户端自己的登录态**:不扫码、不要密码、不走浏览器自动化,cookie 也不落盘。
7
+
8
+ 属于**技能型插件**:装上之后技能出现在会话目录里,模型按需加载并调用包内脚本搜索曲目、建歌单、把 MusicBee 的 `.mbp` 歌单搬上云端。
9
+
10
+ ## 登录态是怎么来的
11
+
12
+ 网易云客户端内嵌 Chromium(CEF),cookie 存在加密 SQLite 里,密钥由 Windows DPAPI 按当前用户加密包裹。技能会:
13
+
14
+ 1. 用 DPAPI 解开 `os_crypt.encrypted_key` → 得到 AES-256-GCM 密钥;
15
+ 2. 用它解每条 `v10` cookie,取出 `MUSIC_U`(登录凭据)与 `__csrf`;
16
+ 3. 按客户端的规则加密 `weapi/*` 请求体后调用 `music.163.com`。
17
+
18
+ 密钥与 cookie 副本只写到系统临时目录、读完立刻删除,cookie 只在进程内存里用。每条命令都重新解一次(约 1 秒),这是刻意的设计。
19
+
20
+ ## 技能能做什么
21
+
22
+ | 命令 | 作用 |
23
+ |---|---|
24
+ | `ne login` | 验证登录态,打印昵称与 uid |
25
+ | `ne search <关键词>` | 搜索曲目 |
26
+ | `ne create / rename / desc / privacy` | 新建歌单,改名/改简介/改隐私(公开可被收藏、私密仅自己可见) |
27
+ | `ne add / remove / list / delete` | 加歌(`--order` 保证显示顺序=给定顺序)、移歌、列曲目、删歌单 |
28
+ | `ne download <id>` | 下载歌单全部歌曲为本地 mp3(320k,断点续传) |
29
+ | `ne import-mbp [目标] --groups a,b` | 把 MusicBee `.mbp` 歌单批量搬上云端:解析→读标签→模糊匹配→建单→按序加歌→复核;`--sync` 在本地歌单改过后把云端对齐 |
30
+
31
+ ## 环境要求
32
+
33
+ - **Windows**:DPAPI 与客户端 CEF 存储都是 Windows 专有,脚本也是 `.cmd`。
34
+ - **已安装并登录网易云音乐桌面客户端**,且运行 `dsh` 的是**同一个 Windows 用户**(DPAPI 解不了别的用户的密钥)。
35
+ - **Node ≥ 22.5**(CLI 用内置 `node:sqlite` 读 cookie 库)。DSH 宿主本身已满足。
36
+
37
+ ## 安装
38
+
39
+ ```sh
40
+ dsh plugin --profile web add @chenhao6682108/dsh-skill-netease-playlist # npm(发布后)
41
+ dsh plugin --profile web add github:chenhao6682108/dsh-skill-netease-playlist # 直接从仓库装
42
+ dsh plugin --profile web add . # 从本地 checkout 装
43
+ ```
44
+
45
+ 重启 `dsh web`,技能目录里就有 `netease-playlist`。
46
+
47
+ 卸载:`dsh plugin --profile web remove @chenhao6682108/dsh-skill-netease-playlist`。
48
+
49
+ ## 技能里记录的坑
50
+
51
+ - 加歌是**倒序插入**(同批 25 首内部也倒序)→ `--order` 提交倒序数组来保证显示顺序;改过歌单后要保序只能整单清空重建。
52
+ - 写接口偶发 `404 歌单不存在`,CLI 内置 3 次重试、间隔 1.5s。
53
+ - 改名/隐私只有明文 `/api/playlist/update/*` 接口可用。
54
+ - 搜索被翻唱/remix/Live 污染,导入流程按标题/艺人/时长打分,低于阈值宁可不加。
55
+ - 下载必须用 `weapi/song/enhance/download/url/v1`,流媒体 CDN 链接一律 403。
56
+ - `.mbp` 前缀长度因库而异,解析器从 40~120 字节逐个偏移试解并要求恰好读到文件末尾。
57
+
58
+ ## 目录结构
59
+
60
+ ```text
61
+ package.json dsh.bundle.patch + engines.dsh
62
+ cordis.patch.yml 把插件插入 profile 层栈
63
+ lib/index.js 注册包内技能(零依赖、零构建)
64
+ skills/netease-playlist/
65
+ SKILL.md 模型加载的技能正文
66
+ scripts/ ne.cmd / ne.mjs(CLI)、mbp-import.mjs、mbp.mjs、tagread.mjs、
67
+ extract-key.ps1 + Dpapi.cs(凭据提取)
68
+ ```
69
+
70
+ ## 官方仓库
71
+
72
+ 本仓库是 `@chenhao6682108/dsh-skill-netease-playlist` 的**唯一官方源**。任何 fork 或二次分发都与作者无关、
73
+ 也不代表作者背书;npm 包只从本仓库发布。本技能会读取客户端登录态——**运行任何非本仓库来源的副本前,
74
+ 请先读 [SECURITY.md](SECURITY.md)**。
75
+
76
+ ## 注意
77
+
78
+ - 和 [`@chenhao6682108/dsh-skill-musicbee`](../dsh-skill-musicbee) 配套:从网易云下载 → 补标签 → 进 MusicBee。
79
+ - `extract-key.ps1` 与 `Dpapi.cs` **刻意保持纯 ASCII**——Windows PowerShell 5.1 会把无 BOM 的 UTF-8 当 ANSI 解码,
80
+ 非 ASCII 源码会解析失败。
81
+
82
+ ## 许可
83
+
84
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,59 @@
1
+ # Security
2
+
3
+ This skill touches your NetEase Cloud Music **login state**, so how it handles credentials is the
4
+ most important thing about it. This file states exactly what it does.
5
+
6
+ ## Credential handling
7
+
8
+ 1. `extract-key.ps1` reads `%LOCALAPPDATA%\Netease\CloudMusic\webapp91x64\LocalPrefs.json` and unwraps
9
+ `os_crypt.encrypted_key` with **DPAPI** (scope: the current Windows user).
10
+ 2. The resulting AES-256-GCM key decrypts the `v10` cookies in the client's SQLite store. Only
11
+ `MUSIC_U` (the login credential) and `__csrf` (write-request token) are used.
12
+ 3. Key and cookie copies are written **only** to a system temp directory, deleted immediately, and the
13
+ cookies live in process memory for the lifetime of one command.
14
+ 4. Nothing credential-related is persisted: no cookie jar, no token file, no credential logging.
15
+ `NE_DEBUG=1` prints request paths and bodies, never cookies.
16
+
17
+ Every command re-derives the key (~1 second) by design. Do not "optimize" this into a disk cache.
18
+
19
+ ## Network
20
+
21
+ Requests go only to `music.163.com` (weapi and plaintext playlist/song endpoints). No other host is
22
+ contacted and no telemetry is sent. Downloads use the official
23
+ `weapi/song/enhance/download/url/v1` endpoint and save the raw mp3 to the folder you name.
24
+
25
+ ## Scope of writes
26
+
27
+ - Local: files downloaded under `--out` (default `%USERPROFILE%\CloudMusic\<playlist name>`).
28
+ - Remote: playlists **you name explicitly** — `create`, `add`, `remove`, `rename`, `desc`, `privacy`,
29
+ `delete`, and `import-mbp` / `--sync` (which rebuilds the named playlist in place). Use
30
+ `import-mbp --dry-run` to preview before anything is written.
31
+
32
+ ## Threat model
33
+
34
+ - **DPAPI is user-scoped**: decryption works only for the same Windows user that is logged in to the
35
+ client. Running `dsh` as another user or elevated fails by design.
36
+ - **Your client directory is a credential**: whoever can read `%LOCALAPPDATA%\Netease` under your
37
+ account can act as you on NetEase. Protect it with normal file permissions and the Windows password.
38
+ - **Forks are not covered**: a modified copy of this skill can read those cookies and send them
39
+ anywhere. Trust the canonical repository (`github.com/chenhao6682108/dsh-skill-netease-playlist`) and
40
+ the npm package built from it; check the source of anything else before running it.
41
+
42
+ ## Requirements it enforces
43
+
44
+ `scripts\ne-ensure.ps1` guarantees **Node ≥ 22.5** with a usable `node:sqlite` before the CLI runs,
45
+ and only falls back to `winget install OpenJS.NodeJS.LTS` when no suitable Node exists. The skill
46
+ itself is zero-dependency: it imports Node built-ins only.
47
+
48
+ ## Reporting a vulnerability
49
+
50
+ Please report privately, not in a public issue:
51
+
52
+ - GitHub → this repository → **Security** tab → *Report a vulnerability*, or
53
+ - email `13714251547@163.com`.
54
+
55
+ Include the plugin version and reproduction steps.
56
+
57
+ ## Supported versions
58
+
59
+ Only the latest published version receives security fixes.
@@ -0,0 +1,5 @@
1
+ # DSH bundle patch: inserts this plugin into a profile's plugin layer stack.
2
+ # Installed with: dsh plugin --profile <profile> add <package-or-tarball>
3
+ - insert:
4
+ - id: skill-netease-playlist
5
+ name: '@chenhao6682108/dsh-skill-netease-playlist'
package/lib/index.js ADDED
@@ -0,0 +1,106 @@
1
+ /**
2
+ * `@chenhao6682108/dsh-skill-netease-playlist` — ships the `netease-playlist` skill as
3
+ * an installable DSH plugin.
4
+ *
5
+ * A Cordis function plugin with no dependencies and no build step: `apply()`
6
+ * reads this package's bundled `skills/netease-playlist/SKILL.md`, parses its
7
+ * frontmatter, and registers the body into the harness skill registry
8
+ * (`ctx.skills`) with a directory resource base, so the relative `scripts/`
9
+ * paths in the body resolve against the installed package.
10
+ *
11
+ * The plugin is a bundle: `cordis.patch.yml` inserts it into a profile's layer
12
+ * stack when installed with `dsh plugin add`.
13
+ *
14
+ * @module @chenhao6682108/dsh-skill-netease-playlist
15
+ */
16
+
17
+ import { readFileSync } from 'node:fs'
18
+ import { fileURLToPath } from 'node:url'
19
+
20
+ /** Plugin name shown by the loader. */
21
+ export const name = 'skill-netease-playlist'
22
+
23
+ /** The skill registry is the only host service this plugin touches. */
24
+ export const inject = ['skills']
25
+
26
+ const SKILL_DIR = new URL('../skills/netease-playlist/', import.meta.url)
27
+
28
+ /** Shown only when the bundled SKILL.md loses its frontmatter description. */
29
+ const FALLBACK_DESCRIPTION =
30
+ 'NetEase Cloud Music playlist toolkit: reuse the local desktop client login state ' +
31
+ '(DPAPI-decrypted CEF cookie) to search tracks, create/rename/describe/private playlists, ' +
32
+ 'add and reorder tracks, delete playlists, download playlist audio as mp3, and bulk-import ' +
33
+ 'MusicBee .mbp playlists into the cloud. Windows plus a logged-in NetEase Cloud Music ' +
34
+ 'client required.'
35
+
36
+ /**
37
+ * Parse leading YAML frontmatter into flat fields.
38
+ *
39
+ * Only the subset a SKILL.md uses is understood: `key: value` scalars and
40
+ * `key:` followed by `- item` lists. Deeper YAML (nested maps, block scalars)
41
+ * is not needed by any argument this plugin ships, so it is left alone rather
42
+ * than half-parsed.
43
+ *
44
+ * @param {string} raw - full SKILL.md text.
45
+ * @returns {{ fields: Record<string, string | string[]>, body: string }}
46
+ */
47
+ function parseFrontmatter(raw) {
48
+ const text = raw.replace(/^\uFEFF/, '')
49
+ const match = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text)
50
+ if (match === null) return { fields: {}, body: text }
51
+
52
+ /** @type {Record<string, string | string[]>} */
53
+ const fields = {}
54
+ let key = null
55
+ for (const line of match[1].split(/\r?\n/)) {
56
+ if (line.trim() === '' || /^[ \t]*#/.test(line)) continue
57
+
58
+ const item = /^[ \t]*-[ \t]+(.*)$/.exec(line)
59
+ if (item !== null && key !== null) {
60
+ const list = Array.isArray(fields[key]) ? fields[key] : []
61
+ list.push(unquote(item[1].trim()))
62
+ fields[key] = list
63
+ continue
64
+ }
65
+
66
+ const pair = /^([A-Za-z][\w-]*)[ \t]*:[ \t]*(.*)$/.exec(line)
67
+ if (pair === null) continue
68
+ key = pair[1]
69
+ const value = pair[2].trim()
70
+ fields[key] = value === '' ? [] : unquote(value)
71
+ }
72
+ return { fields, body: text.slice(match[0].length) }
73
+ }
74
+
75
+ /**
76
+ * Strip one layer of matching single or double quotes.
77
+ * @param {string} value - raw scalar.
78
+ * @returns {string} the unquoted scalar.
79
+ */
80
+ function unquote(value) {
81
+ const quoted = /^(['"])([\s\S]*)\1$/.exec(value)
82
+ return quoted === null ? value : quoted[2]
83
+ }
84
+
85
+ /**
86
+ * Register the bundled skill into the harness skill registry.
87
+ * @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
88
+ */
89
+ export function apply(ctx) {
90
+ const source = readFileSync(new URL('SKILL.md', SKILL_DIR), 'utf8')
91
+ const { fields, body } = parseFrontmatter(source)
92
+
93
+ ctx.skills.register({
94
+ name: typeof fields.name === 'string' ? fields.name : 'netease-playlist',
95
+ description:
96
+ typeof fields.description === 'string' && fields.description !== ''
97
+ ? fields.description
98
+ : FALLBACK_DESCRIPTION,
99
+ ...(typeof fields.whenToUse === 'string' ? { whenToUse: fields.whenToUse } : {}),
100
+ content: body.trim(),
101
+ source: 'bundled',
102
+ path: fileURLToPath(new URL('SKILL.md', SKILL_DIR)),
103
+ resourceBase: { kind: 'directory', path: fileURLToPath(SKILL_DIR) },
104
+ metadata: { triggers: fields.triggers ?? [] },
105
+ })
106
+ }
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@chenhao6682108/dsh-skill-netease-playlist",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "NetEase Cloud Music playlist toolkit as a DSH skill plugin: reuse the local desktop client's login state to search tracks, create and edit playlists, add or reorder tracks, delete playlists, download playlist audio as mp3, and bulk-import MusicBee .mbp playlists into the cloud. Ships ne-ensure to install Node LTS when node:sqlite is unavailable. Windows and a logged-in NetEase Cloud Music client required.",
5
+ "keywords": [
6
+ "deepseek",
7
+ "harness",
8
+ "dsh",
9
+ "dsh-plugin",
10
+ "skill",
11
+ "netease",
12
+ "playlist",
13
+ "musicbee",
14
+ "mbp",
15
+ "music"
16
+ ],
17
+ "license": "MIT",
18
+ "type": "module",
19
+ "main": "./lib/index.js",
20
+ "exports": {
21
+ ".": "./lib/index.js",
22
+ "./cordis.patch.yml": "./cordis.patch.yml",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "lib",
27
+ "skills",
28
+ "cordis.patch.yml",
29
+ "README.md",
30
+ "README.zh.md",
31
+ "SECURITY.md",
32
+ "LICENSE"
33
+ ],
34
+ "engines": {
35
+ "node": ">=24.9.0",
36
+ "dsh": ">=0.1.2-rc.1 <0.2.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/chenhao6682108/dsh-skill-netease-playlist.git"
41
+ },
42
+ "dsh": {
43
+ "bundle": {
44
+ "patch": "./cordis.patch.yml"
45
+ }
46
+ }
47
+ }