@jojonadam/dsh-mriter 0.2.1 → 0.3.0

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 CHANGED
@@ -2,78 +2,43 @@
2
2
 
3
3
  > **一句话生成一首歌,不是创作,是抽奖。**
4
4
  >
5
- > Mriter 是人类深度参与的 AI 音乐制作工具:AI 给材料和可核对的事实,词、判断、决定始终在你。
5
+ > Mriter 是人类深度参与的 AI 音乐制作工具:AI 给可编辑的编曲草稿与可核对的事实,词、判断、决定始终在你。
6
6
 
7
- 把 Mriter 的引擎暴露成 DSH 里可调用的两个工具:歌词结构诊断、和弦走向稀有度。
8
- 词与判断留给你,引擎只负责算事实。本地运行,零网络请求。
7
+ 把 Mriter 引擎接进 DSH:**8 个工具**——风格库、声源面板、算法歌词、风格推荐、歌词体检、完整编曲(6 轨 MIDI/GP8),外加早期的创作方向报告与和弦稀有度查询。
8
+ 本地运行、零网络请求,**词与音频不出本机**。
9
9
 
10
- - 官网:<https://mriter.com>
10
+ - 官网 / 注册:<https://mriter.com>(注册即用网页版,33 种风格,词不上传)
11
11
  - npm:`@jojonadam/dsh-mriter`
12
12
 
13
+ ## 工具
13
14
 
14
- ## 与 SKILL 版本的区别
15
-
16
- | | SKILL(`packaging/dsh-skill`) | 插件(本目录) |
17
- |---|---|---|
18
- | 形态 | 提示词 + 命令行 | npm bundle,注册真实工具 |
19
- | 调用 | Agent 自己拼命令 | 结构化参数与返回值 |
20
- | 分发 | 拷 SKILL.md | `dsh plugin add` |
21
- | 引擎 | 需要本机 Python + 仓库 | 包内二进制,**不需要 Python** |
15
+ | 工具 | 作用 |
16
+ |---|---|
17
+ | `mriter_styles` | 33 种风格 id(style 参数唯一合法来源) |
18
+ | `mriter_sources` | 某风格的席位声源面板(原声/合成器、切换代价) |
19
+ | `mriter_random` | Roll 算法歌词(无语义层,需人工改) |
20
+ | `mriter_suggest` | 按词的句长/押韵给风格候选 |
21
+ | `mriter_diagnose` | 歌词体检(韵脚/套话/句长落差/助词密度) |
22
+ | `mriter_compose` | 完整编曲 → `.mid` + `.gp8`,支持 `scope` 局部重 Roll |
23
+ | `mriter_advice` | 歌词 → 创作方向八节报告(早期工具) |
24
+ | `mriter_progression` | 和弦走向在 1029 首中文流行语料里的稀有度 |
22
25
 
23
26
  ## 安装
24
27
 
25
28
  ```bash
26
- # 已发布到 npm(0.1.0,内置 darwin-arm64 二进制)
27
29
  dsh plugin --profile desktop add @jojonadam/dsh-mriter
28
-
29
- # 或装本地 checkout
30
- dsh plugin --profile desktop add ./packaging/dsh-plugin
31
-
32
- # 桌面版没有暴露 dsh CLI 时(本机实测路径)
33
- npx --yes @deepseek-ai/dsh@latest plugin --profile desktop add ./packaging/dsh-plugin
34
- ```
35
-
36
- **坑**:`dsh plugin` 内部要 spawn `pnpm`,桌面版把它打包在 app 里但没放进 PATH。
37
- 本机的做法是加一个 shim:
38
-
39
- ```bash
40
- cat > /tmp/pbin/pnpm <<'SH'
41
- #!/bin/sh
42
- exec node "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.cjs" "$@"
43
- SH
44
- chmod +x /tmp/pbin/pnpm
45
- PATH=/tmp/pbin:$PATH npx --yes @deepseek-ai/dsh@latest plugin --profile desktop add ./packaging/dsh-plugin
46
30
  ```
47
31
 
48
- 装完重启 DSH 生效。验证层已编入:
49
-
50
- ```bash
51
- npx --yes @deepseek-ai/dsh@latest --profile desktop --dump-config | grep -A2 mriter
52
- # == @jojonadam/dsh-mriter
53
- # - id: dsh-mriter
54
- ```
55
-
56
- ## 已验证
57
-
58
- - node 冒烟 12 项全过(工具元信息、引擎解析、八节报告、退出码 3、指定题材、空歌词报错)
59
- - 装进临时 profile `mritertest` 成功,`--dump-config` 里出现 `# == @jojonadam/dsh-mriter` 层
60
- - **已做(2026-11-11)**:装进 desktop profile(`plugin_manager` + `link:` 本地路径),
61
- 重启 DSH 后工具 `mriter_advice` 出现在工具列表,真实调用返回完整八节报告。
62
- 链路:DSH → 插件 JS → 包内二进制 → 报告,**全程不经过 Python 环境**。
63
-
64
- ## 引擎解析顺序
65
-
66
- 1. `MRITER_BIN` 环境变量
67
- 2. 包内 `bin/<platform>-<arch>/mriter`
68
- 3. `MRITER_HOME`(默认 `~/AI_Projects/Mriter`)+ `python3 -m antimusic.advice`
69
-
70
- 三者都找不到时,工具会明确报错并说明怎么修,不会静默失败。
32
+ 包内自带 `darwin-arm64` 二进制(`mriter` + `mriter-mcp`),**不需要 Python**。
33
+ 其他平台:插件会用 `npx -y @jojonadam/mriter-mcp` 兜底;也可设 `MRITER_MCP_BIN` / `MRITER_BIN` 指向自己的二进制。
71
34
 
72
- ## 平台
35
+ ## 契约(别自己发明)
73
36
 
74
- 当前只内置 `bin/darwin-arm64/mriter`(8.2MB)。其他平台需要各自构建后放进 `bin/<platform>-<arch>/`。
75
- 未内置的平台会退化到第 3 条(源码 + Python)。
37
+ - `style` 只能来自 `mriter_styles`
38
+ - `bars` 仅无词时生效,最小 64、按 8 吸附
39
+ - 重 Roll 用 `scope={seg,track,nonce}`,段名来自 `sections[].name`
40
+ - 同 `seed` 同参数 = 同产物;`fp_exact` 变了才说明真改了
76
41
 
77
- ## 签名
42
+ ## 隐私
78
43
 
79
- npm 安装不写 `com.apple.quarantine`,因此**不需要 Apple 签名**。只有浏览器直接下载二进制才需要。
44
+ 词与音频不出设备;插件零上报。服务端(网页版)只收两个指纹做查重,不收词与音频。
Binary file
package/index.js CHANGED
@@ -166,6 +166,146 @@ const progressionTool = {
166
166
  },
167
167
  };
168
168
 
169
+
170
+ // ---------- MCP 桥(六工具) ----------
171
+ const MCP_CANDIDATES = [
172
+ process.env.MRITER_MCP_BIN,
173
+ join(HERE, "bin", PLATFORM, "mriter-mcp"),
174
+ join(HERE, "bin", "mriter-mcp"),
175
+ ].filter(Boolean);
176
+
177
+ function resolveMcp() {
178
+ for (const p of MCP_CANDIDATES) {
179
+ if (p && existsSync(p)) return { cmd: p, base: [] };
180
+ }
181
+ return { cmd: "npx", base: ["-y", "@jojonadam/mriter-mcp"] };
182
+ }
183
+
184
+ async function mcpCall(tool, args, opts = {}) {
185
+ const m = resolveMcp();
186
+ const argv = [...m.base, "call", tool, JSON.stringify(args || {})];
187
+ if (opts.outDir) argv.push("--out-dir", opts.outDir);
188
+ const r = await run(m.cmd, argv, { timeout: 120000, maxBuffer: 16 * 1024 * 1024 });
189
+ if (r.code !== 0) {
190
+ throw new Error(`mriter-mcp ${tool} 失败(退出码 ${r.code}):${(r.stderr || r.stdout || "").trim().slice(0, 800)}`);
191
+ }
192
+ const raw = (r.stdout || "").trim();
193
+ try { return JSON.parse(raw); } catch { return { raw }; }
194
+ }
195
+
196
+ function jsonTool(name, description, parameters, fn) {
197
+ return {
198
+ name,
199
+ description,
200
+ parameters,
201
+ output: {
202
+ schema: { type: "object", additionalProperties: true,
203
+ properties: { text: { type: "string" } }, required: ["text"] },
204
+ render: (_a, v) => [{ type: "text", text: String((v && v.text) || "") }],
205
+ },
206
+ async execute(args) { return fn(args || {}); },
207
+ };
208
+ }
209
+
210
+ const stylesTool = jsonTool(
211
+ "mriter_styles",
212
+ "列出 Mriter 全部 33 种编曲风格(id/中文名/家族/默认)。**style 参数唯一合法来源**:先调它拿 id,不要猜风格名。",
213
+ { type: "object", properties: {} },
214
+ async () => {
215
+ const j = await mcpCall("mriter_styles");
216
+ const lines = (j.styles || []).map((s) => `${s[0]} · ${s[1]} · ${s[3] || ""}`).join("\n");
217
+ return { text: `Mriter 风格(${(j.styles || []).length} 个):\n${lines}\n\n默认:psy_electro`, styles: j.styles };
218
+ },
219
+ );
220
+
221
+ const sourcesTool = jsonTool(
222
+ "mriter_sources",
223
+ "查某风格的声源面板:每个席位的原声/合成器选项、默认声源与切换代价。切声源只改音色程序号,不改音符。",
224
+ { type: "object", properties: {
225
+ style: { type: "string", description: "风格 id(见 mriter_styles)" },
226
+ tier: { type: "string", enum: ["free", "base", "pro"], description: "许可档;不传即最高档" } } },
227
+ async (a) => {
228
+ const j = await mcpCall("mriter_sources", { style: a.style || "pop_rock", tier: a.tier });
229
+ return { text: JSON.stringify(j, null, 2), data: j };
230
+ },
231
+ );
232
+
233
+ const randomTool = jsonTool(
234
+ "mriter_random",
235
+ "Roll 一首算法歌词(模板+词库+押韵/句长约束,按风格定行长)。**没有语义层**,可能逻辑不通——必须提示用户人工修改后再用。",
236
+ { type: "object", properties: {
237
+ style: { type: "string", description: "风格 id" },
238
+ bpm: { type: "integer", description: "速度(影响行长)" },
239
+ lang: { type: "string", enum: ["zh", "en"], description: "返回语言,默认 zh" } } },
240
+ async (a) => {
241
+ const j = await mcpCall("mriter_random", { style: a.style || "pop_rock", bpm: a.bpm, lang: a.lang });
242
+ return { text: JSON.stringify(j, null, 2), data: j };
243
+ },
244
+ );
245
+
246
+ const suggestTool = jsonTool(
247
+ "mriter_suggest",
248
+ "给定歌词,按句长/押韵/重复率等信号给风格候选排名(带理由)。拿到候选后再用 mriter_compose 编曲。",
249
+ { type: "object", properties: {
250
+ lyrics: { type: "string", description: "歌词全文,逐行" },
251
+ lang: { type: "string", enum: ["zh", "en"], description: "返回语言,默认 zh" } },
252
+ required: ["lyrics"] },
253
+ async (a) => {
254
+ if (!a.lyrics) throw new Error("lyrics 不能为空");
255
+ const j = await mcpCall("mriter_suggest", { lyrics: a.lyrics, lang: a.lang });
256
+ const top = (j.candidates || []).slice(0, 5).map((c) => `${c[0]}(分 ${c[1]}${c[2] && c[2].length ? ";" + c[2].join(";") : ""})`).join("\n");
257
+ return { text: `风格候选:\n${top}`, candidates: j.candidates, signals: j.signals };
258
+ },
259
+ );
260
+
261
+ const diagnoseTool = jsonTool(
262
+ "mriter_diagnose",
263
+ "歌词体检:韵脚、套话、句长落差、助词/副词密度等问题清单(只建议不改词,每条带 issue/fix/why)。有词时先跑它再编曲。",
264
+ { type: "object", properties: {
265
+ lyrics: { type: "string", description: "歌词全文,逐行" },
266
+ lang: { type: "string", enum: ["zh", "en"], description: "返回语言,默认 zh" } },
267
+ required: ["lyrics"] },
268
+ async (a) => {
269
+ if (!a.lyrics) throw new Error("lyrics 不能为空");
270
+ const j = await mcpCall("mriter_diagnose", { lyrics: a.lyrics, lang: a.lang });
271
+ const items = (j.suggestions || []).map((x) => `- L${x.line} [${x.kind}] ${x.issue} → ${x.fix}(${x.why || ""})`).join("\n");
272
+ return { text: items || JSON.stringify(j, null, 2), data: j };
273
+ },
274
+ );
275
+
276
+ const composeTool = jsonTool(
277
+ "mriter_compose",
278
+ "完整编曲:把歌词/风格/参数编成多轨曲,本地写出 .mid 与 .gp8(路径在返回的 files),并返回段落坐标 sections。" +
279
+ "重 Roll 用 scope={seg,track,nonce},段名取自 sections[].name。产物是编曲草稿,不是成品歌。",
280
+ { type: "object", properties: {
281
+ lyrics: { type: "string", description: "歌词全文,[Verse]/[Chorus]/[Bridge] 标记曲式;留空 = 无词 club 编排" },
282
+ style: { type: "string", description: "风格 id(见 mriter_styles)" },
283
+ tonic: { type: "string", description: "主音,默认 C" },
284
+ bpm: { type: "integer" },
285
+ title: { type: "string" },
286
+ voice: { type: "string", enum: ["male", "female"] },
287
+ variation: { type: "integer" },
288
+ tier: { type: "string", enum: ["free", "base", "pro"] },
289
+ seed: { type: "integer" },
290
+ scope: { type: "object", description: "重 Roll 范围 {seg, track, nonce}" },
291
+ include_tracks: { type: "boolean", description: "是否返回完整音符(默认 false,省流量)" },
292
+ include_prompts: { type: "boolean", description: "是否返回四家平台提示词(默认 false)" } } },
293
+ async (a) => {
294
+ const dir = mkdtempSync(join(tmpdir(), "mriter-"));
295
+ const j = await mcpCall("mriter_compose", { ...a, include_tracks: a.include_tracks === true, include_prompts: a.include_prompts === true }, { outDir: dir });
296
+ const f = j.files || {};
297
+ const files = Object.entries(f).map(([k, v]) => `${k.toUpperCase()}: ${v.path}(${v.bytes} B)`).join("\n") || dir;
298
+ const secs = (j.sections || []).map((s) => `${s.name}[${s.bars[0]}-${s.bars[1]}]`).join(" ");
299
+ return {
300
+ text: `编曲完成:\n${files}\n\n段落:${secs}\n${j.bars_note ? "\n" + j.bars_note : ""}\n` +
301
+ `\n(这是可继续编辑的草稿;想在线试、或换风格/音色,去 mriter.com 注册即可用网页版。)`,
302
+ files: j.files, sections: j.sections, fp_exact: j.fp_exact, outDir: dir,
303
+ };
304
+ },
305
+ );
306
+
307
+ const MCP_TOOLS = [stylesTool, sourcesTool, randomTool, suggestTool, diagnoseTool, composeTool];
308
+
169
309
  function apply(ctx) {
170
310
  const tools = ctx.get("tools");
171
311
  if (tools === undefined) throw new Error("dsh-mriter 需要 tools 服务");
@@ -175,6 +315,9 @@ function apply(ctx) {
175
315
  if (tools.get(progressionTool.name) === undefined) {
176
316
  ctx.effect(() => tools.register(progressionTool));
177
317
  }
318
+ for (const t of MCP_TOOLS) {
319
+ if (tools.get(t.name) === undefined) ctx.effect(() => tools.register(t));
320
+ }
178
321
  }
179
322
 
180
- export { apply, inject, name, tool, progressionTool, advice, resolveEngine };
323
+ export { apply, inject, name, tool, progressionTool, advice, resolveEngine, MCP_TOOLS, mcpCall, resolveMcp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jojonadam/dsh-mriter",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -14,7 +14,7 @@
14
14
  "patch": "./cordis.patch.yml"
15
15
  }
16
16
  },
17
- "description": "Mriter for DSH:人类深度参与的 AI 音乐制作。反对话生成——AI 给材料和可核对的事实(1029 首语料的和弦稀有度、结构断点),词与判断留给你。本地引擎,零网络。",
17
+ "description": "Mriter for DSH:编曲与歌词诊断。8 个工具——33 风格库、声源面板、算法歌词、风格推荐、歌词体检、6 轨编曲(MIDI/GP8,按 seed 复现、支持局部重 Roll)。本地运行、零网络;词与音频不出本机。",
18
18
  "keywords": [
19
19
  "dsh",
20
20
  "dsh-plugin",
@@ -30,5 +30,12 @@
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "git+https://github.com/JOJO-Adam/dsh-mriter.git"
33
+ },
34
+ "peerDependencies": {
35
+ "@deepseek-ai/cordis": "^4.2.0-alpha.1"
36
+ },
37
+ "engines": {
38
+ "dsh": ">=0.2.3-alpha.2",
39
+ "node": ">=20"
33
40
  }
34
- }
41
+ }