@jojonadam/dsh-mriter 0.0.0-stage → 0.1.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 +66 -2
- package/bin/darwin-arm64/mriter +0 -0
- package/cordis.patch.yml +7 -0
- package/index.js +134 -0
- package/package.json +32 -3
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jojonadam/dsh-mriter · DSH 插件
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把 Mriter 暴露成 Agent 可调用的工具 `mriter_advice`。
|
|
4
|
+
|
|
5
|
+
## 与 SKILL 版本的区别
|
|
6
|
+
|
|
7
|
+
| | SKILL(`packaging/dsh-skill`) | 插件(本目录) |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| 形态 | 提示词 + 命令行 | npm bundle,注册真实工具 |
|
|
10
|
+
| 调用 | Agent 自己拼命令 | 结构化参数与返回值 |
|
|
11
|
+
| 分发 | 拷 SKILL.md | `dsh plugin add` |
|
|
12
|
+
| 引擎 | 需要本机 Python + 仓库 | 包内二进制,**不需要 Python** |
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 有 dsh CLI 时
|
|
18
|
+
dsh plugin --profile desktop add ./packaging/dsh-plugin
|
|
19
|
+
|
|
20
|
+
# 桌面版没有暴露 dsh CLI 时(本机实测路径)
|
|
21
|
+
npx --yes @deepseek-ai/dsh@latest plugin --profile desktop add ./packaging/dsh-plugin
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**坑**:`dsh plugin` 内部要 spawn `pnpm`,桌面版把它打包在 app 里但没放进 PATH。
|
|
25
|
+
本机的做法是加一个 shim:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cat > /tmp/pbin/pnpm <<'SH'
|
|
29
|
+
#!/bin/sh
|
|
30
|
+
exec node "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.cjs" "$@"
|
|
31
|
+
SH
|
|
32
|
+
chmod +x /tmp/pbin/pnpm
|
|
33
|
+
PATH=/tmp/pbin:$PATH npx --yes @deepseek-ai/dsh@latest plugin --profile desktop add ./packaging/dsh-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
装完重启 DSH 生效。验证层已编入:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx --yes @deepseek-ai/dsh@latest --profile desktop --dump-config | grep -A2 mriter
|
|
40
|
+
# == @jojonadam/dsh-mriter
|
|
41
|
+
# - id: dsh-mriter
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 已验证
|
|
45
|
+
|
|
46
|
+
- node 冒烟 12 项全过(工具元信息、引擎解析、八节报告、退出码 3、指定题材、空歌词报错)
|
|
47
|
+
- 装进临时 profile `mritertest` 成功,`--dump-config` 里出现 `# == @jojonadam/dsh-mriter` 层
|
|
48
|
+
- **已做(2026-11-11)**:装进 desktop profile(`plugin_manager` + `link:` 本地路径),
|
|
49
|
+
重启 DSH 后工具 `mriter_advice` 出现在工具列表,真实调用返回完整八节报告。
|
|
50
|
+
链路:DSH → 插件 JS → 包内二进制 → 报告,**全程不经过 Python 环境**。
|
|
51
|
+
|
|
52
|
+
## 引擎解析顺序
|
|
53
|
+
|
|
54
|
+
1. `MRITER_BIN` 环境变量
|
|
55
|
+
2. 包内 `bin/<platform>-<arch>/mriter`
|
|
56
|
+
3. `MRITER_HOME`(默认 `~/AI_Projects/Mriter`)+ `python3 -m antimusic.advice`
|
|
57
|
+
|
|
58
|
+
三者都找不到时,工具会明确报错并说明怎么修,不会静默失败。
|
|
59
|
+
|
|
60
|
+
## 平台
|
|
61
|
+
|
|
62
|
+
当前只内置 `bin/darwin-arm64/mriter`(8.2MB)。其他平台需要各自构建后放进 `bin/<platform>-<arch>/`。
|
|
63
|
+
未内置的平台会退化到第 3 条(源码 + Python)。
|
|
64
|
+
|
|
65
|
+
## 签名
|
|
66
|
+
|
|
67
|
+
npm 安装不写 `com.apple.quarantine`,因此**不需要 Apple 签名**。只有浏览器直接下载二进制才需要。
|
|
Binary file
|
package/cordis.patch.yml
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mriter DSH 插件:把「歌词 → 创作方向」暴露成 Agent 可调用的工具。
|
|
3
|
+
*
|
|
4
|
+
* 执行两层兜底:
|
|
5
|
+
* 1. 包内二进制 bin/<platform>-<arch>/mriter(自带引擎与数据,无需 Python)
|
|
6
|
+
* 2. 源码兜底 MRITER_HOME(默认 ~/AI_Projects/Mriter)+ python3 -m antimusic.advice
|
|
7
|
+
*
|
|
8
|
+
* 退出码 3 表示题材未判定:不猜,把可选题材原样返回,让 Agent 去问用户。
|
|
9
|
+
*/
|
|
10
|
+
import { execFile } from "node:child_process";
|
|
11
|
+
import { existsSync, mkdtempSync, writeFileSync, readFileSync } from "node:fs";
|
|
12
|
+
import { homedir, tmpdir } from "node:os";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
|
|
16
|
+
const name = "dsh-mriter";
|
|
17
|
+
const inject = ["tools"];
|
|
18
|
+
|
|
19
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const PLATFORM = `${process.platform}-${process.arch}`;
|
|
21
|
+
|
|
22
|
+
function run(cmd, argv, opts = {}) {
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
execFile(cmd, argv, { timeout: 120000, maxBuffer: 8 * 1024 * 1024, ...opts },
|
|
25
|
+
(err, stdout, stderr) => resolve({
|
|
26
|
+
code: err && typeof err.code === "number" ? err.code : (err ? 1 : 0),
|
|
27
|
+
stdout: String(stdout || ""), stderr: String(stderr || ""),
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function resolveEngine() {
|
|
33
|
+
const binCandidates = [
|
|
34
|
+
process.env.MRITER_BIN,
|
|
35
|
+
join(HERE, "bin", PLATFORM, "mriter"),
|
|
36
|
+
join(HERE, "bin", "mriter"),
|
|
37
|
+
].filter(Boolean);
|
|
38
|
+
for (const p of binCandidates) {
|
|
39
|
+
if (p && existsSync(p)) return { kind: "binary", cmd: p, base: [] };
|
|
40
|
+
}
|
|
41
|
+
const repo = process.env.MRITER_HOME || join(homedir(), "AI_Projects", "Mriter");
|
|
42
|
+
if (existsSync(join(repo, "antimusic", "advice.py"))) {
|
|
43
|
+
return { kind: "python", cmd: process.env.PYTHON || "python3", base: ["-m", "antimusic.advice"], cwd: repo };
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function advice({ lyrics, theme, share }) {
|
|
49
|
+
if (typeof lyrics !== "string" || !lyrics.trim()) throw new Error("lyrics 不能为空");
|
|
50
|
+
const engine = resolveEngine();
|
|
51
|
+
if (!engine) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"找不到 Mriter 引擎:包内没有本平台的二进制,也未检测到源码仓库。" +
|
|
54
|
+
"设 MRITER_HOME 指向仓库,或设 MRITER_BIN 指向二进制。");
|
|
55
|
+
}
|
|
56
|
+
const dir = mkdtempSync(join(tmpdir(), "mriter-"));
|
|
57
|
+
const lyricPath = join(dir, "lyrics.txt");
|
|
58
|
+
writeFileSync(lyricPath, lyrics, "utf8");
|
|
59
|
+
|
|
60
|
+
const argv = [...engine.base, "--lyrics", lyricPath, "--out", dir];
|
|
61
|
+
if (theme) argv.push("--theme", theme);
|
|
62
|
+
if (share) argv.push("--share");
|
|
63
|
+
|
|
64
|
+
const r = await run(engine.cmd, argv, engine.cwd ? { cwd: engine.cwd } : {});
|
|
65
|
+
const mdPath = join(dir, "advice.md");
|
|
66
|
+
const report = existsSync(mdPath) ? readFileSync(mdPath, "utf8") : "";
|
|
67
|
+
|
|
68
|
+
if (r.code === 2) {
|
|
69
|
+
return { text: `Mriter 输入错误(退出码 2):\n${r.stderr || r.stdout}`.trim(), exitCode: 2, outDir: dir };
|
|
70
|
+
}
|
|
71
|
+
if (r.code === 3) {
|
|
72
|
+
const hint = (r.stdout || "").split("\n").find((l) => l.includes("需要回答")) || "题材未判定";
|
|
73
|
+
return {
|
|
74
|
+
text: `Mriter 需要你先确认题材,再继续。\n${hint}\n\n` +
|
|
75
|
+
`拿到题材后,用同一份歌词加 theme 参数重跑(不要自己猜题材)。\n` +
|
|
76
|
+
`(本轮结构部分已生成:${dir}/advice.md)`,
|
|
77
|
+
exitCode: 3, outDir: dir, pending: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (!report) {
|
|
81
|
+
return { text: `Mriter 未产出报告(退出码 ${r.code})。\n${r.stderr || r.stdout}`.trim(), exitCode: r.code, outDir: dir };
|
|
82
|
+
}
|
|
83
|
+
return { text: report, exitCode: 0, outDir: dir };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const tool = {
|
|
87
|
+
name: "mriter_advice",
|
|
88
|
+
description:
|
|
89
|
+
"音乐创作助手:给定一段歌词,返回一份八节报告——结构扫描、结构性断点、作曲方向(音域/音符预算/长音落点/动机)、" +
|
|
90
|
+
"和声走向候选(带真实语料稀有度,1029 首中文流行)、风格卡(草稿态,逐条标出处)、词堆、编曲提示、盲区。" +
|
|
91
|
+
"用于用户从零开始写歌、卡住时找方向、检查词的韵与格律。**只给方向与材料,不产出完整词曲**。" +
|
|
92
|
+
"如果退出码/返回里提示题材未判定,必须回来问用户选哪个题材(童年怀旧/理想成长/爱情遗憾/城市漂泊)," +
|
|
93
|
+
"拿到答案后用 theme 参数重跑,不要自己猜题材。",
|
|
94
|
+
parameters: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
lyrics: { type: "string", description: "歌词全文,逐行给。不要传文件路径。" },
|
|
98
|
+
theme: {
|
|
99
|
+
type: "string",
|
|
100
|
+
enum: ["童年怀旧", "理想成长", "爱情遗憾", "城市漂泊"],
|
|
101
|
+
description: "仅在用户已确认题材时传入;未确认就不要猜。",
|
|
102
|
+
},
|
|
103
|
+
share: { type: "boolean", description: "是否另出一张自包含分享卡(不含歌词原文)。" },
|
|
104
|
+
},
|
|
105
|
+
required: ["lyrics"],
|
|
106
|
+
},
|
|
107
|
+
output: {
|
|
108
|
+
schema: {
|
|
109
|
+
type: "object",
|
|
110
|
+
additionalProperties: true,
|
|
111
|
+
properties: {
|
|
112
|
+
text: { type: "string" },
|
|
113
|
+
exitCode: { type: "number" },
|
|
114
|
+
outDir: { type: "string" },
|
|
115
|
+
pending: { type: "boolean" },
|
|
116
|
+
},
|
|
117
|
+
required: ["text"],
|
|
118
|
+
},
|
|
119
|
+
render: (_args, value) => [{ type: "text", text: String((value && value.text) || "") }],
|
|
120
|
+
},
|
|
121
|
+
async execute(args) {
|
|
122
|
+
return advice({ lyrics: args.lyrics, theme: args.theme, share: args.share });
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function apply(ctx) {
|
|
127
|
+
const tools = ctx.get("tools");
|
|
128
|
+
if (tools === undefined) throw new Error("dsh-mriter 需要 tools 服务");
|
|
129
|
+
if (tools.get(tool.name) === undefined) {
|
|
130
|
+
ctx.effect(() => tools.register(tool));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { apply, inject, name, tool, advice, resolveEngine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jojonadam/dsh-mriter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"cordis.patch.yml",
|
|
9
|
+
"bin",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"dsh": {
|
|
13
|
+
"bundle": {
|
|
14
|
+
"patch": "./cordis.patch.yml"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"description": "Mriter for DSH: 给一段歌词,返回结构扫描、断点、作曲方向、和声走向(带真实语料稀有度)、风格卡、词堆、编曲提示。本地引擎 + 内置二进制,零网络请求。",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"dsh",
|
|
20
|
+
"dsh-plugin",
|
|
21
|
+
"music",
|
|
22
|
+
"songwriting",
|
|
23
|
+
"lyric",
|
|
24
|
+
"song",
|
|
25
|
+
"创作",
|
|
26
|
+
"词曲"
|
|
27
|
+
],
|
|
28
|
+
"author": "JOJO",
|
|
29
|
+
"license": "UNLICENSED",
|
|
30
|
+
"homepage": "https://mriter.com",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/JOJO-Adam/Mriter.git"
|
|
34
|
+
}
|
|
6
35
|
}
|